2018-06-06 02:19:14 +03:00
|
|
|
#!/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"
|
2018-06-06 02:23:37 +03:00
|
|
|
SrcDirs=($BaseDir/utils $BaseDir/iot $BaseDir/av)
|
2018-06-06 02:19:14 +03:00
|
|
|
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 $?
|