From bd4ba60cc55183ffcca6f035ab0e1c959f615e49 Mon Sep 17 00:00:00 2001 From: osm0sis Date: Wed, 23 Dec 2015 13:19:32 -0400 Subject: [PATCH] AnyKernel2: custom user script support, fixes - fix copy of any subdirectories under modules/ - adjust display of modules installation text to match the others - add support for custom user scripts (at /data/custom_boot_image_patch.sh - same as latest SuperSU zips) to automatically execute before reflashing the rebuilt boot image for bump, loki etc. modifications --- META-INF/com/google/android/update-binary | 10 +++++----- anykernel.sh | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/META-INF/com/google/android/update-binary b/META-INF/com/google/android/update-binary index 6757327..ce82f97 100755 --- a/META-INF/com/google/android/update-binary +++ b/META-INF/com/google/android/update-binary @@ -23,7 +23,7 @@ set_perm_recursive() { } file_getprop() { grep "^$2" "$1" | cut -d= -f2; } getprop() { test -e /sbin/getprop && /sbin/getprop $1 || file_getprop /default.prop $1; } -abort() { ui_print "$*"; exit 1; } +abort() { ui_print "$*"; umount /system; umount /data; exit 1; } show_progress 1.34 4; ui_print " "; @@ -39,6 +39,7 @@ ui_print " "; ui_print "AnyKernel2 by osm0sis @ xda-developers"; ui_print " "; /sbin/busybox mount -o ro /system; +/sbin/busybox mount /data; if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.devicecheck)" == 1 ]; then ui_print "Checking device..."; @@ -51,7 +52,6 @@ if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.devicecheck)" == 1 ]; then done; ui_print " "; if [ "$match" != 1 ]; then - umount /system; abort "Unsupported device. Aborting..."; fi; fi; @@ -68,15 +68,14 @@ fi; ui_print "Installing kernel..."; /sbin/sh /tmp/anykernel/anykernel.sh $2; if [ $? != "0" ]; then - umount /system; abort; fi; if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.modules)" == 1 ]; then - ui_print "Pushing modules..."; ui_print " "; + ui_print "Pushing modules..."; /sbin/busybox mount -o remount,rw /system; - cp -f /tmp/anykernel/modules/* /system/lib/modules/; + cp -rf /tmp/anykernel/modules/* /system/lib/modules/; set_perm_recursive 0 0 0755 0644 /system/lib/modules; /sbin/busybox mount -o remount,ro /system; fi; @@ -86,6 +85,7 @@ if [ "$(file_getprop /tmp/anykernel/anykernel.sh do.cleanup)" == 1 ]; then fi; umount /system; +umount /data; ui_print " "; ui_print "Done!"; diff --git a/anykernel.sh b/anykernel.sh index 47be448..c389958 100755 --- a/anykernel.sh +++ b/anykernel.sh @@ -89,6 +89,12 @@ write_boot() { elif [ `wc -c < /tmp/anykernel/boot-new.img` -gt `wc -c < /tmp/anykernel/boot.img` ]; then ui_print " "; ui_print "New image larger than boot partition. Aborting..."; exit 1; fi; + if [ -f "/data/custom_boot_image_patch.sh" ]; then + sh /data/custom_boot_image_patch.sh /tmp/anykernel/boot-new.img; + if [ $? != 0 ]; then + ui_print " "; ui_print "User script execution failed. Aborting..."; exit 1; + fi; + fi; dd if=/tmp/anykernel/boot-new.img of=$block; }