blob: 91f0d070a22aceae3a8a06de9b606b5f03c8c5c8 [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
8BUCK_URL="https://github.com/bocon13/buck/releases/download/v2016.04.08.01/buck"
9BUCK_SHA="e22b6accd43cd3e928fe8e63256ebdc8f0b24cab"
10REQUIRED_VERSION="buck version ad0295088e5da2782062636ed97bd4f71c65bddd"
11
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..."
19 rm -f .buck_version buck
20 curl -o ./buck -L $BUCK_URL
21 if [ -n "$(which shasum)" ]; then
22 SHA=$(shasum ./buck | cut -d' ' -f1)
23 [ "$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
29 chmod 555 ./buck
Brian O'Connor2fdbe0d12016-04-08 19:14:04 -070030 echo $(./buck --version 2>/dev/null) > .buck_version
Brian O'Connor9be23632016-04-08 18:23:45 -070031 chmod 444 .buck_version
Brian O'Connor2fdbe0d12016-04-08 19:14:04 -070032 rm -rf ./buck-out
Brian O'Connor9be23632016-04-08 18:23:45 -070033 printf "Successfully downloaded Buck to $ONOS_ROOT/bin/buck\n\n"
34fi
35popd > /dev/null
36
37# Finally, run the Buck command...
Thomas Vachuska673c3e02016-05-04 16:24:32 -070038$ONOS_ROOT/bin/buck "$@"