blob: 9869ac390b7b286e34104e2fb05ae991005dee34 [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 Milkeyf3aba5f2017-01-09 16:47:14 -080034# Copy local buck configuration to new tree
Ray Milkey8e4acbf2016-11-21 17:30:59 -080035cp $ONOS_ROOT/.buckconfig.local $DIR/
36
Brian O'Connord730b222016-03-01 18:32:38 -080037export ONOS_ROOT=$DIR
Ray Milkey8a0c7c72017-07-18 11:37:04 -070038# This is a hack to remove symlinks from the ONOS_ROOT path. To be removed when
39# the protobuf buck rules can handle symlinks
40ONOS_ROOT=$(pushd $ONOS_ROOT >/dev/null && pwd -P && popd >/dev/null)
Brian O'Connorc5996b22016-03-01 18:55:05 -080041. $ONOS_ROOT/tools/build/envDefaults
Ray Milkey3ac00792016-12-01 14:28:15 -080042exec bash $COMMAND
Brian O'Connord730b222016-03-01 18:32:38 -080043
Brian O'Connor3be81652016-03-02 13:55:11 -080044# TODO on exit, print "leaving directory"