Brian O'Connor
Committed by Gerrit Code Review

Adding buck publish scripts

Change-Id: I7d3cbe55a9d958d2bb2cc2fb71a3293825c1bf33
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
2 includes = //buck-tools/default.defs 2 includes = //buck-tools/default.defs
3 3
4 [plugins] 4 [plugins]
5 - directory = //bucklets/plugins 5 + directory = //bin/plugins
6 6
7 [java] 7 [java]
8 source_level = 8 8 source_level = 8
......
1 +#!/bin/bash
2 +
3 +BUCK_LOCAL_CONFIG=${BUCK_LOCAL_CONFIG:-$ONOS_ROOT/.buckconfig.local}
4 +MVN_REPO="https://oss.sonatype.org/content/repositories/snapshots"
5 +NO_BUCKD=1
6 +
7 +set -e
8 +set -x
9 +
10 +#FIXME if pwd != buck
11 +pushd buck
12 +
13 +# build buck
14 +scripts/create_tag.sh
15 +buck build buck --show-output
16 +
17 +# publish cli:main-fixed as buck-api
18 +cp $BUCK_LOCAL_CONFIG .
19 +buck publish //src/com/facebook/buck/cli:main-fixed \
20 + --remote-repo=https://oss.sonatype.org/content/repositories/snapshots/ \
21 + | tee ../api-publish.txt
22 +
23 +# Alternatively, we can deploy org.onosproject:buck-api with the following:
24 +#mvn deploy:deploy-file -DgroupId=org.onosproject -DartifactId=buck-api \
25 +# -Dversion=0.1-SNAPSHOT -DgeneratePom=true -Dpackaging=jar \
26 +# -DrepositoryId=snapshot -Durl=https://oss.sonatype.org/content/repositories/snapshots/ \
27 +# -Dfile=buck-out/gen/src/com/facebook/buck/cli/main-fixed/main-fixed.jar
28 +
29 +#FIXME upload API to S3 for backup
30 +
31 +popd #buck
32 +
33 +SNAPSHOT_VERSION=$(cat api-publish.txt | grep "^org.onosproject:buck-api:jar" \
34 + | cut -d' ' -f1 | cut -d: -f4)
35 +BUCK_API_URL="$MVN_REPO/org/onosproject/buck-api/0.1-SNAPSHOT/buck-api-$SNAPSHOT_VERSION.jar"
36 +echo $BUCK_API_URL
37 +
38 +BUCK_API_SHA=$(shasum buck-out/gen/src/com/facebook/buck/cli/main-fixed/main-fixed.jar | cut -d' ' -f1)
39 +echo $BUCK_API_SHA
40 +
41 +pushd onos
42 +sed -i "" -E "s#url =.*#url = '$BUCK_API_URL',#" tools/build/buck-plugin/BUCK
43 +sed -i "" -E "s#sha1 =.*#sha1 = '$BUCK_API_SHA',#" tools/build/buck-plugin/BUCK
44 +popd #onos
45 +
46 +#pushd onos-yang-tools
47 +#FIXME update version (assume 0.1-SNAPSHOT for now)
48 +#popd #onos-yang-tools
49 +
50 +set +x
51 +
52 +echo
53 +echo "Please build and verify the ONOS Buck plugin and the Yang tools plugin:"
54 +echo " cd onos; buck build //tools/build/buck-plugin:onosjar"
55 +echo " cd onos-yang-tools; mvn clean package"
56 +echo "You should commit and push any required changes."
...\ No newline at end of file ...\ No newline at end of file
1 +#!/bin/bash
2 +
3 +DEFAULT_TAG=${TAG:-$(date +v%Y.%m.%d.01)}
4 +NO_BUCKD=1
5 +
6 +DOWNLOAD_BASE="http://onlab.vicci.org/onos/third-party"
7 +BUCK_ZIP="buck-$DEFAULT_TAG.zip"
8 +ZIP_STAGE="buck-bin"
9 +
10 +rm -rf $ZIP_STAGE
11 +
12 +set -e
13 +set -x
14 +
15 +# build plugins
16 +
17 +pushd onos
18 +buck build //tools/build/buck-plugin:onosjar
19 +popd #onos
20 +
21 +pushd onos-yang-tools
22 +mvn clean package
23 +popd #onos-yang-tools
24 +
25 +# assemble zip
26 +
27 +mkdir -p buck-bin/plugins
28 +
29 +cp buck/buck-out/gen/programs/buck.pex $ZIP_STAGE/buck
30 +cp onos/buck-out/gen/tools/build/buck-plugin/onosjar.jar $ZIP_STAGE/plugins/onos.jar
31 +cp onos-yang-tools/plugin/buck/target/onos-yang-buck-plugin-1.9-SNAPSHOT.jar $ZIP_STAGE/plugins/yang.jar
32 +
33 +BUCK_VERSION=$(buck/buck-out/gen/programs/buck.pex -V)
34 +echo $BUCK_VERSION > $ZIP_STAGE/.buck_version
35 +
36 +chmod 555 $ZIP_STAGE/buck
37 +chmod 444 $ZIP_STAGE/.buck_version
38 +
39 +pushd $ZIP_STAGE
40 +zip -r ../$BUCK_ZIP buck .buck_version plugins
41 +popd #$ZIP_STAGE
42 +
43 +# publish zip
44 +#FIXME check for s3 credentials
45 +uploadToS3.py --dest third-party/ $BUCK_ZIP
46 +
47 +# update version in onos-buck
48 +URL="$DOWNLOAD_BASE/$BUCK_ZIP"
49 +SHA=$(shasum $BUCK_ZIP | cut -d' ' -f1)
50 +
51 +sed -i "" -E "s#BUCK_URL=.*#BUCK_URL=\"$URL\"#" onos/tools/build/onos-buck
52 +sed -i "" -E "s#BUCK_SHA=.*#BUCK_SHA=\"$SHA\"#" onos/tools/build/onos-buck
53 +sed -i "" -E "s#REQUIRED_VERSION=.*#REQUIRED_VERSION=\"$BUCK_VERSION\"#" onos/tools/build/onos-buck
54 +
55 +set +x
56 +echo
57 +echo "Commit and push change to onos-buck on the onos directory."
...\ No newline at end of file ...\ No newline at end of file
1 +#!/bin/bash
2 +
3 +BUCK_REF="10-11-2016"
4 +ONOS_REF="master"
5 +YANG_REF="master"
6 +
7 +set -x
8 +
9 +# change to tmpdir
10 +DIR=$(mktemp -d /tmp/buck-publish.XXXXX) || { echo "Failed to create temp file"; exit 1; }
11 +cd $DIR
12 +
13 +# checkout buck
14 +git clone -b $BUCK_REF https://github.com/bocon13/buck
15 +
16 +# checkout plugins
17 +git clone -b $ONOS_REF https://gerrit.onosproject.org/onos.git
18 +git clone -b $YANG_REF https://gerrit.onosproject.org/onos-yang-tools.git
19 +
20 +set +x
21 +
22 +echo
23 +echo "Buck publish area:"
24 +echo " cd $DIR"
...@@ -5,9 +5,9 @@ ...@@ -5,9 +5,9 @@
5 5
6 set -e 6 set -e
7 7
8 -BUCK_URL="https://github.com/bocon13/buck/releases/download/v2016.09.13.01/buck" 8 +BUCK_URL="http://onlab.vicci.org/onos/third-party/buck.zip"
9 -BUCK_SHA="e72cf2e9ef719fa81fd4e0d1b620f20448c10a9d" 9 +BUCK_SHA="26652b4f49849517fd19abd782bd8cd6f28e11a9"
10 -REQUIRED_VERSION="buck version 0b60c3d7f8d54b2e6e6607749b748c0f240a6eb3" 10 +REQUIRED_VERSION="buck version 7eb2adae2aa1e4d38ce2f5b9f907878687bf19cf"
11 11
12 [ "-U" = "$1" ] && shift && FORCE_UPDATE=True 12 [ "-U" = "$1" ] && shift && FORCE_UPDATE=True
13 13
...@@ -16,48 +16,24 @@ pushd $ONOS_ROOT/bin > /dev/null ...@@ -16,48 +16,24 @@ pushd $ONOS_ROOT/bin > /dev/null
16 16
17 if [ -n "$FORCE_UPDATE" ] || [ ! -f "buck" ] || [ "$REQUIRED_VERSION" != "$(cat .buck_version)" ]; then 17 if [ -n "$FORCE_UPDATE" ] || [ ! -f "buck" ] || [ "$REQUIRED_VERSION" != "$(cat .buck_version)" ]; then
18 echo "Downloading Buck..." 18 echo "Downloading Buck..."
19 - rm -f .buck_version buck 19 + rm -fr .buck_version buck buck.zip plugins
20 - curl -o ./buck -L $BUCK_URL 20 + curl -o ./buck.zip -L $BUCK_URL
21 if [ -n "$(which shasum)" ]; then 21 if [ -n "$(which shasum)" ]; then
22 - SHA=$(shasum ./buck | cut -d' ' -f1) 22 + SHA=$(shasum ./buck.zip | cut -d' ' -f1)
23 [ "$SHA" != "$BUCK_SHA" ] && 23 [ "$SHA" != "$BUCK_SHA" ] &&
24 echo "ERROR: Downloaded SHA ($SHA) does not match expected SHA ($BUCK_SHA)" && 24 echo "ERROR: Downloaded SHA ($SHA) does not match expected SHA ($BUCK_SHA)" &&
25 exit 1 25 exit 1
26 else 26 else
27 echo "SHA cannot be verified" 27 echo "SHA cannot be verified"
28 fi 28 fi
29 - chmod 555 ./buck 29 + unzip buck.zip
30 - echo $(./buck --version 2>/dev/null) > .buck_version 30 + rm buck.zip
31 - chmod 444 .buck_version 31 + rm -rf $ONOS_ROOT/buck-out
32 - rm -rf ./buck-out
33 printf "Successfully downloaded Buck to $ONOS_ROOT/bin/buck\n\n" 32 printf "Successfully downloaded Buck to $ONOS_ROOT/bin/buck\n\n"
34 - ONOS_BUILD_PLUGIN="true"
35 fi 33 fi
36 popd > /dev/null 34 popd > /dev/null
37 35
38 BUCK=$ONOS_ROOT/bin/buck 36 BUCK=$ONOS_ROOT/bin/buck
39 -PLUGINS=$ONOS_ROOT/bucklets/plugins
40 -ONOS_PLUGIN=$PLUGINS/onosjar.jar
41 -
42 -if [ ! -f "$ONOS_PLUGIN" -o -n "$ONOS_BUILD_PLUGIN" ]; then
43 - echo "Building ONOS Buck plugins..."
44 -
45 - # Build it first
46 - pluginJar=$(NO_BUCKD=1 $BUCK build //tools/build/buck-plugin:onosjar --show-output 2>/dev/null | grep onosjar.jar | cut -d\ -f2)
47 -
48 - CHK_NEW=$(cksum $ONOS_ROOT/$pluginJar | cut -d' ' -f1-2)
49 - CHK_OLD=$(cksum $ONOS_PLUGIN 2>/dev/null | cut -d' ' -f1-2)
50 - if [ "$CHK_NEW" != "$CHK_OLD" ]; then
51 - # diff plugins... if different, copy and restart buckd
52 - # Then install it
53 - mkdir -p $PLUGINS
54 - cp $ONOS_ROOT/$pluginJar $PLUGINS
55 - echo "Updated to the latest plugin."
56 - $BUCK clean 2>/dev/null
57 - else
58 - echo "Plugin was already up to date."
59 - fi
60 -fi
61 37
62 # Finally, run the Buck command... 38 # Finally, run the Buck command...
63 $BUCK "$@" 39 $BUCK "$@"
......