blob: 1a5fd3e080827addad7aff6e83d629bc6f40c581 [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'Connor920f7c22016-11-12 18:07:33 -08008BUCK_URL="http://onlab.vicci.org/onos/third-party/buck-v2016.11.12.01.zip"
9BUCK_SHA="c7472ed3046b6126d3eab2d06cccae2f488e3d85"
10REQUIRED_VERSION="buck version 50b259823655bd5f5f4be7a1e15fb22b4a2e62d5"
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...
Thomas Vachuskacedacd42016-12-02 12:21:58 -080045NO_BUCKD=1 $BUCK "$@"