#!/bin/bash

if [ ! -e ./build/kernel_util ]; then
    svn co -q svn+ssh://arcadia.yandex.ru/arc/trunk/arcadia/skynet/kernel/util@3303958 ./build/kernel_util
fi

if [ ! -e ./build/porto ]; then
    PORTO_VERSION=5.0.29
    if [ -z "$BB_TOKEN" ]; then
        REPO_URL="ssh://git@bb.yandex-team.ru/porto/porto.git"
    else
        REPO_URL="https://x-oauth-token:$BB_TOKEN@bb.yandex-team.ru/scm/porto/porto.git"
    fi
    git init ./build/porto
    pushd build/porto
    git fetch --depth 1 "$REPO_URL" "refs/tags/v$PORTO_VERSION"
    git checkout -f FETCH_HEAD
    cp src/rpc.proto src/api/python/porto/rpc.proto
    popd
fi
