summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorosm0sis <osm0sis@outlook.com>2014-08-26 16:09:16 -0300
committerosm0sis <osm0sis@outlook.com>2014-08-27 02:24:58 -0300
commit7ffb3bb1aa0ad78dd9f8a897b69fd89e41178553 (patch)
treec90de947ac23e46d31c878ec2d77539d5bc8ae5f
parentb7a0960e1d218694e6e49c8bc44d17a51a6d9a50 (diff)
anykernel.sh: add basic exit statuses
- add exit codes to trigger the abort in the updater-script if something goes wrong - add ui_print function to write error message directly back to recovery - compare size of dumped image and new image and abort if the new image is oversized for the partition
-rw-r--r--META-INF/com/google/android/updater-script7
-rw-r--r--README2
-rwxr-xr-xanykernel.sh11
3 files changed, 19 insertions, 1 deletions
diff --git a/META-INF/com/google/android/updater-script b/META-INF/com/google/android/updater-script
index 98347b6..efd208c 100644
--- a/META-INF/com/google/android/updater-script
+++ b/META-INF/com/google/android/updater-script
@@ -22,7 +22,12 @@ ifelse(file_getprop("/tmp/anykernel/anykernel.sh", "do.initd") == 1,
)
);
ui_print("Installing kernel...");
-assert(run_program("/sbin/sh", "/tmp/anykernel/anykernel.sh"));
+run_program("/sbin/sh", "/tmp/anykernel/anykernel.sh");
+ifelse(run_program("/sbin/sh", "-c", "test `cat /tmp/anykernel/exitcode` == 1") == 0,
+ (unmount("/system");
+ abort();
+ )
+);
ifelse(file_getprop("/tmp/anykernel/anykernel.sh", "do.modules") == 1,
(ui_print("Pushing modules...");
ui_print(" ");
diff --git a/README b/README
index 373a02f..35516a8 100644
--- a/README
+++ b/README
@@ -46,6 +46,8 @@ Similarly, "line match string" and "line replace string" are the search strings
"before/after" requires you simply specify "before" or "after" for the placement of the inserted line, in relation to "line match string".
+You may also use ui_print "<text>" to write messages back to the recovery during the modification process.
+
// Instructions
1- Place zImage in the root
diff --git a/anykernel.sh b/anykernel.sh
index a1744a5..3769590 100755
--- a/anykernel.sh
+++ b/anykernel.sh
@@ -29,10 +29,17 @@ cd $ramdisk;
chmod -R 755 $bin;
mkdir -p $split_img;
+OUTFD=`ps | grep -v "grep" | grep -oE "update(.*)" | cut -d" " -f3`;
+ui_print() { echo "ui_print $1" >&$OUTFD; echo "ui_print" >&$OUTFD; }
+
# dump boot and extract ramdisk
dump_boot() {
dd if=$block of=/tmp/anykernel/boot.img;
$bin/unpackbootimg -i /tmp/anykernel/boot.img -o $split_img;
+ if [ $? != 0 ]; then
+ ui_print " "; ui_print "Dumping/unpacking image failed. Aborting...";
+ echo 1 > /tmp/anykernel/exitcode; exit;
+ fi;
gunzip -c $split_img/boot.img-ramdisk.gz | cpio -i;
}
@@ -59,6 +66,10 @@ write_boot() {
cd $ramdisk;
find . | cpio -H newc -o | gzip > /tmp/anykernel/ramdisk-new.cpio.gz;
$bin/mkbootimg --kernel /tmp/anykernel/zImage --ramdisk /tmp/anykernel/ramdisk-new.cpio.gz $second --cmdline "$cmdline" --board "$board" --base $base --pagesize $pagesize --kernel_offset $kerneloff --ramdisk_offset $ramdiskoff $secondoff --tags_offset $tagsoff $dtb --output /tmp/anykernel/boot-new.img;
+ if [ $? != 0 -o `wc -c < /tmp/anykernel/boot-new.img` -gt `wc -c < /tmp/anykernel/boot.img` ]; then
+ ui_print " "; ui_print "Repacking image failed. Aborting...";
+ echo 1 > /tmp/anykernel/exitcode; exit;
+ fi;
dd if=/tmp/anykernel/boot-new.img of=$block;
}