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 | |
Brian O'Connor | 2938a03 | 2016-10-20 14:19:19 -0700 | [diff] [blame] | 8 | BUCK_URL="http://onlab.vicci.org/onos/third-party/buck-v2016.10.20.01.zip" |
| 9 | BUCK_SHA="718ab518bf5edc7e92626e434551396171f3ab5a" |
| 10 | REQUIRED_VERSION="buck version 274d79c597589aeac30b39ece59fb78afda78530" |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 11 | |
| 12 | [ "-U" = "$1" ] && shift && FORCE_UPDATE=True |
| 13 | |
| 14 | mkdir -p $ONOS_ROOT/bin |
| 15 | pushd $ONOS_ROOT/bin > /dev/null |
| 16 | |
| 17 | if [ -n "$FORCE_UPDATE" ] || [ ! -f "buck" ] || [ "$REQUIRED_VERSION" != "$(cat .buck_version)" ]; then |
Thomas Vachuska | ae9ba21 | 2016-10-26 15:44:05 -0700 | [diff] [blame] | 18 | echo "Updating Buck..." |
| 19 | rm -fr .buck_version buck plugins |
| 20 | mkdir -p cache |
| 21 | BUCK_FILE=$(basename $BUCK_URL) |
| 22 | # Check the local cache; download to cache if required |
| 23 | [ -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] | 24 | if [ -n "$(which shasum)" ]; then |
Thomas Vachuska | ae9ba21 | 2016-10-26 15:44:05 -0700 | [diff] [blame] | 25 | SHA=$(shasum cache/$BUCK_FILE | cut -d' ' -f1) |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 26 | [ "$SHA" != "$BUCK_SHA" ] && |
| 27 | echo "ERROR: Downloaded SHA ($SHA) does not match expected SHA ($BUCK_SHA)" && |
| 28 | exit 1 |
| 29 | else |
| 30 | echo "SHA cannot be verified" |
| 31 | fi |
Thomas Vachuska | ae9ba21 | 2016-10-26 15:44:05 -0700 | [diff] [blame] | 32 | unzip cache/$BUCK_FILE |
| 33 | # Kill buckd |
| 34 | ps -ef | egrep buckd | grep -v egrep | cut -c7-11 | xargs kill 2>/dev/null || : |
Brian O'Connor | d27d437 | 2016-10-12 15:06:21 -0700 | [diff] [blame] | 35 | rm -rf $ONOS_ROOT/buck-out |
Thomas Vachuska | ae9ba21 | 2016-10-26 15:44:05 -0700 | [diff] [blame] | 36 | printf "Successfully updated Buck in $ONOS_ROOT/bin/buck to $BUCK_FILE\n\n" |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 37 | fi |
| 38 | popd > /dev/null |
| 39 | |
Brian O'Connor | e8468b5 | 2016-07-25 13:42:36 -0700 | [diff] [blame] | 40 | BUCK=$ONOS_ROOT/bin/buck |
Brian O'Connor | e8468b5 | 2016-07-25 13:42:36 -0700 | [diff] [blame] | 41 | |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 42 | # Finally, run the Buck command... |
Brian O'Connor | e8468b5 | 2016-07-25 13:42:36 -0700 | [diff] [blame] | 43 | $BUCK "$@" |