2010-01-02 19:10:08 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2012-01-02 18:11:36 -08:00
|
|
|
set -u -e
|
|
|
|
|
|
|
|
TAGNAME=""
|
|
|
|
FILES=""
|
2014-08-29 07:21:54 -07:00
|
|
|
LIST_FILE=''
|
2012-03-01 22:10:41 -08:00
|
|
|
VARIANT="XWords4"
|
2012-01-02 18:25:01 -08:00
|
|
|
XW_WWW_PATH=${XW_WWW_PATH:-""}
|
2013-11-14 21:53:19 -08:00
|
|
|
XW_RELEASE_SCP_DEST=${XW_RELEASE_SCP_DEST:-""}
|
2012-01-02 18:11:36 -08:00
|
|
|
|
2010-01-02 19:10:08 +00:00
|
|
|
usage() {
|
2014-08-29 07:21:54 -07:00
|
|
|
echo "Error: $*" >&2
|
|
|
|
echo "usage: $0 [--tag <name>] [--variant variant] [--apk-list path/to/out.txt] [<package-unsigned.apk>]" >&2
|
2010-01-02 19:10:08 +00:00
|
|
|
exit 1
|
|
|
|
}
|
|
|
|
|
2010-04-25 03:38:50 +00:00
|
|
|
do_build() {
|
|
|
|
WD=$(pwd)
|
2012-03-01 22:10:41 -08:00
|
|
|
cd $(dirname $0)/../${VARIANT}/
|
2010-04-25 03:38:50 +00:00
|
|
|
rm -rf bin/ gen/
|
2012-03-05 19:07:49 -08:00
|
|
|
ant clean release
|
2010-04-25 03:38:50 +00:00
|
|
|
cd $WD
|
|
|
|
}
|
2010-01-02 19:10:08 +00:00
|
|
|
|
2012-01-02 18:11:36 -08:00
|
|
|
while [ "$#" -gt 0 ]; do
|
2010-06-05 10:17:53 -07:00
|
|
|
case $1 in
|
2012-03-01 22:10:41 -08:00
|
|
|
--tag)
|
|
|
|
TAGNAME=$2
|
2010-06-05 10:17:53 -07:00
|
|
|
git describe $TAGNAME || usage "$TAGNAME not a valid git tag"
|
|
|
|
shift
|
|
|
|
;;
|
2012-03-01 22:10:41 -08:00
|
|
|
--variant)
|
|
|
|
VARIANT=$2
|
|
|
|
shift
|
|
|
|
;;
|
2014-08-29 07:21:54 -07:00
|
|
|
--apk-list)
|
|
|
|
LIST_FILE=$2
|
|
|
|
> $LIST_FILE
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--help)
|
|
|
|
usage
|
|
|
|
;;
|
2010-06-05 10:17:53 -07:00
|
|
|
*)
|
|
|
|
FILES="$1"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ -n "$TAGNAME" ]; then
|
|
|
|
git branch 2>/dev/null | grep '\* android_branch' \
|
|
|
|
|| usage "not currently at android_branch"
|
|
|
|
git checkout $TAGNAME 2>/dev/null || usage "unable to checkout $TAGNAME"
|
|
|
|
HASH=$(git log -1 --pretty=format:%H)
|
|
|
|
CHECK_BRANCH=$(git describe $HASH 2>/dev/null)
|
|
|
|
if [ "$CHECK_BRANCH" != $TAGNAME ]; then
|
|
|
|
usage "tagname not found in repo or not as expected"
|
|
|
|
fi
|
2010-06-05 10:29:22 -07:00
|
|
|
git stash
|
2010-06-05 10:17:53 -07:00
|
|
|
fi
|
2010-01-02 19:10:08 +00:00
|
|
|
|
|
|
|
if [ -z "$FILES" ]; then
|
2010-04-25 03:38:50 +00:00
|
|
|
do_build
|
2010-01-02 19:10:08 +00:00
|
|
|
FILES=$(ls $(dirname $0)/../*/bin/*-unsigned.apk)
|
|
|
|
if [ -z "$FILES" ]; then
|
|
|
|
echo "unable to find any unsigned packages" >&2
|
|
|
|
usage
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
for PACK_UNSIGNED in $FILES; do
|
|
|
|
|
|
|
|
PACK_SIGNED=$(basename $PACK_UNSIGNED)
|
2014-08-29 07:21:54 -07:00
|
|
|
echo "base: $PACK_SIGNED" >&2
|
2010-01-02 19:10:08 +00:00
|
|
|
PACK_SIGNED=${PACK_SIGNED/-unsigned}
|
2014-08-29 07:21:54 -07:00
|
|
|
echo "signed: $PACK_SIGNED" >&2
|
2016-02-01 06:27:29 -08:00
|
|
|
jarsigner -verbose -digestalg SHA1 -keystore ~/.keystore $PACK_UNSIGNED mykey
|
2010-01-02 19:10:08 +00:00
|
|
|
rm -f $PACK_SIGNED
|
|
|
|
zipalign -v 4 $PACK_UNSIGNED $PACK_SIGNED
|
|
|
|
[ -n "$XW_WWW_PATH" ] && cp $PACK_SIGNED $XW_WWW_PATH
|
2014-10-13 19:06:40 -07:00
|
|
|
TARGET="${PACK_SIGNED%.apk}_$(git rev-parse --verify HEAD)_$(git describe).apk"
|
2013-11-14 21:53:19 -08:00
|
|
|
cp $PACK_SIGNED "${TARGET}"
|
2014-08-29 07:21:54 -07:00
|
|
|
echo "created ${TARGET}" >&2
|
|
|
|
[ -n "$LIST_FILE" ] && echo ${TARGET} >> $LIST_FILE
|
2010-01-02 19:10:08 +00:00
|
|
|
done
|
2010-06-05 10:17:53 -07:00
|
|
|
|
|
|
|
if [ -n "$TAGNAME" ]; then
|
2010-06-05 10:29:22 -07:00
|
|
|
git stash pop
|
2010-06-05 10:17:53 -07:00
|
|
|
git checkout android_branch 2>/dev/null
|
|
|
|
fi
|