| #!/bin/bash |
| # ----------------------------------------------------------------------------- |
| # Runs the custom version of Buck required by ONOS. |
| # ----------------------------------------------------------------------------- |
| |
| set -e |
| |
| BUCK_URL="https://github.com/bocon13/buck/releases/download/v2016.07.29.01-wip/buck" |
| BUCK_SHA="31b2925f0c7935cd581b11a52f4e7fc53ade125e" |
| REQUIRED_VERSION="buck version b1271d04f2c319784f8af9abc92ed2d01d10ed3a" |
| |
| [ "-U" = "$1" ] && shift && FORCE_UPDATE=True |
| |
| mkdir -p $ONOS_ROOT/bin |
| pushd $ONOS_ROOT/bin > /dev/null |
| |
| if [ -n "$FORCE_UPDATE" ] || [ ! -f "buck" ] || [ "$REQUIRED_VERSION" != "$(cat .buck_version)" ]; then |
| echo "Downloading Buck..." |
| rm -f .buck_version buck |
| curl -o ./buck -L $BUCK_URL |
| if [ -n "$(which shasum)" ]; then |
| SHA=$(shasum ./buck | cut -d' ' -f1) |
| [ "$SHA" != "$BUCK_SHA" ] && |
| echo "ERROR: Downloaded SHA ($SHA) does not match expected SHA ($BUCK_SHA)" && |
| exit 1 |
| else |
| echo "SHA cannot be verified" |
| fi |
| chmod 555 ./buck |
| echo $(./buck --version 2>/dev/null) > .buck_version |
| chmod 444 .buck_version |
| rm -rf ./buck-out |
| printf "Successfully downloaded Buck to $ONOS_ROOT/bin/buck\n\n" |
| fi |
| popd > /dev/null |
| |
| BUCK=$ONOS_ROOT/bin/buck |
| PLUGINS=$ONOS_ROOT/bucklets/plugins |
| ONOS_PLUGIN=$PLUGINS/onosjar.jar |
| |
| if [ ! -f "$ONOS_PLUGIN" -o -n "$ONOS_BUILD_PLUGIN" ]; then |
| echo "Building ONOS Buck plugins..." |
| |
| # Build it first |
| pluginJar=$(NO_BUCKD=1 $BUCK build //tools/build/buck-plugin:onosjar --show-output 2>/dev/null | grep onosjar.jar | cut -d\ -f2) |
| |
| CHK_NEW=$(cksum $pluginJar | cut -d' ' -f1-2) |
| CHK_OLD=$(cksum $ONOS_PLUGIN 2>/dev/null | cut -d' ' -f1-2) |
| if [ "$CHK_NEW" != "$CHK_OLD" ]; then |
| # diff plugins... if different, copy and restart buckd |
| # Then install it |
| mkdir -p $PLUGINS |
| cp $ONOS_ROOT/$pluginJar $PLUGINS |
| echo "Updated to the latest plugin." |
| $BUCK clean 2>/dev/null |
| else |
| echo "Plugin was already up to date." |
| fi |
| fi |
| |
| # Finally, run the Buck command... |
| $BUCK "$@" |