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 | d27d437 | 2016-10-12 15:06:21 -0700 | [diff] [blame^] | 8 | BUCK_URL="http://onlab.vicci.org/onos/third-party/buck.zip" |
| 9 | BUCK_SHA="26652b4f49849517fd19abd782bd8cd6f28e11a9" |
| 10 | REQUIRED_VERSION="buck version 7eb2adae2aa1e4d38ce2f5b9f907878687bf19cf" |
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 |
| 18 | echo "Downloading Buck..." |
Brian O'Connor | d27d437 | 2016-10-12 15:06:21 -0700 | [diff] [blame^] | 19 | rm -fr .buck_version buck buck.zip plugins |
| 20 | curl -o ./buck.zip -L $BUCK_URL |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 21 | if [ -n "$(which shasum)" ]; then |
Brian O'Connor | d27d437 | 2016-10-12 15:06:21 -0700 | [diff] [blame^] | 22 | SHA=$(shasum ./buck.zip | cut -d' ' -f1) |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 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 |
Brian O'Connor | d27d437 | 2016-10-12 15:06:21 -0700 | [diff] [blame^] | 29 | unzip buck.zip |
| 30 | rm buck.zip |
| 31 | rm -rf $ONOS_ROOT/buck-out |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 32 | printf "Successfully downloaded Buck to $ONOS_ROOT/bin/buck\n\n" |
| 33 | fi |
| 34 | popd > /dev/null |
| 35 | |
Brian O'Connor | e8468b5 | 2016-07-25 13:42:36 -0700 | [diff] [blame] | 36 | BUCK=$ONOS_ROOT/bin/buck |
Brian O'Connor | e8468b5 | 2016-07-25 13:42:36 -0700 | [diff] [blame] | 37 | |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 38 | # Finally, run the Buck command... |
Brian O'Connor | e8468b5 | 2016-07-25 13:42:36 -0700 | [diff] [blame] | 39 | $BUCK "$@" |