blob: 856197871fddbfdc593e920aca2440b15abd6aeb [file] [log] [blame]
Steve Kondikae76c842010-06-28 11:47:26 -04001#!/bin/sh
2#
3# Squish a CM otapackage for distribution
4# cyanogen
5#
6
7OUT_TARGET_HOST=$(uname -a | grep Darwin)
8if [ -z "$OUT_TARGET_HOST" ]
9then
10 OUT_TARGET_HOST=linux-x86
11 MD5=md5sum
12else
13 OUT_TARGET_HOST=darwin-x86
14 MD5=md5
15fi
16
17OTAPACKAGE=$OUT/$TARGET_PRODUCT-ota-$TARGET_BUILD_VARIANT.$LOGNAME.zip
18if [ ! -f "$OTAPACKAGE" ]; then
19 echo "$OTAPACKAGE doesn't exist!";
20 exit 1
21fi
22
23XBIN=$OUT/system/xbin
24OPTICHARGER=$ANDROID_BUILD_TOP/vendor/cyanogen/tools/opticharger
25
26DELETE_BINS="applypatch applypatch_static check_prereq recovery updater"
27
28WORK=/tmp/repack
29rm -rf $WORK
30mkdir -p $WORK
31
32if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ]
33then
34 # Create the xbin squashfs
35 cp -a $XBIN $WORK/xbin/
ctsof095b8a2010-07-03 08:16:59 +000036 chown -R 1000:1000 $WORK/xbin/*
37 chmod -R 755 $WORK/xbin/*
38 rm $WORK/xbin/su
39 ln -s $WORK/bin/su $WORK/xbin/su
40 mksquashfs $WORK/xbin/* $WORK/xbin.sqf
Steve Kondikae76c842010-06-28 11:47:26 -040041fi
42
43# Unpack the otapackage and opticharge all apks
44mkdir $WORK/ota
45cd $WORK/ota
46unzip $OTAPACKAGE
47cd system/framework
48$OPTICHARGER framework-res.apk
49cd ../app
50for i in *.apk; do
51 $OPTICHARGER $i;
52done
53
54cd $WORK/ota/system
55
Steve Kondikc47804f2010-07-07 09:06:39 -040056if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ]
Steve Kondikae76c842010-06-28 11:47:26 -040057then
58 # Relocate su and put xbin.sqf where it belongs
59 rm -f bin/su
60 mv xbin/su bin/su
61 rm -rf xbin/*
62 mv $WORK/xbin.sqf xbin/
63fi
64
65# Fix build.prop
66grep -v ro.kernel.android.checkjni build.prop | sed -e "s/^ro\.build\.type=eng$/ro\.build\.type=user/g" > build.prop.new
67mv build.prop.new build.prop
68
69# Delete unnecessary binaries
70for i in $DELETE_BINS; do
71 rm -f bin/$i
72done
73
74# Find the CM version
75MODVERSION=`grep ro.modversion build.prop | sed -e "s/^.*CyanogenMod-//g"`
76
77# No need for recovery
78cd $WORK/ota
79rm -rf recovery
80
81# Remove xbin stuff and fix up updater-script
Steve Kondikc47804f2010-07-07 09:06:39 -040082if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ]
Steve Kondikae76c842010-06-28 11:47:26 -040083then
84 sed -e "s/system\/xbin\/su/system\/bin\/su/g" META-INF/com/google/android/updater-script | grep -v xbin > updater-script.new
Steve Kondik7cfb49f2010-07-09 01:34:30 -040085 mv updater-script.new META-INF/com/google/android/updater-script
Steve Kondikae76c842010-06-28 11:47:26 -040086fi
87
Steve Kondikae76c842010-06-28 11:47:26 -040088# Pack it up and sign
89zip -r update.zip .
90echo "Signing package.."
91SECURITYDIR=$ANDROID_BUILD_TOP/build/target/product/security
92java -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
93
ctsocff00cd2010-07-03 06:15:31 +000094if [ "$CYANOGEN_NIGHTLY" != "" ]
95then
ctso7e2391a2010-07-03 06:31:37 +000096 OUTFILE=$OUT/update-squished.zip
ctsocff00cd2010-07-03 06:15:31 +000097else
ctso7e2391a2010-07-03 06:31:37 +000098 OUTFILE=$OUT/update-cm-$MODVERSION-signed.zip
ctsocff00cd2010-07-03 06:15:31 +000099fi
ctso7e2391a2010-07-03 06:31:37 +0000100mv update_signed.zip $OUTFILE
101$MD5 $OUTFILE > $OUTFILE.md5sum
Steve Kondikae76c842010-06-28 11:47:26 -0400102echo "Package complete: $OUT/update-cm-$MODVERSION-signed.zip";
ctso7e2391a2010-07-03 06:31:37 +0000103cat $OUTFILE.md5sum
Steve Kondikae76c842010-06-28 11:47:26 -0400104