Add a meta-script to build a new buck release

Change-Id: I68673f9afc52fdf033ba2c71ebacfd071404693a
diff --git a/tools/build/buck-publish b/tools/build/buck-publish
new file mode 100755
index 0000000..8d9d84d
--- /dev/null
+++ b/tools/build/buck-publish
@@ -0,0 +1,31 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# Build and publish the ONOS version of buck.
+# -----------------------------------------------------------------------------
+
+if [ $# -ne 3  -a $# -ne 4 ]; then
+    echo "Usage: buck-publish-setup buck-branch onos-branch yang-branch [version] [--dry-run]"
+    echo "For example, to build buck branch 11-11-2016, onos branch master, and onos-yang-tools master:"
+    echo "buck-publish 11-11-2016 master master"
+    exit 1
+fi
+
+if [ $# -eq 4 -a "${4}" != "--dry-run" ]; then
+    echo "$4 is an invalid parameter - only --dry-run allowed"
+    exit 1
+fi
+
+BUCK_BRANCH="$1"
+ONOS_BRANCH="$2"
+YANG_BRANCH="$3"
+
+if [ -z "$4" ]; then
+    onos-release-prerequisites
+fi
+
+DIR=$(mktemp -d /tmp/buck-publish.XXXXX) || { echo "Failed to create temp file"; exit 1; }
+
+buck-publish-setup $BUCK_BRANCH $ONOS_BRANCH $YANG_BRANCH $DIR
+pushd $DIR && buck-publish-package $4 && popd
+
+
diff --git a/tools/build/buck-publish-package b/tools/build/buck-publish-package
index 61a10fd..fe32d8f 100755
--- a/tools/build/buck-publish-package
+++ b/tools/build/buck-publish-package
@@ -44,9 +44,11 @@
 zip -r ../$BUCK_ZIP buck .buck_version plugins
 popd #$ZIP_STAGE
 
-# publish zip
-#FIXME check for s3 credentials
-uploadToS3.py --dest third-party/ $BUCK_ZIP
+if [ "$1" -ne "--dry-run" ]; then
+    # publish zip
+    #FIXME check for s3 credentials
+    uploadToS3.py --dest third-party/ $BUCK_ZIP
+fi
 
 # update version in onos-buck
 URL="$DOWNLOAD_BASE/$BUCK_ZIP"
diff --git a/tools/build/buck-publish-setup b/tools/build/buck-publish-setup
index b56575f..d180479 100755
--- a/tools/build/buck-publish-setup
+++ b/tools/build/buck-publish-setup
@@ -1,13 +1,16 @@
 #!/bin/bash
 
-BUCK_REF="11-11-2016"
-ONOS_REF="master"
-YANG_REF="master"
+BUCK_REF=${1:-"11-11-2016"}
+ONOS_REF=${2:-"master"}
+YANG_REF=${3:-"master"}
+DIR=$4
 
 set -x
 
+if [ -z "$4" ]; then
+    DIR=$(mktemp -d /tmp/buck-publish.XXXXX) || { echo "Failed to create temp file"; exit 1; }
+fi
 # change to tmpdir
-DIR=$(mktemp -d /tmp/buck-publish.XXXXX) || { echo "Failed to create temp file"; exit 1; }
 cd $DIR
 
 # checkout buck
@@ -22,3 +25,4 @@
 echo
 echo "Buck publish area:"
 echo "  cd $DIR"
+