Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 1 | #/bin/bash |
| 2 | # ----------------------------------------------------------------------------- |
| 3 | # Runs the custom version of Buck required by ONOS. |
| 4 | # ----------------------------------------------------------------------------- |
| 5 | |
| 6 | set -e |
| 7 | |
| 8 | BUCK_URL="https://github.com/bocon13/buck/releases/download/v2016.04.08.01/buck" |
| 9 | BUCK_SHA="e22b6accd43cd3e928fe8e63256ebdc8f0b24cab" |
| 10 | REQUIRED_VERSION="buck version ad0295088e5da2782062636ed97bd4f71c65bddd" |
| 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..." |
| 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'Connor | 2fdbe0d1 | 2016-04-08 19:14:04 -0700 | [diff] [blame] | 30 | echo $(./buck --version 2>/dev/null) > .buck_version |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 31 | chmod 444 .buck_version |
Brian O'Connor | 2fdbe0d1 | 2016-04-08 19:14:04 -0700 | [diff] [blame] | 32 | rm -rf ./buck-out |
Brian O'Connor | 9be2363 | 2016-04-08 18:23:45 -0700 | [diff] [blame] | 33 | printf "Successfully downloaded Buck to $ONOS_ROOT/bin/buck\n\n" |
| 34 | fi |
| 35 | popd > /dev/null |
| 36 | |
| 37 | # Finally, run the Buck command... |
Thomas Vachuska | 673c3e0 | 2016-05-04 16:24:32 -0700 | [diff] [blame] | 38 | $ONOS_ROOT/bin/buck "$@" |