blob: c07b2646a971a7ebce525929d7f747ba44d52127 [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'Connor33c1fb72016-10-12 15:35:07 -07008BUCK_URL="http://onlab.vicci.org/onos/third-party/buck-v2016.10.12.01.zip"
9BUCK_SHA="d2e0dafa4f4434c76cea2ceb036847596385e218"
10REQUIRED_VERSION="buck version e99a5d2eb229ec9aafc9df073a85e51087e4d1dc"
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
18 echo "Downloading Buck..."
Brian O'Connord27d4372016-10-12 15:06:21 -070019 rm -fr .buck_version buck buck.zip plugins
20 curl -o ./buck.zip -L $BUCK_URL
Brian O'Connor9be23632016-04-08 18:23:45 -070021 if [ -n "$(which shasum)" ]; then
Brian O'Connord27d4372016-10-12 15:06:21 -070022 SHA=$(shasum ./buck.zip | cut -d' ' -f1)
Brian O'Connor9be23632016-04-08 18:23:45 -070023 [ "$SHA" != "$BUCK_SHA" ] &&
24 echo "ERROR: Downloaded SHA ($SHA) does not match expected SHA ($BUCK_SHA)" &&
25 exit 1
26 else
27 echo "SHA cannot be verified"
28 fi
Brian O'Connord27d4372016-10-12 15:06:21 -070029 unzip buck.zip
30 rm buck.zip
31 rm -rf $ONOS_ROOT/buck-out
Brian O'Connor9be23632016-04-08 18:23:45 -070032 printf "Successfully downloaded Buck to $ONOS_ROOT/bin/buck\n\n"
33fi
34popd > /dev/null
35
Brian O'Connore8468b52016-07-25 13:42:36 -070036BUCK=$ONOS_ROOT/bin/buck
Brian O'Connore8468b52016-07-25 13:42:36 -070037
Brian O'Connor9be23632016-04-08 18:23:45 -070038# Finally, run the Buck command...
Brian O'Connore8468b52016-07-25 13:42:36 -070039$BUCK "$@"