blob: 3ca93269b661e98a645b4fe01194ca0e3e1a1bf5 [file] [log] [blame]
Brian O'Connord730b222016-03-01 18:32:38 -08001#!/bin/bash
2# --------------------------------------------------------
3# Creates a tempdir for release and checks out the code
4# --------------------------------------------------------
5
Ray Milkeyf77ea412018-08-10 17:37:28 -07006set -eu -o pipefail
Brian O'Connord730b222016-03-01 18:32:38 -08007
8GERRIT_USER=${GERRIT_USER:-$USER}
9BRANCH=${2:-master}
Ray Milkey3ac00792016-12-01 14:28:15 -080010COMMAND=${3:--i}
Brian O'Connord730b222016-03-01 18:32:38 -080011
12export ONOS_VERSION=${1:-$ONOS_VERSION}
13if [ -z "$ONOS_VERSION" ]; then
14 echo "USAGE: onos-prepare-release <version number>"
15 echo " Alternatively, ONOS_VERSION must be set"
16 exit -1
17fi
18
19DIR=$(mktemp -d /tmp/onos-release.XXXXX) &&
20 echo "Created tempdir for release: $DIR" ||
21 { echo "Failed to create temp file"; exit 1; }
22
23cd $DIR
24git init
25git remote add origin ssh://$GERRIT_USER@gerrit.onosproject.org:29418/onos.git
26git fetch origin
27git checkout $BRANCH
28
29# Check existance of version
Brian O'Connora3178722016-03-10 15:44:27 -080030git tag -l | grep -q "$ONOS_VERSION\$" &&
31 { echo "ERROR: Version already exists"; exit -1; }
Brian O'Connord730b222016-03-01 18:32:38 -080032
33export ONOS_ROOT=$DIR
Ray Milkey8a0c7c72017-07-18 11:37:04 -070034# This is a hack to remove symlinks from the ONOS_ROOT path. To be removed when
35# the protobuf buck rules can handle symlinks
36ONOS_ROOT=$(pushd $ONOS_ROOT >/dev/null && pwd -P && popd >/dev/null)
Brian O'Connorc5996b22016-03-01 18:55:05 -080037. $ONOS_ROOT/tools/build/envDefaults
Ray Milkeyf77ea412018-08-10 17:37:28 -070038
39# cause any accidental invocation of buck to fail
40ln -s /tmp/no/such/directory $DIR/buck-out
41
Ray Milkey3ac00792016-12-01 14:28:15 -080042exec bash $COMMAND
Brian O'Connord730b222016-03-01 18:32:38 -080043
Ray Milkey4867af22018-08-10 16:52:28 -070044# TODO on exit, print "leaving directory"