Skip to content
Browse files

Fix colorized output while building

reference bash instead instead of sh
Some systems symlink sh to bash while others symlink to dash or use sh
on it's own

Change-Id: Iaa87d001d1a174b0220085816ea5b3f28a7ab34a
  • Loading branch information...
1 parent 626ee29 commit 63cf049eccab356b7360416cf57b7097f2681de3 @KAsp3rd KAsp3rd committed with Gerrit Code Review Jan 8, 2013
Showing with 57 additions and 57 deletions.
  1. +21 −21 tools/opticharger
  2. +36 −36 tools/squisher
View
42 tools/opticharger
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# Super-mega opticharger of doom
# Shrinks apks by running pngcrush or optipng or pngout on png images
@@ -39,14 +39,14 @@ then
APKCERTS=$OUT/obj/PACKAGING/target_files_intermediates/$TARGET_PRODUCT-target_files-$TARGET_BUILD_VARIANT.$USER/META/apkcerts.txt
if [ ! -f "$APKCERTS" ];
then
- echo $CL_RED"Set APKCERTS to the path to your apkcerts.txt file"$CL_RST
+ echo -e $CL_RED"Set APKCERTS to the path to your apkcerts.txt file"$CL_RST
exit 1;
fi
fi
if [ ! -f "$APKCERTS" ];
then
- echo $CL_RED"Invalid path to apkcerts.txt, set APKCERTS to the correct path."$CL_RST
+ echo -e $CL_RED"Invalid path to apkcerts.txt, set APKCERTS to the correct path."$CL_RST
fi
if [ "$(which pngcrush)" != "" ];
@@ -71,59 +71,59 @@ then
pngout $1
}
else
- echo $CL_RED"Please install pngcrush, optipng, or pngout"$CL_RST
+ echo -e $CL_RED"Please install pngcrush, optipng, or pngout"$CL_RST
exit 1;
fi
if [ "`which aapt`" = "" ];
then
- echo $CL_RED"Please ensure aapt is in your \$PATH"$CL_RST
+ echo -e $CL_RED"Please ensure aapt is in your \$PATH"$CL_RST
exit 1;
fi
if [ "`which zipalign`" = "" ];
then
- echo $CL_RED"Please ensure zipalign is in your \$PATH"$CL_RST
+ echo -e $CL_RED"Please ensure zipalign is in your \$PATH"$CL_RST
exit 1;
fi
if [ -e "$1" ];
then
NAME=`basename $1`;
- echo $CL_CYN"Optimizing"$CL_RST" $NAME...";
+ echo -e $CL_CYN"Optimizing"$CL_RST" $NAME...";
if [ "$2" != "" ];
then
CERT=build/target/product/security/$2.x509.pem
KEY=build/target/product/security/$2.pk8
if [ ! -f "$ANDROID_BUILD_TOP/$CERT" ];
then
- echo $CL_RED"$CERT does not exist!";$CL_RST
+ echo -e $CL_RED"$CERT does not exist!";$CL_RST
exit 1;
fi
else
APKINFO=`grep "name=\"$NAME\"" $APKCERTS`;
- [ $QUIET ] || echo "APKINFO: $APKINFO";
+ [ $QUIET ] || echo -e "APKINFO: $APKINFO";
if [ "$APKINFO" = "" ];
then
- echo $CL_RED"No apk info for $NAME";$CL_RST
+ echo -e $CL_RED"No apk info for $NAME";$CL_RST
exit 1;
fi
- CERT=`echo $APKINFO | awk {'print $2'} | cut -f 2 -d "=" | tr -d "\""`;
- KEY=`echo $APKINFO | awk {'print $3'} | cut -f 2 -d "=" | tr -d "\""`;
+ CERT=`echo -e $APKINFO | awk {'print $2'} | cut -f 2 -d "=" | tr -d "\""`;
+ KEY=`echo -e $APKINFO | awk {'print $3'} | cut -f 2 -d "=" | tr -d "\""`;
if [ "$CERT" = "" ];
then
- echo $CL_RED"Unable to find certificate for $NAME"$CL_RST
+ echo -e $CL_RED"Unable to find certificate for $NAME"$CL_RST
exit 1;
fi
if [ "$CERT" = "PRESIGNED" ];
then
- echo $CL_GRN"$NAME is presigned, skipping"$CL_RST
+ echo -e $CL_GRN"$NAME is presigned, skipping"$CL_RST
exit 1;
fi
fi
- [ $QUIET ] || echo $CL_YLW"Certificate:"$CL_RST" $CERT";
+ [ $QUIET ] || echo -e $CL_YLW"Certificate:"$CL_RST" $CERT";
[ -d $TMPDIR/$NAME ] && rm -rf $TMPDIR/$NAME
mkdir -p $TMPDIR/$NAME
@@ -132,25 +132,25 @@ then
unzip -q $BASE/$1
for x in `find . -name "*.png" | grep -v "\.9.png$" | tr "\n" " "`
do
- [ $QUIET ] || echo $CL_GRN"Crushing $x"$CL_RST
+ [ $QUIET ] || echo -e $CL_GRN"Crushing $x"$CL_RST
optimize_png $x
done
cp $BASE/$1 $BASE/$1.old
- [ $QUIET ] || echo $CL_GRN"Repacking apk.."$CL_RST
+ [ $QUIET ] || echo -e $CL_GRN"Repacking apk.."$CL_RST
aapt p -0 .dat -0 .dict -0 .arsc -F $NAME .
- [ $QUIET ] || echo $CL_YLW"Resigning with cert: `echo $CERT`"$CL_RST
+ [ $QUIET ] || echo -e $CL_YLW"Resigning with cert: `echo -e $CERT`"$CL_RST
- [ $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
+ [ $QUIET ] || echo -e 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
- [ $QUIET ] || echo $CL_GRN"Zipalign.."$CL_RST
+ [ $QUIET ] || echo -e $CL_GRN"Zipalign.."$CL_RST
zipalign -f 4 signed_$NAME $BASE/$1
if [ ! $QUIET ]; then
ls -l $BASE/$1.old
ls -l $BASE/$1
fi
rm $BASE/$1.old
else
- echo "Usage: $0 [apk file]"
+ echo -e "Usage: $0 [apk file]"
fi
View
72 tools/squisher
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
# Squish a CM otapackage for distribution
#
@@ -22,7 +22,7 @@ else
fi
if [ -z "$OUT" -o ! -d "$OUT" ]; then
- echo "ERROR: $0 only works with a full build environment. $OUT should exist."
+ echo -e "ERROR: $0 only works with a full build environment. $OUT should exist."
exit 1
fi
@@ -34,7 +34,7 @@ else
OTAPACKAGE=$OUT/$TARGET_PRODUCT-ota-$TARGET_BUILD_VARIANT.$USER.zip
fi
if [ ! -f "$OTAPACKAGE" ]; then
- echo "$OTAPACKAGE doesn't exist!";
+ echo -e "$OTAPACKAGE doesn't exist!";
exit 1
fi
@@ -54,38 +54,38 @@ if [ "$WANT_SQUASHFS" -eq 1 ]; then
MKSQUASHFS_VER_REQ=4
if type mksquashfs >/dev/null 2>&1; then
if mksquashfs -version | grep -q "version $MKSQUASHFS_VER_REQ"; then :; else
- echo
- echo $CL_RED"ERROR: mksquashfs must be at least version $MKSQUASHFS_VER_REQ for this build."$CL_RST
+ echo -e
+ echo -e $CL_RED"ERROR: mksquashfs must be at least version $MKSQUASHFS_VER_REQ for this build."$CL_RST
fatal=1
fi
else
- echo
- echo $CL_RED"ERROR: $TARGET_PRODUCT requires mksquashfs."$CL_RST
+ echo -e
+ echo -e $CL_RED"ERROR: $TARGET_PRODUCT requires mksquashfs."$CL_RST
fatal=1
fi
if [ "$fatal" -ne 0 ]; then
- echo
- echo $CL_YLW" Unoptimized package is still available at"
- echo " $OTAPACKAGE"$CL_RST
+ echo -e
+ echo -e $CL_YLW" Unoptimized package is still available at"
+ echo -e " $OTAPACKAGE"$CL_RST
exit $fatal
fi
fi
REPACK=$OUT/repack.d
-echo $CL_CYN"Sanitizing environment..."$CL_RST
+echo -e $CL_CYN"Sanitizing environment..."$CL_RST
rm -rf $REPACK
mkdir -p $REPACK
-echo
+echo -e
# Unpack the otapackage and opticharge all apks
mkdir $REPACK/ota
(
cd $REPACK/ota
-echo $CL_CYN"Unpacking $OTAPACKAGE..."$CL_RST
+echo -e $CL_CYN"Unpacking $OTAPACKAGE..."$CL_RST
unzip $QUIET $OTAPACKAGE
-echo
+echo -e
# Move all apks to the same directory so xargs can
# use also with framework-res.apk. This allow process
@@ -145,7 +145,7 @@ $SED -i \
# Delete unnecessary binaries
-( cd $REPACK/ota/system/bin; echo $DELETE_BINS | xargs rm -f; )
+( cd $REPACK/ota/system/bin; echo -e $DELETE_BINS | xargs rm -f; )
# Delete leftover wireless driver
# rm -rf $REPACK/ota/system/lib/modules/*/kernel/drivers/net
@@ -165,41 +165,41 @@ MODVERSION="$VERSION"
OUTFILE=$OUT/$MODVERSION.zip
# Pack it up and sign
-echo $CL_CYN"Zipping package..."$CL_RST
+echo -e $CL_CYN"Zipping package..."$CL_RST
( cd $REPACK/ota; zip $QUIET -r $REPACK/update.zip . )
-echo
-echo $CL_CYN"Signing package..."$CL_RST
+echo -e
+echo -e $CL_CYN"Signing package..."$CL_RST
SECURITYDIR=$ANDROID_BUILD_TOP/build/target/product/security
java -Xmx1024m \
-jar $ANDROID_BUILD_TOP/out/host/$OUT_TARGET_HOST/framework/signapk.jar \
-w $SECURITYDIR/testkey.x509.pem $SECURITYDIR/testkey.pk8 \
$REPACK/update.zip $OUTFILE
-echo
-echo $CL_CYN"Cleaning up..."$CL_RST
+echo -e
+echo -e $CL_CYN"Cleaning up..."$CL_RST
rm -rf $REPACK
-echo
+echo -e
# Create a md5 checksum image of the repacked package
(
img=`basename $OUTFILE`
cd `dirname $OUTFILE`
$MD5 $img >$img.md5sum
ZIPSIZE=`ls -lah $OUTFILE | awk '{ print $5}' `
-echo
-echo $CL_RED" ______"$CL_MAG" _____"$CL_CYN" __ __"$CL_BLU" ____"$CL_RST
-echo $CL_RED" /\\\\ _ \\\\"$CL_MAG"/\\\\ __\`\\\\"$CL_CYN"/\\\\ \\\\/\\\\ \\\\"$CL_BLU" /\\\\ _\`\\\\"$CL_RST
-echo $CL_RED" \\\\ \\\\ \\\\L\\\\ \\\\"$CL_MAG" \\\\ \\\\/\\\\ \\\\"$CL_CYN" \\\\ \\\\/'/'"$CL_BLU"\\\\ \\\\ \\\\L\\\\ \\\\"$CL_RST
-echo $CL_RED" \\\\ \\\\ __ \\\\"$CL_MAG" \\\\ \\\\ \\\\ \\\\"$CL_CYN" \\\\ , <"$CL_BLU" \\\\ \\\\ ,__/"$CL_RST
-echo $CL_RED" \\\\ \\\\ \\\\/\\\\ \\\\"$CL_MAG" \\\\ \\\\_\\\\ \\\\"$CL_CYN" \\\\ \\\\\\\\\`\\\\"$CL_BLU" \\\\ \\\\ \\\\/"$CL_RST
-echo $CL_RED" \\\\ \\\\_\\\\ \\\\_\\\\"$CL_MAG" \\\\_____\\\\"$CL_CYN" \\\\_\\\\ \\\\_\\\\"$CL_BLU"\\\\ \\\\_\\\\"$CL_RST
-echo $CL_RED" \\\\/_/\\\\/_/"$CL_MAG"\\\\/_____/"$CL_CYN"\\\\/_/\\\\/_/"$CL_BLU" \\\\/_/"$CL_RST
-echo
-echo $CL_CYN"===========-Package complete-==========="$CL_RST
-echo $CL_CYN"zip:"$CL_MAG" $OUTFILE"$CL_RST
-echo $CL_CYN"md5:"$CL_MAG" $(cat $img.md5sum | awk '{ print $1 }')"$CL_RST
-echo $CL_CYN"size:"$CL_MAG" $ZIPSIZE"$CL_RST
-echo $CL_CYN"========================================"$CL_RST
-echo
+echo -e
+echo -e $CL_RED" ______"$CL_MAG" _____"$CL_CYN" __ __"$CL_BLU" ____"$CL_RST
+echo -e $CL_RED" /\\\\ _ \\\\"$CL_MAG"/\\\\ __\`\\\\"$CL_CYN"/\\\\ \\\\/\\\\ \\\\"$CL_BLU" /\\\\ _\`\\\\"$CL_RST
+echo -e $CL_RED" \\\\ \\\\ \\\\L\\\\ \\\\"$CL_MAG" \\\\ \\\\/\\\\ \\\\"$CL_CYN" \\\\ \\\\/'/'"$CL_BLU"\\\\ \\\\ \\\\L\\\\ \\\\"$CL_RST
+echo -e $CL_RED" \\\\ \\\\ __ \\\\"$CL_MAG" \\\\ \\\\ \\\\ \\\\"$CL_CYN" \\\\ , <"$CL_BLU" \\\\ \\\\ ,__/"$CL_RST
+echo -e $CL_RED" \\\\ \\\\ \\\\/\\\\ \\\\"$CL_MAG" \\\\ \\\\_\\\\ \\\\"$CL_CYN" \\\\ \\\\\\\\\`\\\\"$CL_BLU" \\\\ \\\\ \\\\/"$CL_RST
+echo -e $CL_RED" \\\\ \\\\_\\\\ \\\\_\\\\"$CL_MAG" \\\\_____\\\\"$CL_CYN" \\\\_\\\\ \\\\_\\\\"$CL_BLU"\\\\ \\\\_\\\\"$CL_RST
+echo -e $CL_RED" \\\\/_/\\\\/_/"$CL_MAG"\\\\/_____/"$CL_CYN"\\\\/_/\\\\/_/"$CL_BLU" \\\\/_/"$CL_RST
+echo -e
+echo -e $CL_CYN"===========-Package complete-==========="$CL_RST
+echo -e $CL_CYN"zip:"$CL_MAG" $OUTFILE"$CL_RST
+echo -e $CL_CYN"md5:"$CL_MAG" $(cat $img.md5sum | awk '{ print $1 }')"$CL_RST
+echo -e $CL_CYN"size:"$CL_MAG" $ZIPSIZE"$CL_RST
+echo -e $CL_CYN"========================================"$CL_RST
+echo -e
)
exit 0

0 comments on commit 63cf049

Please sign in to comment.
Something went wrong with that request. Please try again.