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/ |
| 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 |
| 42 | fi |
| 43 | |
| 44 | # Unpack the otapackage and opticharge all apks |
| 45 | mkdir $WORK/ota |
| 46 | cd $WORK/ota |
| 47 | unzip $OTAPACKAGE |
| 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 | |
| 57 | if [ "$TARGET_PRODUCT" == "cyanogen_dream_sapphire" ] |
| 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 |
| 67 | grep -v ro.kernel.android.checkjni build.prop | sed -e "s/^ro\.build\.type=eng$/ro\.build\.type=user/g" > build.prop.new |
| 68 | mv build.prop.new build.prop |
| 69 | |
| 70 | # Delete unnecessary binaries |
| 71 | for i in $DELETE_BINS; do |
| 72 | rm -f bin/$i |
| 73 | done |
| 74 | |
| 75 | # Find the CM version |
| 76 | MODVERSION=`grep ro.modversion build.prop | sed -e "s/^.*CyanogenMod-//g"` |
| 77 | |
| 78 | # No need for recovery |
| 79 | cd $WORK/ota |
| 80 | rm -rf recovery |
| 81 | |
| 82 | # Remove xbin stuff and fix up updater-script |
| 83 | if [ "$TARGET_PRODUCT" == "cyanogen_dream_sapphire" ] |
| 84 | then |
| 85 | sed -e "s/system\/xbin\/su/system\/bin\/su/g" META-INF/com/google/android/updater-script | grep -v xbin > updater-script.new |
| 86 | else |
| 87 | cp META-INF/com/google/android/updater-script updater-script.new |
| 88 | fi |
| 89 | |
| 90 | echo "ui_print(\"Welcome to CyanogenMod-$MODVERSION!\");" > META-INF/com/google/android/updater-script |
| 91 | cat updater-script.new >> META-INF/com/google/android/updater-script |
| 92 | rm updater-script.new |
| 93 | |
| 94 | # Pack it up and sign |
| 95 | zip -r update.zip . |
| 96 | echo "Signing package.." |
| 97 | SECURITYDIR=$ANDROID_BUILD_TOP/build/target/product/security |
| 98 | 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 |
| 99 | |
ctso | cff00cd | 2010-07-03 06:15:31 +0000 | [diff] [blame^] | 100 | if [ "$CYANOGEN_NIGHTLY" != "" ] |
| 101 | then |
| 102 | mv update_signed.zip $OUT/update-squished.zip |
| 103 | else |
| 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 |
| 106 | fi |
Steve Kondik | ae76c84 | 2010-06-28 11:47:26 -0400 | [diff] [blame] | 107 | |
| 108 | echo "Package complete: $OUT/update-cm-$MODVERSION-signed.zip"; |
| 109 | cat $OUT/update-cm-$MODVERSION-signed.zip.md5sum |
| 110 | |