summaryrefslogtreecommitdiff
path: root/anykernel.sh
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 /anykernel.sh
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
Diffstat (limited to 'anykernel.sh')
-rwxr-xr-xanykernel.sh11
1 files changed, 11 insertions, 0 deletions
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;
}