improve script. Allow pass either branch or tag on commandline,

defaulting to branch of tree from which called.  Add usage().  set -u
-e and deal with [ -n "$1" ] being an error in that case.
This commit is contained in:
Andy2 2010-11-07 08:16:36 -08:00
parent 46a01ace56
commit 57838c0436

View file

@ -1,19 +1,55 @@
#!/bin/sh
BUILDIR=/tmp/$(basename $0)_build_$$
CURDIR=$(pwd)
SRCDIR=${CURDIR}/../../../
set -e -u
echo $BUILDIR
echo $SRCDIR
ls $SRCDIR
usage () {
echo "usage: $(basename $0) [--tag tagname | --branch branchname]"
echo " # (uses current branch as default)"
exit 0
}
TAG=""
BRANCH=""
while [ 0 -lt $# ] ; do
case $1 in
--tag)
TAG=$2
shift
;;
--branch)
BRANCH=$2
shift
;;
*)
usage
;;
esac
shift
done
if [ -n "$TAG" ]; then
if ! git tag | grep -w "$TAG"; then
echo "tag $TAG not found"
usage
fi
elif [ -z $BRANCH ]; then
BRANCH=$(git branch | grep '^*' | sed 's,^.* ,,')
fi
echo "building with ${TAG}${BRANCH}"
BUILDIR=/tmp/$(basename $0)_build_$$
SRCDIR=$(pwd)/$(dirname $0)/../../../
CURDIR=$(pwd)
mkdir -p $BUILDIR
cd $BUILDIR
git clone $SRCDIR BUILD
cd BUILD
git checkout android_branch
./xwords4/android/scripts/arelease.sh $*
git checkout ${TAG}${BRANCH}
./xwords4/android/scripts/arelease.sh
cp *.apk /tmp
cd $CURDIR