blob: e72431dbfbb993140729dba8907bcae1c2f86bce [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
Pat Thoyts304457f2010-07-11 02:42:36 -040025QUIET=-q
Steve Kondikae76c842010-06-28 11:47:26 -040026DELETE_BINS="applypatch applypatch_static check_prereq recovery updater"
Pat Thoyts304457f2010-07-11 02:42:36 -040027[ -z "$NO_SQUASHFS" -a `which mksquashfs` = "" ] && NO_SQUASHFS=true
Steve Kondikae76c842010-06-28 11:47:26 -040028
29WORK=/tmp/repack
30rm -rf $WORK
31mkdir -p $WORK
32
33if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ]
34then
35 # Create the xbin squashfs
36 cp -a $XBIN $WORK/xbin/
ctsof095b8a2010-07-03 08:16:59 +000037 chown -R 1000:1000 $WORK/xbin/*
38 chmod -R 755 $WORK/xbin/*
39 rm $WORK/xbin/su
40 ln -s $WORK/bin/su $WORK/xbin/su
41 mksquashfs $WORK/xbin/* $WORK/xbin.sqf
Steve Kondikae76c842010-06-28 11:47:26 -040042fi
43
44# Unpack the otapackage and opticharge all apks
45mkdir $WORK/ota
46cd $WORK/ota
Pat Thoyts304457f2010-07-11 02:42:36 -040047unzip $QUIET $OTAPACKAGE
Steve Kondikae76c842010-06-28 11:47:26 -040048cd system/framework
49$OPTICHARGER framework-res.apk
50cd ../app
51for i in *.apk; do
52 $OPTICHARGER $i;
53done
54
55cd $WORK/ota/system
56
Steve Kondikc47804f2010-07-07 09:06:39 -040057if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ]
Steve Kondikae76c842010-06-28 11:47:26 -040058then
59 # Relocate su and put xbin.sqf where it belongs
60 rm -f bin/su
61 mv xbin/su bin/su
62 rm -rf xbin/*
63 mv $WORK/xbin.sqf xbin/
64fi
65
66# Fix build.prop
Pat Thoyts304457f2010-07-11 02:42:36 -040067sed -n -e '/ro\.kernel\.android\.checkjni/d' \
68 -e '/ro\.build\.type/s/eng/user/' \
69 -e 'p' \
70 build.prop > build.prop.new
Steve Kondikae76c842010-06-28 11:47:26 -040071mv build.prop.new build.prop
72
73# Delete unnecessary binaries
74for i in $DELETE_BINS; do
75 rm -f bin/$i
76done
77
78# Find the CM version
Pat Thoyts304457f2010-07-11 02:42:36 -040079MODVERSION=`sed -ne '/ro\.modversion/s/^.*CyanogenMod-//p' build.prop`
Steve Kondikae76c842010-06-28 11:47:26 -040080
81# No need for recovery
82cd $WORK/ota
83rm -rf recovery
84
85# Remove xbin stuff and fix up updater-script
Steve Kondikc47804f2010-07-07 09:06:39 -040086if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ]
Steve Kondikae76c842010-06-28 11:47:26 -040087then
88 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 -040089 mv updater-script.new META-INF/com/google/android/updater-script
Steve Kondikae76c842010-06-28 11:47:26 -040090fi
91
Steve Kondikae76c842010-06-28 11:47:26 -040092# Pack it up and sign
Pat Thoyts304457f2010-07-11 02:42:36 -040093zip $QUIET -r update.zip .
Steve Kondikae76c842010-06-28 11:47:26 -040094echo "Signing package.."
95SECURITYDIR=$ANDROID_BUILD_TOP/build/target/product/security
96java -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
97
ctsocff00cd2010-07-03 06:15:31 +000098if [ "$CYANOGEN_NIGHTLY" != "" ]
99then
ctso7e2391a2010-07-03 06:31:37 +0000100 OUTFILE=$OUT/update-squished.zip
ctsocff00cd2010-07-03 06:15:31 +0000101else
ctso7e2391a2010-07-03 06:31:37 +0000102 OUTFILE=$OUT/update-cm-$MODVERSION-signed.zip
ctsocff00cd2010-07-03 06:15:31 +0000103fi
ctso7e2391a2010-07-03 06:31:37 +0000104mv update_signed.zip $OUTFILE
105$MD5 $OUTFILE > $OUTFILE.md5sum
Steve Kondikae76c842010-06-28 11:47:26 -0400106echo "Package complete: $OUT/update-cm-$MODVERSION-signed.zip";
ctso7e2391a2010-07-03 06:31:37 +0000107cat $OUTFILE.md5sum
Steve Kondikae76c842010-06-28 11:47:26 -0400108