diff --git a/cmd/revid-cli/upgrade.sh b/cmd/revid-cli/upgrade.sh new file mode 100755 index 00000000..b4f6f8d1 --- /dev/null +++ b/cmd/revid-cli/upgrade.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# All-purpose upgrade script. +# Upgrades source(s) to given Git tag, runs make in each directory, +# and write tags to tags.conf upon success, exiting 0. +# NB: Customize SrcDirs as needed to reflect dependencies. +Usage="Usage: upgrade.sh [-d] tag" +VarDir="/var/netsender" +BaseDir="$HOME/go/src/bitbucket.org/ausocean" +SrcDirs=($BaseDir/iot $BaseDir/av) +if [ "$1" == "-d" ]; then + set -x + GitFlags="" + NewTag="$2" +else + GitFlags="--quiet" + NewTag="$1" +fi +if [ -z "$NewTag" ]; then + echo "$Usage" + exit 1 +fi +for dir in ${SrcDirs[@]}; do + pushd $dir + git fetch $GitFlags --depth=1 origin refs/tags/$NewTag:refs/tags/$NewTag + git checkout $GitFlags1 tags/$NewTag + if [ ! "$?" == 0 ]; then + exit 1 + fi + if [ -e Makefile ]; then + make + if [ ! "$?" == 0 ]; then + exit 1 + fi + fi + popd +done +if [ ! -d "$VarDir" ]; then + echo "Error: $VarDir does not exit." + exit 1 +fi +git tag > "$VarDir/tags.conf" +exit $?