blob: 19dc908381d0f0b49bfc670717a225b83561bba7 [file] [log] [blame]
#!/bin/bash
# -----------------------------------------------------------------------------
# Runs the custom version of Buck required by ONOS.
# -----------------------------------------------------------------------------
set -e
BUCK_URL="http://onlab.vicci.org/onos/third-party/buck-v2016.10.20.01.zip"
BUCK_SHA="718ab518bf5edc7e92626e434551396171f3ab5a"
REQUIRED_VERSION="buck version 274d79c597589aeac30b39ece59fb78afda78530"
[ "-U" = "$1" ] && shift && FORCE_UPDATE=True
mkdir -p $ONOS_ROOT/bin
pushd $ONOS_ROOT/bin > /dev/null
if [ -n "$FORCE_UPDATE" ] || [ ! -f "buck" ] || [ "$REQUIRED_VERSION" != "$(cat .buck_version)" ]; then
echo "Updating Buck..."
rm -fr .buck_version 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)
[ "$SHA" != "$BUCK_SHA" ] &&
echo "ERROR: Downloaded SHA ($SHA) does not match expected SHA ($BUCK_SHA)" &&
exit 1
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 $ONOS_ROOT/buck-out
printf "Successfully updated Buck in $ONOS_ROOT/bin/buck to $BUCK_FILE\n\n"
fi
popd > /dev/null
BUCK=$ONOS_ROOT/bin/buck
# Finally, run the Buck command...
$BUCK "$@"