blob: 8bf5a13f14f3ad8f6f2f8199cd261a259699b680 [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
Gaurav Agrawalb1d839f2017-03-15 17:18:46 +05308BUCK_URL="http://onlab.vicci.org/onos/third-party/buck-v2017.03.10.01.zip"
9BUCK_SHA="baa7bae077ef0e65b371525fd525a5763fef41c4"
Brian O'Connorbee19492016-12-02 13:03:45 -080010REQUIRED_VERSION="buck version c4e714c9c0c774cbb674c2fde0a4419824f0cfdb"
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
Brian O'Connor1b55bfb2017-03-21 15:30:38 -070019if [ -n "$FORCE_UPDATE" ] || [ ! -f "buck" ] || [ "$BUCK_SHA" != "$(cat .buck_sha)" ]; then
Thomas Vachuskaae9ba212016-10-26 15:44:05 -070020 echo "Updating Buck..."
Brian O'Connor1b55bfb2017-03-21 15:30:38 -070021 rm -fr .buck_version .buck_sha buck plugins
Thomas Vachuskaae9ba212016-10-26 15:44:05 -070022 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'Connor1b55bfb2017-03-21 15:30:38 -070028 if [ "$SHA" != "$BUCK_SHA" ]; then
Brian O'Connor9be23632016-04-08 18:23:45 -070029 echo "ERROR: Downloaded SHA ($SHA) does not match expected SHA ($BUCK_SHA)" &&
Brian O'Connore1c02f42016-12-02 12:49:55 -080030 rm -f cache/$BUCK_FILE && exit 1
Brian O'Connor1b55bfb2017-03-21 15:30:38 -070031 else
32 echo "$SHA" > .buck_sha
33 fi
Brian O'Connor9be23632016-04-08 18:23:45 -070034 else
35 echo "SHA cannot be verified"
36 fi
Thomas Vachuskaae9ba212016-10-26 15:44:05 -070037 unzip cache/$BUCK_FILE
38 # Kill buckd
39 ps -ef | egrep buckd | grep -v egrep | cut -c7-11 | xargs kill 2>/dev/null || :
Brian O'Connor4ed68b62016-10-27 21:08:37 -070040 rm -rf $ROOT_DIR/buck-out
41 printf "Successfully updated Buck in $ROOT_DIR/bin/buck to $BUCK_FILE\n\n"
Brian O'Connor9be23632016-04-08 18:23:45 -070042fi
43popd > /dev/null
44
Brian O'Connor4ed68b62016-10-27 21:08:37 -070045BUCK=$ROOT_DIR/bin/buck
Brian O'Connore8468b52016-07-25 13:42:36 -070046
Yuta HIGUCHIb1fa40d2017-02-22 11:28:13 -080047if [ "${ONOS_NO_BUCKD:-1}" == "1" ]; then
48 export NO_BUCKD=1
49fi
50
Brian O'Connor9be23632016-04-08 18:23:45 -070051# Finally, run the Buck command...
Yuta HIGUCHIb1fa40d2017-02-22 11:28:13 -080052$BUCK "$@"