From af7a85316b74e6420f64c75f9ea622c6c98cee20 Mon Sep 17 00:00:00 2001 From: osm0sis Date: Fri, 4 Dec 2015 10:06:31 -0400 Subject: [PATCH] Backend fixes: unzip error catching, only mount system rw if necessary - initial unzip verification to catch it early on broken recoveries/zips - display the matching name during the devicecheck while installing - mount /system ro for the off-chance getprop relies on build.prop (older recoveries), and only remount rw if init.d or modules need to be setup/installed to fix/workaround TWRP's "mount only as ro" feature being finicky and allow /system to remain untouched on devices supporting systemless root. - add signing documentation to README --- META-INF/com/google/android/update-binary | 12 ++++++++++-- README | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary index aed1aa0..6757327 100755 --- a/META-INF/com/google/android/update-binary +++ b/META-INF/com/google/android/update-binary @@ -30,22 +30,26 @@ ui_print " "; mkdir -p /tmp/anykernel; cd /tmp/anykernel; unzip -o "$ZIP"; +if [ $? != 0 -o -z "$(ls /tmp/anykernel)" ]; then + abort "Unzip failed. Aborting..."; +fi; ui_print "$(file_getprop /tmp/anykernel/anykernel.sh kernel.string)"; ui_print " "; ui_print "AnyKernel2 by osm0sis @ xda-developers"; ui_print " "; -/sbin/busybox mount /system; +/sbin/busybox mount -o ro /system; if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.devicecheck)" == 1 ]; then ui_print "Checking device..."; - ui_print " "; for i in 1 2 3 4 5; do testname="$(file_getprop /tmp/anykernel/anykernel.sh device.name$i)"; if [ "$(getprop ro.product.device)" == "$testname" -o "$(getprop ro.build.product)" == "$testname" ]; then + ui_print "$testname"; match=1; fi; done; + ui_print " "; if [ "$match" != 1 ]; then umount /system; abort "Unsupported device. Aborting..."; @@ -55,8 +59,10 @@ fi; if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.initd)" == 1 ]; then ui_print "Creating init.d..."; ui_print " "; + /sbin/busybox mount -o remount,rw /system; mkdir /system/etc/init.d; set_perm_recursive 0 0 0755 0755 /system/etc/init.d; + /sbin/busybox mount -o remount,ro /system; fi; ui_print "Installing kernel..."; @@ -69,8 +75,10 @@ fi; if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.modules)" == 1 ]; then ui_print "Pushing modules..."; ui_print " "; + /sbin/busybox mount -o remount,rw /system; cp -f /tmp/anykernel/modules/* /system/lib/modules/; set_perm_recursive 0 0 0755 0644 /system/lib/modules; + /sbin/busybox mount -o remount,ro /system; fi; if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.cleanup)" == 1 ]; then diff --git a/README b/README index b478936..c1c3fec 100644 --- a/README +++ b/README @@ -60,6 +60,9 @@ You may also use ui_print "" to write messages back to the recovery during 4- Modify the anykernel.sh to add your kernel's name, boot partition location, permissions for included ramdisk files, and use methods for any required ramdisk modifications 5- zip -r9 UPDATE-AnyKernel2.zip * -x README UPDATE-AnyKernel2.zip +If supporting a recovery that forces zip signature verification (like Cyanogen Recovery) then you will need to also sign your zip using the method I describe here: +http://forum.xda-developers.com/android/software-hacking/dev-complete-shell-script-flashable-zip-t2934449 + Not required, but any tweaks you can't hardcode into the source should be added with a bootscript.sh like is done in the example provided.