blob: 40888697ceab7d7d0a9481d4059be19cdb4669ce [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
6set -e
Ray Milkey3ac00792016-12-01 14:28:15 -08007set -x
Brian O'Connord730b222016-03-01 18:32:38 -08008
9GERRIT_USER=${GERRIT_USER:-$USER}
10BRANCH=${2:-master}
Ray Milkey3ac00792016-12-01 14:28:15 -080011COMMAND=${3:--i}
Brian O'Connord730b222016-03-01 18:32:38 -080012
13export ONOS_VERSION=${1:-$ONOS_VERSION}
14if [ -z "$ONOS_VERSION" ]; then
15 echo "USAGE: onos-prepare-release <version number>"
16 echo " Alternatively, ONOS_VERSION must be set"
17 exit -1
18fi
19
20DIR=$(mktemp -d /tmp/onos-release.XXXXX) &&
21 echo "Created tempdir for release: $DIR" ||
22 { echo "Failed to create temp file"; exit 1; }
23
24cd $DIR
25git init
26git remote add origin ssh://$GERRIT_USER@gerrit.onosproject.org:29418/onos.git
27git fetch origin
28git checkout $BRANCH
29
30# Check existance of version
Brian O'Connora3178722016-03-10 15:44:27 -080031git tag -l | grep -q "$ONOS_VERSION\$" &&
32 { echo "ERROR: Version already exists"; exit -1; }
Brian O'Connord730b222016-03-01 18:32:38 -080033
Ray Milkey8e4acbf2016-11-21 17:30:59 -080034
35cp $ONOS_ROOT/.buckconfig.local $DIR/
36
37
Brian O'Connord730b222016-03-01 18:32:38 -080038export ONOS_ROOT=$DIR
Brian O'Connorc5996b22016-03-01 18:55:05 -080039. $ONOS_ROOT/tools/build/envDefaults
Ray Milkey3ac00792016-12-01 14:28:15 -080040exec bash $COMMAND
Brian O'Connord730b222016-03-01 18:32:38 -080041
Brian O'Connor3be81652016-03-02 13:55:11 -080042# TODO on exit, print "leaving directory"