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
This commit is contained in:
osm0sis committed 2015-12-04 10:16:13 -04:00
1 parent 5112f2e4ae
commit af7a85316b
2 files changed
+13 -2

No files matched your search

+10 -2
View File
@@ -30,22 +30,26 @@ ui_print " ";
mkdir -p /tmp/anykernel; mkdir -p /tmp/anykernel;
cd /tmp/anykernel; cd /tmp/anykernel;
unzip -o "$ZIP"; 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 "$(file_getprop /tmp/anykernel/anykernel.sh kernel.string)";
ui_print " "; ui_print " ";
ui_print "AnyKernel2 by osm0sis @ xda-developers"; ui_print "AnyKernel2 by osm0sis @ xda-developers";
ui_print " "; ui_print " ";
/sbin/busybox mount /system; /sbin/busybox mount -o ro /system;
if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.devicecheck)" == 1 ]; then if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.devicecheck)" == 1 ]; then
ui_print "Checking device..."; ui_print "Checking device...";
ui_print " ";
for i in 1 2 3 4 5; do for i in 1 2 3 4 5; do
testname="$(file_getprop /tmp/anykernel/anykernel.sh device.name$i)"; testname="$(file_getprop /tmp/anykernel/anykernel.sh device.name$i)";
if [ "$(getprop ro.product.device)" == "$testname" -o "$(getprop ro.build.product)" == "$testname" ]; then if [ "$(getprop ro.product.device)" == "$testname" -o "$(getprop ro.build.product)" == "$testname" ]; then
ui_print "$testname";
match=1; match=1;
fi; fi;
done; done;
ui_print " ";
if [ "$match" != 1 ]; then if [ "$match" != 1 ]; then
umount /system; umount /system;
abort "Unsupported device. Aborting..."; abort "Unsupported device. Aborting...";
@@ -55,8 +59,10 @@ fi;
if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.initd)" == 1 ]; then if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.initd)" == 1 ]; then
ui_print "Creating init.d..."; ui_print "Creating init.d...";
ui_print " "; ui_print " ";
/sbin/busybox mount -o remount,rw /system;
mkdir /system/etc/init.d; mkdir /system/etc/init.d;
set_perm_recursive 0 0 0755 0755 /system/etc/init.d; set_perm_recursive 0 0 0755 0755 /system/etc/init.d;
/sbin/busybox mount -o remount,ro /system;
fi; fi;
ui_print "Installing kernel..."; ui_print "Installing kernel...";
@@ -69,8 +75,10 @@ fi;
if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.modules)" == 1 ]; then if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.modules)" == 1 ]; then
ui_print "Pushing modules..."; ui_print "Pushing modules...";
ui_print " "; ui_print " ";
/sbin/busybox mount -o remount,rw /system;
cp -f /tmp/anykernel/modules/* /system/lib/modules/; cp -f /tmp/anykernel/modules/* /system/lib/modules/;
set_perm_recursive 0 0 0755 0644 /system/lib/modules; set_perm_recursive 0 0 0755 0644 /system/lib/modules;
/sbin/busybox mount -o remount,ro /system;
fi; fi;
if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.cleanup)" == 1 ]; then if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.cleanup)" == 1 ]; then
+3
View File
@@ -60,6 +60,9 @@ You may also use ui_print "<text>" 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 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 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. 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.