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 | |
Ray Milkey | f77ea41 | 2018-08-10 17:37:28 -0700 | [diff] [blame^] | 6 | set -eu -o pipefail |
Brian O'Connor | d730b22 | 2016-03-01 18:32:38 -0800 | [diff] [blame] | 7 | |
| 8 | GERRIT_USER=${GERRIT_USER:-$USER} |
| 9 | BRANCH=${2:-master} |
Ray Milkey | 3ac0079 | 2016-12-01 14:28:15 -0800 | [diff] [blame] | 10 | COMMAND=${3:--i} |
Brian O'Connor | d730b22 | 2016-03-01 18:32:38 -0800 | [diff] [blame] | 11 | |
| 12 | export ONOS_VERSION=${1:-$ONOS_VERSION} |
| 13 | if [ -z "$ONOS_VERSION" ]; then |
| 14 | echo "USAGE: onos-prepare-release <version number>" |
| 15 | echo " Alternatively, ONOS_VERSION must be set" |
| 16 | exit -1 |
| 17 | fi |
| 18 | |
| 19 | DIR=$(mktemp -d /tmp/onos-release.XXXXX) && |
| 20 | echo "Created tempdir for release: $DIR" || |
| 21 | { echo "Failed to create temp file"; exit 1; } |
| 22 | |
| 23 | cd $DIR |
| 24 | git init |
| 25 | git remote add origin ssh://$GERRIT_USER@gerrit.onosproject.org:29418/onos.git |
| 26 | git fetch origin |
| 27 | git checkout $BRANCH |
| 28 | |
| 29 | # Check existance of version |
Brian O'Connor | a317872 | 2016-03-10 15:44:27 -0800 | [diff] [blame] | 30 | git tag -l | grep -q "$ONOS_VERSION\$" && |
| 31 | { echo "ERROR: Version already exists"; exit -1; } |
Brian O'Connor | d730b22 | 2016-03-01 18:32:38 -0800 | [diff] [blame] | 32 | |
| 33 | export ONOS_ROOT=$DIR |
Ray Milkey | 8a0c7c7 | 2017-07-18 11:37:04 -0700 | [diff] [blame] | 34 | # This is a hack to remove symlinks from the ONOS_ROOT path. To be removed when |
| 35 | # the protobuf buck rules can handle symlinks |
| 36 | ONOS_ROOT=$(pushd $ONOS_ROOT >/dev/null && pwd -P && popd >/dev/null) |
Brian O'Connor | c5996b2 | 2016-03-01 18:55:05 -0800 | [diff] [blame] | 37 | . $ONOS_ROOT/tools/build/envDefaults |
Ray Milkey | f77ea41 | 2018-08-10 17:37:28 -0700 | [diff] [blame^] | 38 | |
| 39 | # cause any accidental invocation of buck to fail |
| 40 | ln -s /tmp/no/such/directory $DIR/buck-out |
| 41 | |
Ray Milkey | 3ac0079 | 2016-12-01 14:28:15 -0800 | [diff] [blame] | 42 | exec bash $COMMAND |
Brian O'Connor | d730b22 | 2016-03-01 18:32:38 -0800 | [diff] [blame] | 43 | |
Ray Milkey | 4867af2 | 2018-08-10 16:52:28 -0700 | [diff] [blame] | 44 | # TODO on exit, print "leaving directory" |