Brian O'Connor | d730b22 | 2016-03-01 18:32:38 -0800 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | # -------------------------------------------------------- |
| 3 | # Creates a tempdir for release and checks out the code |
| 4 | # -------------------------------------------------------- |
| 5 | |
| 6 | set -e |
Ray Milkey | 3ac0079 | 2016-12-01 14:28:15 -0800 | [diff] [blame] | 7 | set -x |
Brian O'Connor | d730b22 | 2016-03-01 18:32:38 -0800 | [diff] [blame] | 8 | |
| 9 | GERRIT_USER=${GERRIT_USER:-$USER} |
| 10 | BRANCH=${2:-master} |
Ray Milkey | 3ac0079 | 2016-12-01 14:28:15 -0800 | [diff] [blame] | 11 | COMMAND=${3:--i} |
Brian O'Connor | d730b22 | 2016-03-01 18:32:38 -0800 | [diff] [blame] | 12 | |
| 13 | export ONOS_VERSION=${1:-$ONOS_VERSION} |
| 14 | if [ -z "$ONOS_VERSION" ]; then |
| 15 | echo "USAGE: onos-prepare-release <version number>" |
| 16 | echo " Alternatively, ONOS_VERSION must be set" |
| 17 | exit -1 |
| 18 | fi |
| 19 | |
| 20 | DIR=$(mktemp -d /tmp/onos-release.XXXXX) && |
| 21 | echo "Created tempdir for release: $DIR" || |
| 22 | { echo "Failed to create temp file"; exit 1; } |
| 23 | |
| 24 | cd $DIR |
| 25 | git init |
| 26 | git remote add origin ssh://$GERRIT_USER@gerrit.onosproject.org:29418/onos.git |
| 27 | git fetch origin |
| 28 | git checkout $BRANCH |
| 29 | |
| 30 | # Check existance of version |
Brian O'Connor | a317872 | 2016-03-10 15:44:27 -0800 | [diff] [blame] | 31 | git tag -l | grep -q "$ONOS_VERSION\$" && |
| 32 | { echo "ERROR: Version already exists"; exit -1; } |
Brian O'Connor | d730b22 | 2016-03-01 18:32:38 -0800 | [diff] [blame] | 33 | |
Ray Milkey | 8e4acbf | 2016-11-21 17:30:59 -0800 | [diff] [blame] | 34 | |
| 35 | cp $ONOS_ROOT/.buckconfig.local $DIR/ |
| 36 | |
| 37 | |
Brian O'Connor | d730b22 | 2016-03-01 18:32:38 -0800 | [diff] [blame] | 38 | export ONOS_ROOT=$DIR |
Brian O'Connor | c5996b2 | 2016-03-01 18:55:05 -0800 | [diff] [blame] | 39 | . $ONOS_ROOT/tools/build/envDefaults |
Ray Milkey | 3ac0079 | 2016-12-01 14:28:15 -0800 | [diff] [blame] | 40 | exec bash $COMMAND |
Brian O'Connor | d730b22 | 2016-03-01 18:32:38 -0800 | [diff] [blame] | 41 | |
Brian O'Connor | 3be8165 | 2016-03-02 13:55:11 -0800 | [diff] [blame] | 42 | # TODO on exit, print "leaving directory" |