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 | f3aba5f | 2017-01-09 16:47:14 -0800 | [diff] [blame] | 34 | # Copy local buck configuration to new tree |
Ray Milkey | 8e4acbf | 2016-11-21 17:30:59 -0800 | [diff] [blame] | 35 | cp $ONOS_ROOT/.buckconfig.local $DIR/ |
| 36 | |
Brian O'Connor | d730b22 | 2016-03-01 18:32:38 -0800 | [diff] [blame] | 37 | export ONOS_ROOT=$DIR |
Ray Milkey | 8a0c7c7 | 2017-07-18 11:37:04 -0700 | [diff] [blame] | 38 | # This is a hack to remove symlinks from the ONOS_ROOT path. To be removed when |
| 39 | # the protobuf buck rules can handle symlinks |
| 40 | 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] | 41 | . $ONOS_ROOT/tools/build/envDefaults |
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 | |
Brian O'Connor | 3be8165 | 2016-03-02 13:55:11 -0800 | [diff] [blame] | 44 | # TODO on exit, print "leaving directory" |