blob: 75e441a4a134805a3974c4ec284c6f9020c13068 [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
Brian O'Connor4ed68b62016-10-27 21:08:37 -070014ROOT_DIR=${ONOS_ROOT:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"}
15
16mkdir -p $ROOT_DIR/bin
17pushd $ROOT_DIR/bin > /dev/null
Brian O'Connor9be23632016-04-08 18:23:45 -070018
19if [ -n "$FORCE_UPDATE" ] || [ ! -f "buck" ] || [ "$REQUIRED_VERSION" != "$(cat .buck_version)" ]; then
Thomas Vachuskaae9ba212016-10-26 15:44:05 -070020 echo "Updating Buck..."
21 rm -fr .buck_version buck plugins
22 mkdir -p cache
23 BUCK_FILE=$(basename $BUCK_URL)
24 # Check the local cache; download to cache if required
25 [ -f "cache/$BUCK_FILE" ] || curl -o cache/$BUCK_FILE -L $BUCK_URL
Brian O'Connor9be23632016-04-08 18:23:45 -070026 if [ -n "$(which shasum)" ]; then
Thomas Vachuskaae9ba212016-10-26 15:44:05 -070027 SHA=$(shasum cache/$BUCK_FILE | cut -d' ' -f1)
Brian O'Connor9be23632016-04-08 18:23:45 -070028 [ "$SHA" != "$BUCK_SHA" ] &&
29 echo "ERROR: Downloaded SHA ($SHA) does not match expected SHA ($BUCK_SHA)" &&
30 exit 1
31 else
32 echo "SHA cannot be verified"
33 fi
Thomas Vachuskaae9ba212016-10-26 15:44:05 -070034 unzip cache/$BUCK_FILE
35 # Kill buckd
36 ps -ef | egrep buckd | grep -v egrep | cut -c7-11 | xargs kill 2>/dev/null || :
Brian O'Connor4ed68b62016-10-27 21:08:37 -070037 rm -rf $ROOT_DIR/buck-out
38 printf "Successfully updated Buck in $ROOT_DIR/bin/buck to $BUCK_FILE\n\n"
Brian O'Connor9be23632016-04-08 18:23:45 -070039fi
40popd > /dev/null
41
Brian O'Connor4ed68b62016-10-27 21:08:37 -070042BUCK=$ROOT_DIR/bin/buck
Brian O'Connore8468b52016-07-25 13:42:36 -070043
Brian O'Connor9be23632016-04-08 18:23:45 -070044# Finally, run the Buck command...
Brian O'Connore8468b52016-07-25 13:42:36 -070045$BUCK "$@"