blob: e1557efa9b7e734a659657810a76b4fbc27b7529 [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/
36 cd $WORK/xbin
37 chown -R 1000:1000 *
38 chmod -R 755 *
39 rm su
40 ln -s ../bin/su su
41 mksquashfs . $WORK/xbin.sqf
42fi
43
44# Unpack the otapackage and opticharge all apks
45mkdir $WORK/ota
46cd $WORK/ota
47unzip $OTAPACKAGE
48cd system/framework
49$OPTICHARGER framework-res.apk
50cd ../app
51for i in *.apk; do
52 $OPTICHARGER $i;
53done
54
55cd $WORK/ota/system
56
57if [ "$TARGET_PRODUCT" == "cyanogen_dream_sapphire" ]
58then
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
67grep -v ro.kernel.android.checkjni build.prop | sed -e "s/^ro\.build\.type=eng$/ro\.build\.type=user/g" > build.prop.new
68mv build.prop.new build.prop
69
70# Delete unnecessary binaries
71for i in $DELETE_BINS; do
72 rm -f bin/$i
73done
74
75# Find the CM version
76MODVERSION=`grep ro.modversion build.prop | sed -e "s/^.*CyanogenMod-//g"`
77
78# No need for recovery
79cd $WORK/ota
80rm -rf recovery
81
82# Remove xbin stuff and fix up updater-script
83if [ "$TARGET_PRODUCT" == "cyanogen_dream_sapphire" ]
84then
85 sed -e "s/system\/xbin\/su/system\/bin\/su/g" META-INF/com/google/android/updater-script | grep -v xbin > updater-script.new
86else
87 cp META-INF/com/google/android/updater-script updater-script.new
88fi
89
90echo "ui_print(\"Welcome to CyanogenMod-$MODVERSION!\");" > META-INF/com/google/android/updater-script
91cat updater-script.new >> META-INF/com/google/android/updater-script
92rm updater-script.new
93
94# Pack it up and sign
95zip -r update.zip .
96echo "Signing package.."
97SECURITYDIR=$ANDROID_BUILD_TOP/build/target/product/security
98java -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
99
ctsocff00cd2010-07-03 06:15:31 +0000100if [ "$CYANOGEN_NIGHTLY" != "" ]
101then
102 mv update_signed.zip $OUT/update-squished.zip
103else
104 mv update_signed.zip $OUT/update-cm-$MODVERSION-signed.zip
105 $MD5 $OUT/update-cm-$MODVERSION-signed.zip > $OUT/update-cm-$MODVERSION-signed.zip.md5sum
106fi
Steve Kondikae76c842010-06-28 11:47:26 -0400107
108echo "Package complete: $OUT/update-cm-$MODVERSION-signed.zip";
109cat $OUT/update-cm-$MODVERSION-signed.zip.md5sum
110