| #!/usr/bin/env bash |
| # repo_bootstrap.sh |
| |
| # Use master as default version |
| REPO_BRANCH=${REPO_BRANCH:-'master'} |
| ONOS_REPO_DIR=${ONOS_REPO_DIR:-'~/onos_repo'} |
| |
| function install_repo_tool() { |
| if [ ! -x "/usr/local/bin/repo" ] |
| then |
| echo "Installing repo..." |
| REPO_SHA256SUM="e147f0392686c40cfd7d5e6f332c6ee74c4eab4d24e2694b3b0a0c037bf51dc5" # not versioned... |
| curl -o /tmp/repo https://storage.googleapis.com/git-repo-downloads/repo |
| echo "$REPO_SHA256SUM /tmp/repo" | sha256sum -c - |
| sudo mv /tmp/repo /usr/local/bin/repo |
| sudo chmod a+x /usr/local/bin/repo |
| fi |
| } |
| |
| function checkout_onos_with_repo() { |
| |
| if [ ! -d "$ONOS_REPO_DIR" ] |
| then |
| echo "Checking out ONOS using repo..." |
| |
| mkdir $ONOS_REPO_DIR && cd $ONOS_REPO_DIR |
| repo init -u https://gerrit.onosproject.org/manifest -b $REPO_BRANCH -g onos |
| repo sync |
| |
| # check out gerrit branches using repo |
| for gerrit_branch in ${GERRIT_BRANCHES[@]}; do |
| echo "Checking out opencord gerrit branch: $gerrit_branch" |
| repo download ${gerrit_branch/:/ } |
| done |
| fi |
| } |
| |
| # Parse options |
| GERRIT_BRANCHES= |
| |
| while getopts "b:chsv" opt; do |
| case ${opt} in |
| b ) GERRIT_BRANCHES+=("$OPTARG") |
| ;; |
| h ) echo "Usage:" |
| echo " $0 download ONOS using repo [default]" |
| echo " $0 -b <project:changeset/revision> checkout changesets from gerrit. Can" |
| echo " be used multiple times." |
| echo " $0 -h display this help message" |
| \? ) echo "Invalid option: -$OPTARG" |
| exit 1 |
| ;; |
| esac |
| done |
| |
| install_repo_tool() |
| checkout_onos_with_repo() |
| |