Make opticharger less verbose and clean up after itself.

The verbose output of opticharger can obscure warning messages about missing
tools so this patch reduces the noise.
The script leaves droppings in /tmp so clean this up on exit using a trap.

Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
This commit is contained in:
Pat Thoyts 2010-06-11 11:53:38 +01:00 committed by Steve Kondik
parent 4eb2673f34
commit 0e7f64ef60
1 changed files with 17 additions and 13 deletions

View File

@ -18,7 +18,8 @@ else
fi fi
set -e set -e
QUIET=1
QFLAG=-q
BASE=`pwd` BASE=`pwd`
if [ "$APKCERTS" = "" ]; if [ "$APKCERTS" = "" ];
then then
@ -69,7 +70,7 @@ then
fi fi
else else
APKINFO=`grep "name=\"$NAME\"" $APKCERTS`; APKINFO=`grep "name=\"$NAME\"" $APKCERTS`;
echo "APKINFO: $APKINFO"; [ $QUIET ] || echo "APKINFO: $APKINFO";
if [ "$APKINFO" = "" ]; if [ "$APKINFO" = "" ];
then then
echo "No apk info for $NAME"; echo "No apk info for $NAME";
@ -84,16 +85,17 @@ then
fi fi
fi fi
echo "Certificate: $CERT"; [ $QUIET ] || echo "Certificate: $CERT";
rm -rf /tmp/$NAME [ -d /tmp/$NAME ] && rm -rf /tmp/$NAME
mkdir /tmp/$NAME mkdir /tmp/$NAME
trap "rm -rf /tmp/$NAME; exit" INT TERM EXIT
cd /tmp/$NAME cd /tmp/$NAME
unzip $BASE/$1 unzip -q $BASE/$1
for x in `find . -name "*.png" | grep -v "\.9.png$" | tr "\n" " "` for x in `find . -name "*.png" | grep -v "\.9.png$" | tr "\n" " "`
do do
echo "Crushing $x" [ $QUIET ] || echo "Crushing $x"
pngcrush $x $x.crushed 1>/dev/null pngcrush $QFLAG $x $x.crushed 1>/dev/null
if [ -e "$x.crushed" ]; if [ -e "$x.crushed" ];
then then
mv $x.crushed $x mv $x.crushed $x
@ -101,17 +103,19 @@ then
done done
cp $BASE/$1 $BASE/$1.old cp $BASE/$1 $BASE/$1.old
echo "Repacking apk.." [ $QUIET ] || echo "Repacking apk.."
aapt p -0 res/raw -0 res/raw-en -F $NAME . aapt p -0 res/raw -0 res/raw-en -F $NAME .
echo "Resigning with cert: `echo $CERT`" [ $QUIET ] || echo "Resigning with cert: `echo $CERT`"
echo java -jar $ANDROID_BUILD_TOP/out/host/$OUT_TARGET_HOST/framework/signapk.jar $ANDROID_BUILD_TOP/$CERT $ANDROID_BUILD_TOP/$KEY $NAME signed_$NAME [ $QUIET ] || echo java -jar $ANDROID_BUILD_TOP/out/host/$OUT_TARGET_HOST/framework/signapk.jar $ANDROID_BUILD_TOP/$CERT $ANDROID_BUILD_TOP/$KEY $NAME signed_$NAME
java -jar $ANDROID_BUILD_TOP/out/host/$OUT_TARGET_HOST/framework/signapk.jar $ANDROID_BUILD_TOP/$CERT $ANDROID_BUILD_TOP/$KEY $NAME signed_$NAME java -jar $ANDROID_BUILD_TOP/out/host/$OUT_TARGET_HOST/framework/signapk.jar $ANDROID_BUILD_TOP/$CERT $ANDROID_BUILD_TOP/$KEY $NAME signed_$NAME
echo "Zipalign.." [ $QUIET ] || echo "Zipalign.."
zipalign -f 4 signed_$NAME $BASE/$1 zipalign -f 4 signed_$NAME $BASE/$1
ls -l $BASE/$1.old if [ ! $QUIET ]; then
ls -l $BASE/$1 ls -l $BASE/$1.old
ls -l $BASE/$1
fi
rm $BASE/$1.old rm $BASE/$1.old
else else
echo "Usage: $0 [apk file]" echo "Usage: $0 [apk file]"