| #!/bin/bash |
| # ----------------------------------------------------------------------------- |
| # Runs the custom version of Buck required by ONOS. |
| # ----------------------------------------------------------------------------- |
| |
| set -e |
| |
| BUCK_URL="http://repo1.maven.org/maven2/org/onosproject/onos-buck/v2018.01.17.01/buck-v2018.01.17.01.zip" |
| BUCK_SHA="4a70a84ef40a06762a7248db25590696e80af9fe" |
| |
| [ "-U" = "$1" ] && shift && FORCE_UPDATE=True |
| |
| ROOT_DIR=${ONOS_ROOT:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"} |
| |
| mkdir -p $ROOT_DIR/bin |
| pushd $ROOT_DIR/bin > /dev/null |
| |
| if [ -n "$FORCE_UPDATE" ] || [ ! -f "buck" ] || [ "$BUCK_SHA" != "$(cat .buck_sha)" ]; then |
| echo "Updating Buck..." >&2 |
| rm -fr .buck_version .buck_sha buck plugins |
| mkdir -p cache |
| BUCK_FILE=$(basename $BUCK_URL) |
| # Check the local cache; download to cache if required |
| [ -f "cache/$BUCK_FILE" ] || curl -o cache/$BUCK_FILE -L $BUCK_URL |
| if [ -n "$(which shasum)" ]; then |
| SHA=$(shasum cache/$BUCK_FILE | cut -d' ' -f1) |
| if [ "$SHA" != "$BUCK_SHA" ]; then |
| echo "ERROR: Downloaded SHA ($SHA) does not match expected SHA ($BUCK_SHA)" && |
| rm -f cache/$BUCK_FILE && exit 1 |
| else |
| echo "$SHA" > .buck_sha |
| fi |
| else |
| echo "SHA cannot be verified" |
| fi |
| unzip cache/$BUCK_FILE |
| # Kill buckd |
| ps -ef | egrep buckd | grep -v egrep | cut -c7-11 | xargs kill 2>/dev/null || : |
| rm -rf $ROOT_DIR/buck-out |
| printf "Successfully updated Buck in $ROOT_DIR/bin/buck to $BUCK_FILE\n\n" |
| fi |
| popd > /dev/null |
| |
| BUCK=$ROOT_DIR/bin/buck |
| |
| if [ "${ONOS_NO_BUCKD:-1}" == "1" ]; then |
| export NO_BUCKD=1 |
| fi |
| |
| # Finally, run the Buck command... |
| $BUCK "$@" |