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
This commit is contained in:
osm0sis committed 2014-08-27 02:24:58 -03:00
1 parent b7a0960e1d
commit 7ffb3bb1aa
3 files changed
+19 -1

No files matched your search

+6 -1
View File
@@ -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(" ");
+2
View File
@@ -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
+11
View File
@@ -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;
}