2012-01-04 03:53:42 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
2013-04-06 17:16:57 +02:00
|
|
|
set -e -u
|
|
|
|
|
|
|
|
INDEX=0
|
2015-08-10 15:43:19 +02:00
|
|
|
DRYRUN=''
|
2013-04-06 17:16:57 +02:00
|
|
|
|
|
|
|
usage() {
|
2015-08-10 15:43:19 +02:00
|
|
|
[ $# -gt 0 ] && echo "ERROR: $1"
|
|
|
|
echo "usage: $0 [--dry-run] [--help] [-n <index>]"
|
2013-04-06 17:16:57 +02:00
|
|
|
echo "uninstall crosswords from the <index>th device"
|
|
|
|
exit 0
|
|
|
|
}
|
|
|
|
|
2015-08-10 15:43:19 +02:00
|
|
|
while :; do
|
|
|
|
WD=$(pwd)
|
|
|
|
if [ -e ${WD}/AndroidManifest.xml ]; then
|
|
|
|
break
|
|
|
|
elif [ ${WD} = '/' ]; then
|
|
|
|
usage "reached / without finding AndroidManifest.xml"
|
|
|
|
else
|
|
|
|
cd ..
|
|
|
|
fi
|
|
|
|
done
|
2013-12-06 16:37:56 +01:00
|
|
|
|
2015-08-10 15:43:19 +02:00
|
|
|
PACK=$(grep 'package=\".*\..*\.*\"' ${WD}/AndroidManifest.xml | sed 's,^.*package="\(.*\)".*$,\1,')
|
|
|
|
|
|
|
|
if [ -z "${PACK}" ]; then
|
|
|
|
usage "unable to find package in ${WD}/AndroidManifest.xml"
|
|
|
|
fi
|
2013-12-06 16:37:56 +01:00
|
|
|
|
2013-04-06 17:16:57 +02:00
|
|
|
while [ $# -ge 1 ]; do
|
|
|
|
case $1 in
|
2015-08-10 15:43:19 +02:00
|
|
|
--dry-run)
|
|
|
|
DRYRUN=1
|
|
|
|
;;
|
2013-04-06 17:16:57 +02:00
|
|
|
-n)
|
|
|
|
shift
|
|
|
|
INDEX=$1
|
|
|
|
;;
|
|
|
|
*) usage
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
SERIAL="$(adb devices | grep 'device$' | sed -n "$((1+INDEX)) p" | awk '{print $1}')"
|
|
|
|
|
2015-08-10 15:43:19 +02:00
|
|
|
echo "adb -s $SERIAL uninstall $PACK"
|
|
|
|
[ -z "$DRYRUN" ] && adb -s $SERIAL uninstall $PACK
|