blob: 19dc908381d0f0b49bfc670717a225b83561bba7 [file] [log] [blame]
Thomas Vachuska0483bee2016-05-04 19:37:51 -07001#!/bin/bash
Brian O'Connor9be23632016-04-08 18:23:45 -07002# -----------------------------------------------------------------------------
3# Runs the custom version of Buck required by ONOS.
4# -----------------------------------------------------------------------------
5
6set -e
7
Brian O'Connor2938a032016-10-20 14:19:19 -07008BUCK_URL="http://onlab.vicci.org/onos/third-party/buck-v2016.10.20.01.zip"
9BUCK_SHA="718ab518bf5edc7e92626e434551396171f3ab5a"
10REQUIRED_VERSION="buck version 274d79c597589aeac30b39ece59fb78afda78530"
Brian O'Connor9be23632016-04-08 18:23:45 -070011
12[ "-U" = "$1" ] && shift && FORCE_UPDATE=True
13
14mkdir -p $ONOS_ROOT/bin
15pushd $ONOS_ROOT/bin > /dev/null
16
17if [ -n "$FORCE_UPDATE" ] || [ ! -f "buck" ] || [ "$REQUIRED_VERSION" != "$(cat .buck_version)" ]; then
Thomas Vachuskaae9ba212016-10-26 15:44:05 -070018 echo "Updating Buck..."
19 rm -fr .buck_version buck plugins
20 mkdir -p cache
21 BUCK_FILE=$(basename $BUCK_URL)
22 # Check the local cache; download to cache if required
23 [ -f "cache/$BUCK_FILE" ] || curl -o cache/$BUCK_FILE -L $BUCK_URL
Brian O'Connor9be23632016-04-08 18:23:45 -070024 if [ -n "$(which shasum)" ]; then
Thomas Vachuskaae9ba212016-10-26 15:44:05 -070025 SHA=$(shasum cache/$BUCK_FILE | cut -d' ' -f1)
Brian O'Connor9be23632016-04-08 18:23:45 -070026 [ "$SHA" != "$BUCK_SHA" ] &&
27 echo "ERROR: Downloaded SHA ($SHA) does not match expected SHA ($BUCK_SHA)" &&
28 exit 1
29 else
30 echo "SHA cannot be verified"
31 fi
Thomas Vachuskaae9ba212016-10-26 15:44:05 -070032 unzip cache/$BUCK_FILE
33 # Kill buckd
34 ps -ef | egrep buckd | grep -v egrep | cut -c7-11 | xargs kill 2>/dev/null || :
Brian O'Connord27d4372016-10-12 15:06:21 -070035 rm -rf $ONOS_ROOT/buck-out
Thomas Vachuskaae9ba212016-10-26 15:44:05 -070036 printf "Successfully updated Buck in $ONOS_ROOT/bin/buck to $BUCK_FILE\n\n"
Brian O'Connor9be23632016-04-08 18:23:45 -070037fi
38popd > /dev/null
39
Brian O'Connore8468b52016-07-25 13:42:36 -070040BUCK=$ONOS_ROOT/bin/buck
Brian O'Connore8468b52016-07-25 13:42:36 -070041
Brian O'Connor9be23632016-04-08 18:23:45 -070042# Finally, run the Buck command...
Brian O'Connore8468b52016-07-25 13:42:36 -070043$BUCK "$@"