Thomas Vachuska | 0483bee | 2016-05-04 19:37:51 -0700 | [diff] [blame] | 1 | #!/bin/bash |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 2 | # ----------------------------------------------------------------------------- |
| 3 | # Runs the custom version of Buck required by ONOS. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | set -e |
| 7 | |
Ray Milkey | e901932 | 2017-09-01 10:19:17 -0700 | [diff] [blame] | 8 | BUCK_URL="http://onlab.vicci.org/onos/third-party/buck-v2017.09.01.01.zip" |
| 9 | BUCK_SHA="9addcfd68518ee51b8f08135a7828b38dffb8fe5" |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 10 | |
| 11 | [ "-U" = "$1" ] && shift && FORCE_UPDATE=True |
| 12 | |
Brian O'Connor | 4ed68b6 | 2016-10-27 21:08:37 -0700 | [diff] [blame] | 13 | ROOT_DIR=${ONOS_ROOT:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )/../.." && pwd )"} |
| 14 | |
| 15 | mkdir -p $ROOT_DIR/bin |
| 16 | pushd $ROOT_DIR/bin > /dev/null |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 17 | |
Brian O'Connor | 1b55bfb | 2017-03-21 15:30:38 -0700 | [diff] [blame] | 18 | if [ -n "$FORCE_UPDATE" ] || [ ! -f "buck" ] || [ "$BUCK_SHA" != "$(cat .buck_sha)" ]; then |
Thomas Vachuska | 96f2b2c | 2017-07-19 10:08:30 -0700 | [diff] [blame] | 19 | echo "Updating Buck..." >&2 |
Brian O'Connor | 1b55bfb | 2017-03-21 15:30:38 -0700 | [diff] [blame] | 20 | rm -fr .buck_version .buck_sha buck plugins |
Thomas Vachuska | ae9ba21 | 2016-10-26 15:44:05 -0700 | [diff] [blame] | 21 | mkdir -p cache |
| 22 | BUCK_FILE=$(basename $BUCK_URL) |
| 23 | # Check the local cache; download to cache if required |
| 24 | [ -f "cache/$BUCK_FILE" ] || curl -o cache/$BUCK_FILE -L $BUCK_URL |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 25 | if [ -n "$(which shasum)" ]; then |
Thomas Vachuska | ae9ba21 | 2016-10-26 15:44:05 -0700 | [diff] [blame] | 26 | SHA=$(shasum cache/$BUCK_FILE | cut -d' ' -f1) |
Brian O'Connor | 1b55bfb | 2017-03-21 15:30:38 -0700 | [diff] [blame] | 27 | if [ "$SHA" != "$BUCK_SHA" ]; then |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 28 | echo "ERROR: Downloaded SHA ($SHA) does not match expected SHA ($BUCK_SHA)" && |
Brian O'Connor | e1c02f4 | 2016-12-02 12:49:55 -0800 | [diff] [blame] | 29 | rm -f cache/$BUCK_FILE && exit 1 |
Brian O'Connor | 1b55bfb | 2017-03-21 15:30:38 -0700 | [diff] [blame] | 30 | else |
| 31 | echo "$SHA" > .buck_sha |
| 32 | fi |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 33 | else |
| 34 | echo "SHA cannot be verified" |
| 35 | fi |
Thomas Vachuska | ae9ba21 | 2016-10-26 15:44:05 -0700 | [diff] [blame] | 36 | unzip cache/$BUCK_FILE |
| 37 | # Kill buckd |
| 38 | ps -ef | egrep buckd | grep -v egrep | cut -c7-11 | xargs kill 2>/dev/null || : |
Brian O'Connor | 4ed68b6 | 2016-10-27 21:08:37 -0700 | [diff] [blame] | 39 | rm -rf $ROOT_DIR/buck-out |
| 40 | printf "Successfully updated Buck in $ROOT_DIR/bin/buck to $BUCK_FILE\n\n" |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 41 | fi |
| 42 | popd > /dev/null |
| 43 | |
Brian O'Connor | 4ed68b6 | 2016-10-27 21:08:37 -0700 | [diff] [blame] | 44 | BUCK=$ROOT_DIR/bin/buck |
Brian O'Connor | e8468b5 | 2016-07-25 13:42:36 -0700 | [diff] [blame] | 45 | |
Yuta HIGUCHI | b1fa40d | 2017-02-22 11:28:13 -0800 | [diff] [blame] | 46 | if [ "${ONOS_NO_BUCKD:-1}" == "1" ]; then |
| 47 | export NO_BUCKD=1 |
| 48 | fi |
| 49 | |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 50 | # Finally, run the Buck command... |
Yuta HIGUCHI | b1fa40d | 2017-02-22 11:28:13 -0800 | [diff] [blame] | 51 | $BUCK "$@" |