2010-06-28 15:47:26 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Squish a CM otapackage for distribution
|
|
|
|
# cyanogen
|
|
|
|
#
|
|
|
|
|
|
|
|
OUT_TARGET_HOST=$(uname -a | grep Darwin)
|
|
|
|
if [ -z "$OUT_TARGET_HOST" ]
|
|
|
|
then
|
|
|
|
OUT_TARGET_HOST=linux-x86
|
|
|
|
MD5=md5sum
|
|
|
|
else
|
|
|
|
OUT_TARGET_HOST=darwin-x86
|
|
|
|
MD5=md5
|
|
|
|
fi
|
|
|
|
|
|
|
|
OTAPACKAGE=$OUT/$TARGET_PRODUCT-ota-$TARGET_BUILD_VARIANT.$LOGNAME.zip
|
|
|
|
if [ ! -f "$OTAPACKAGE" ]; then
|
|
|
|
echo "$OTAPACKAGE doesn't exist!";
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
XBIN=$OUT/system/xbin
|
|
|
|
OPTICHARGER=$ANDROID_BUILD_TOP/vendor/cyanogen/tools/opticharger
|
2010-07-11 06:42:36 +00:00
|
|
|
QUIET=-q
|
2010-06-28 15:47:26 +00:00
|
|
|
DELETE_BINS="applypatch applypatch_static check_prereq recovery updater"
|
2010-07-15 19:44:43 +00:00
|
|
|
if [ -z "$NO_SQUASHFS" -a `which mksquashfs` = "" ]; then
|
|
|
|
NO_SQUASHFS=true
|
|
|
|
else
|
|
|
|
if mksquashfs -version | grep -q 'version 4'; then :; else
|
|
|
|
echo "mksquashfs must be at least version 4 for this build"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
fi
|
2010-06-28 15:47:26 +00:00
|
|
|
|
|
|
|
WORK=/tmp/repack
|
|
|
|
rm -rf $WORK
|
|
|
|
mkdir -p $WORK
|
|
|
|
|
|
|
|
if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ]
|
|
|
|
then
|
|
|
|
# Create the xbin squashfs
|
|
|
|
cp -a $XBIN $WORK/xbin/
|
2010-07-03 08:16:59 +00:00
|
|
|
chmod -R 755 $WORK/xbin/*
|
2010-07-15 19:44:43 +00:00
|
|
|
rm -f $WORK/xbin/su
|
2010-07-03 08:16:59 +00:00
|
|
|
ln -s $WORK/bin/su $WORK/xbin/su
|
2010-07-15 19:44:43 +00:00
|
|
|
mksquashfs $WORK/xbin/* $WORK/xbin.sqf -force-uid 1000 -force-gid 1000
|
2010-06-28 15:47:26 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Unpack the otapackage and opticharge all apks
|
|
|
|
mkdir $WORK/ota
|
|
|
|
cd $WORK/ota
|
2010-07-11 06:42:36 +00:00
|
|
|
unzip $QUIET $OTAPACKAGE
|
2010-06-28 15:47:26 +00:00
|
|
|
cd system/framework
|
|
|
|
$OPTICHARGER framework-res.apk
|
|
|
|
cd ../app
|
|
|
|
for i in *.apk; do
|
|
|
|
$OPTICHARGER $i;
|
|
|
|
done
|
|
|
|
|
|
|
|
cd $WORK/ota/system
|
|
|
|
|
2010-07-07 13:06:39 +00:00
|
|
|
if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ]
|
2010-06-28 15:47:26 +00:00
|
|
|
then
|
|
|
|
# Relocate su and put xbin.sqf where it belongs
|
|
|
|
rm -f bin/su
|
|
|
|
mv xbin/su bin/su
|
|
|
|
rm -rf xbin/*
|
|
|
|
mv $WORK/xbin.sqf xbin/
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Fix build.prop
|
2010-07-11 06:42:36 +00:00
|
|
|
sed -n -e '/ro\.kernel\.android\.checkjni/d' \
|
|
|
|
-e '/ro\.build\.type/s/eng/user/' \
|
|
|
|
-e 'p' \
|
|
|
|
build.prop > build.prop.new
|
2010-06-28 15:47:26 +00:00
|
|
|
mv build.prop.new build.prop
|
|
|
|
|
|
|
|
# Delete unnecessary binaries
|
|
|
|
for i in $DELETE_BINS; do
|
|
|
|
rm -f bin/$i
|
|
|
|
done
|
|
|
|
|
2010-07-11 08:34:44 +00:00
|
|
|
# Delete leftover wireless driver
|
|
|
|
rm -rf lib/modules/*/kernel/drivers/net
|
|
|
|
|
|
|
|
# Strip modules
|
|
|
|
find lib/modules -name "*.ko" -exec arm-eabi-strip --strip-unneeded {} \;
|
|
|
|
|
2010-06-28 15:47:26 +00:00
|
|
|
# Find the CM version
|
2010-07-11 06:42:36 +00:00
|
|
|
MODVERSION=`sed -ne '/ro\.modversion/s/^.*CyanogenMod-//p' build.prop`
|
2010-06-28 15:47:26 +00:00
|
|
|
|
|
|
|
# No need for recovery
|
|
|
|
cd $WORK/ota
|
|
|
|
rm -rf recovery
|
|
|
|
|
|
|
|
# Remove xbin stuff and fix up updater-script
|
2010-07-07 13:06:39 +00:00
|
|
|
if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ]
|
2010-06-28 15:47:26 +00:00
|
|
|
then
|
|
|
|
sed -e "s/system\/xbin\/su/system\/bin\/su/g" META-INF/com/google/android/updater-script | grep -v xbin > updater-script.new
|
2010-07-09 05:34:30 +00:00
|
|
|
mv updater-script.new META-INF/com/google/android/updater-script
|
2010-06-28 15:47:26 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
# Pack it up and sign
|
2010-07-11 06:42:36 +00:00
|
|
|
zip $QUIET -r update.zip .
|
2010-06-28 15:47:26 +00:00
|
|
|
echo "Signing package.."
|
|
|
|
SECURITYDIR=$ANDROID_BUILD_TOP/build/target/product/security
|
|
|
|
java -Xmx2048m -jar $ANDROID_BUILD_TOP/out/host/$OUT_TARGET_HOST/framework/signapk.jar -w $SECURITYDIR/testkey.x509.pem $SECURITYDIR/testkey.pk8 update.zip update_signed.zip
|
|
|
|
|
2010-07-03 06:15:31 +00:00
|
|
|
if [ "$CYANOGEN_NIGHTLY" != "" ]
|
|
|
|
then
|
2010-07-03 06:31:37 +00:00
|
|
|
OUTFILE=$OUT/update-squished.zip
|
2010-07-03 06:15:31 +00:00
|
|
|
else
|
2010-07-03 06:31:37 +00:00
|
|
|
OUTFILE=$OUT/update-cm-$MODVERSION-signed.zip
|
2010-07-03 06:15:31 +00:00
|
|
|
fi
|
2010-07-03 06:31:37 +00:00
|
|
|
mv update_signed.zip $OUTFILE
|
|
|
|
$MD5 $OUTFILE > $OUTFILE.md5sum
|
2010-06-28 15:47:26 +00:00
|
|
|
echo "Package complete: $OUT/update-cm-$MODVERSION-signed.zip";
|
2010-07-03 06:31:37 +00:00
|
|
|
cat $OUTFILE.md5sum
|
2010-06-28 15:47:26 +00:00
|
|
|
|