Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Squish a CM otapackage for distribution |
| 4 | # cyanogen |
| 5 | # |
| 6 | |
| 7 | OUT_TARGET_HOST=$(uname -a | grep Darwin) |
| 8 | if [ -z "$OUT_TARGET_HOST" ] |
| 9 | then |
| 10 | OUT_TARGET_HOST=linux-x86 |
| 11 | MD5=md5sum |
| 12 | else |
| 13 | OUT_TARGET_HOST=darwin-x86 |
| 14 | MD5=md5 |
| 15 | fi |
| 16 | |
| 17 | OTAPACKAGE=$OUT/$TARGET_PRODUCT-ota-$TARGET_BUILD_VARIANT.$LOGNAME.zip |
| 18 | if [ ! -f "$OTAPACKAGE" ]; then |
| 19 | echo "$OTAPACKAGE doesn't exist!"; |
| 20 | exit 1 |
| 21 | fi |
| 22 | |
| 23 | XBIN=$OUT/system/xbin |
| 24 | OPTICHARGER=$ANDROID_BUILD_TOP/vendor/cyanogen/tools/opticharger |
Pat Thoyts | 304457f | 2010-07-11 02:42:36 -0400 | [diff] [blame^] | 25 | QUIET=-q |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 26 | DELETE_BINS="applypatch applypatch_static check_prereq recovery updater" |
Pat Thoyts | 304457f | 2010-07-11 02:42:36 -0400 | [diff] [blame^] | 27 | [ -z "$NO_SQUASHFS" -a `which mksquashfs` = "" ] && NO_SQUASHFS=true |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 28 | |
| 29 | WORK=/tmp/repack |
| 30 | rm -rf $WORK |
| 31 | mkdir -p $WORK |
| 32 | |
| 33 | if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ] |
| 34 | then |
| 35 | # Create the xbin squashfs |
| 36 | cp -a $XBIN $WORK/xbin/ |
ctso | f095b8a | 2010-07-03 08:16:59 +0000 | [diff] [blame] | 37 | 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 Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 42 | fi |
| 43 | |
| 44 | # Unpack the otapackage and opticharge all apks |
| 45 | mkdir $WORK/ota |
| 46 | cd $WORK/ota |
Pat Thoyts | 304457f | 2010-07-11 02:42:36 -0400 | [diff] [blame^] | 47 | unzip $QUIET $OTAPACKAGE |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 48 | cd system/framework |
| 49 | $OPTICHARGER framework-res.apk |
| 50 | cd ../app |
| 51 | for i in *.apk; do |
| 52 | $OPTICHARGER $i; |
| 53 | done |
| 54 | |
| 55 | cd $WORK/ota/system |
| 56 | |
Steve Kondik | c47804f | 2010-07-07 09:06:39 -0400 | [diff] [blame] | 57 | if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ] |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 58 | then |
| 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/ |
| 64 | fi |
| 65 | |
| 66 | # Fix build.prop |
Pat Thoyts | 304457f | 2010-07-11 02:42:36 -0400 | [diff] [blame^] | 67 | sed -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 Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 71 | mv build.prop.new build.prop |
| 72 | |
| 73 | # Delete unnecessary binaries |
| 74 | for i in $DELETE_BINS; do |
| 75 | rm -f bin/$i |
| 76 | done |
| 77 | |
| 78 | # Find the CM version |
Pat Thoyts | 304457f | 2010-07-11 02:42:36 -0400 | [diff] [blame^] | 79 | MODVERSION=`sed -ne '/ro\.modversion/s/^.*CyanogenMod-//p' build.prop` |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 80 | |
| 81 | # No need for recovery |
| 82 | cd $WORK/ota |
| 83 | rm -rf recovery |
| 84 | |
| 85 | # Remove xbin stuff and fix up updater-script |
Steve Kondik | c47804f | 2010-07-07 09:06:39 -0400 | [diff] [blame] | 86 | if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ] |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 87 | then |
| 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 Kondik | 7cfb49f | 2010-07-09 01:34:30 -0400 | [diff] [blame] | 89 | mv updater-script.new META-INF/com/google/android/updater-script |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 90 | fi |
| 91 | |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 92 | # Pack it up and sign |
Pat Thoyts | 304457f | 2010-07-11 02:42:36 -0400 | [diff] [blame^] | 93 | zip $QUIET -r update.zip . |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 94 | echo "Signing package.." |
| 95 | SECURITYDIR=$ANDROID_BUILD_TOP/build/target/product/security |
| 96 | 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 |
| 97 | |
ctso | cff00cd | 2010-07-03 06:15:31 +0000 | [diff] [blame] | 98 | if [ "$CYANOGEN_NIGHTLY" != "" ] |
| 99 | then |
ctso | 7e2391a | 2010-07-03 06:31:37 +0000 | [diff] [blame] | 100 | OUTFILE=$OUT/update-squished.zip |
ctso | cff00cd | 2010-07-03 06:15:31 +0000 | [diff] [blame] | 101 | else |
ctso | 7e2391a | 2010-07-03 06:31:37 +0000 | [diff] [blame] | 102 | OUTFILE=$OUT/update-cm-$MODVERSION-signed.zip |
ctso | cff00cd | 2010-07-03 06:15:31 +0000 | [diff] [blame] | 103 | fi |
ctso | 7e2391a | 2010-07-03 06:31:37 +0000 | [diff] [blame] | 104 | mv update_signed.zip $OUTFILE |
| 105 | $MD5 $OUTFILE > $OUTFILE.md5sum |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 106 | echo "Package complete: $OUT/update-cm-$MODVERSION-signed.zip"; |
ctso | 7e2391a | 2010-07-03 06:31:37 +0000 | [diff] [blame] | 107 | cat $OUTFILE.md5sum |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 108 | |