Updating scripts for release
Change-Id: I5c3cfb60d10de03e3f60643bb6d655869ccc8562
diff --git a/tools/build/onos-edit-config b/tools/build/onos-edit-config
index 554ad35..9bc99fd 100755
--- a/tools/build/onos-edit-config
+++ b/tools/build/onos-edit-config
@@ -1,4 +1,9 @@
#!/bin/bash
+# ----------------------------------------------------
+# Used to update the project's refs/meta/config
+# ----------------------------------------------------
+
+set -e
GERRIT_USER=${GERRIT_USER:-$USER}
GERRIT_PROJECT=${GERRIT_PROJECT:-onos}
diff --git a/tools/build/onos-prepare-release b/tools/build/onos-prepare-release
new file mode 100755
index 0000000..658151d
--- /dev/null
+++ b/tools/build/onos-prepare-release
@@ -0,0 +1,33 @@
+#!/bin/bash
+# --------------------------------------------------------
+# Creates a tempdir for release and checks out the code
+# --------------------------------------------------------
+
+set -e
+
+GERRIT_USER=${GERRIT_USER:-$USER}
+BRANCH=${2:-master}
+
+export ONOS_VERSION=${1:-$ONOS_VERSION}
+if [ -z "$ONOS_VERSION" ]; then
+ echo "USAGE: onos-prepare-release <version number>"
+ echo " Alternatively, ONOS_VERSION must be set"
+ exit -1
+fi
+
+DIR=$(mktemp -d /tmp/onos-release.XXXXX) &&
+ echo "Created tempdir for release: $DIR" ||
+ { echo "Failed to create temp file"; exit 1; }
+
+cd $DIR
+git init
+git remote add origin ssh://$GERRIT_USER@gerrit.onosproject.org:29418/onos.git
+git fetch origin
+git checkout $BRANCH
+
+# Check existance of version
+git tag -l | grep -q $ONOS_VERSION && { echo "ERROR: Version already exists"; exit -1; }
+
+export ONOS_ROOT=$DIR
+exec bash -i
+
diff --git a/tools/build/onos-release b/tools/build/onos-release
index 3bc4f4d..48676cc 100755
--- a/tools/build/onos-release
+++ b/tools/build/onos-release
@@ -8,7 +8,7 @@
set -e
-export NEW_VERSION=$1
+export NEW_VERSION=${1:-$ONOS_VERSION}
[ -z "$NEW_VERSION" ] && echo "New ONOS version not specified" && exit 1
export NEW_VERSION_SHORT=${NEW_VERSION%-SNAPSHOT}