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 |
| 25 | |
| 26 | DELETE_BINS="applypatch applypatch_static check_prereq recovery updater" |
| 27 | |
| 28 | WORK=/tmp/repack |
| 29 | rm -rf $WORK |
| 30 | mkdir -p $WORK |
| 31 | |
| 32 | if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ] |
| 33 | then |
| 34 | # Create the xbin squashfs |
| 35 | cp -a $XBIN $WORK/xbin/ |
ctso | f095b8a | 2010-07-03 08:16:59 +0000 | [diff] [blame] | 36 | 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 Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 41 | fi |
| 42 | |
| 43 | # Unpack the otapackage and opticharge all apks |
| 44 | mkdir $WORK/ota |
| 45 | cd $WORK/ota |
| 46 | unzip $OTAPACKAGE |
| 47 | cd system/framework |
| 48 | $OPTICHARGER framework-res.apk |
| 49 | cd ../app |
| 50 | for i in *.apk; do |
| 51 | $OPTICHARGER $i; |
| 52 | done |
| 53 | |
| 54 | cd $WORK/ota/system |
| 55 | |
Steve Kondik | c47804f | 2010-07-07 09:06:39 -0400 | [diff] [blame^] | 56 | if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ] |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 57 | then |
| 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/ |
| 63 | fi |
| 64 | |
| 65 | # Fix build.prop |
| 66 | grep -v ro.kernel.android.checkjni build.prop | sed -e "s/^ro\.build\.type=eng$/ro\.build\.type=user/g" > build.prop.new |
| 67 | mv build.prop.new build.prop |
| 68 | |
| 69 | # Delete unnecessary binaries |
| 70 | for i in $DELETE_BINS; do |
| 71 | rm -f bin/$i |
| 72 | done |
| 73 | |
| 74 | # Find the CM version |
| 75 | MODVERSION=`grep ro.modversion build.prop | sed -e "s/^.*CyanogenMod-//g"` |
| 76 | |
| 77 | # No need for recovery |
| 78 | cd $WORK/ota |
| 79 | rm -rf recovery |
| 80 | |
| 81 | # Remove xbin stuff and fix up updater-script |
Steve Kondik | c47804f | 2010-07-07 09:06:39 -0400 | [diff] [blame^] | 82 | if [ "$TARGET_PRODUCT" = "cyanogen_dream_sapphire" ] |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 83 | then |
| 84 | sed -e "s/system\/xbin\/su/system\/bin\/su/g" META-INF/com/google/android/updater-script | grep -v xbin > updater-script.new |
| 85 | else |
| 86 | cp META-INF/com/google/android/updater-script updater-script.new |
| 87 | fi |
| 88 | |
| 89 | echo "ui_print(\"Welcome to CyanogenMod-$MODVERSION!\");" > META-INF/com/google/android/updater-script |
| 90 | cat updater-script.new >> META-INF/com/google/android/updater-script |
| 91 | rm updater-script.new |
| 92 | |
| 93 | # Pack it up and sign |
| 94 | zip -r update.zip . |
| 95 | echo "Signing package.." |
| 96 | SECURITYDIR=$ANDROID_BUILD_TOP/build/target/product/security |
| 97 | 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 |
| 98 | |
ctso | cff00cd | 2010-07-03 06:15:31 +0000 | [diff] [blame] | 99 | if [ "$CYANOGEN_NIGHTLY" != "" ] |
| 100 | then |
ctso | 7e2391a | 2010-07-03 06:31:37 +0000 | [diff] [blame] | 101 | OUTFILE=$OUT/update-squished.zip |
ctso | cff00cd | 2010-07-03 06:15:31 +0000 | [diff] [blame] | 102 | else |
ctso | 7e2391a | 2010-07-03 06:31:37 +0000 | [diff] [blame] | 103 | OUTFILE=$OUT/update-cm-$MODVERSION-signed.zip |
ctso | cff00cd | 2010-07-03 06:15:31 +0000 | [diff] [blame] | 104 | fi |
ctso | 7e2391a | 2010-07-03 06:31:37 +0000 | [diff] [blame] | 105 | mv update_signed.zip $OUTFILE |
| 106 | $MD5 $OUTFILE > $OUTFILE.md5sum |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 107 | echo "Package complete: $OUT/update-cm-$MODVERSION-signed.zip"; |
ctso | 7e2391a | 2010-07-03 06:31:37 +0000 | [diff] [blame] | 108 | cat $OUTFILE.md5sum |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 109 | |