AK3: be clear when unpack_ramdisk fails because there is no ramdisk

- previously this was failing a bit too spectacularly for my liking since $comp would erroneously get set to "fopen: ramdisk.cpio failed with 2: No such file or directory"
- on devices where there is no ramdisk.cpio unless rooted with Magisk this will indicate better to developers working on the device that they should be using "OG AK" mode to avoid trying to unpack a ramdisk which may or may not exist
This commit is contained in:
osm0sis committed 2019-06-07 21:35:10 -03:00
1 parent da324c430f
commit bf38d208c8
1 file changed
+6 -2
+6 -2
View File
@@ -123,7 +123,11 @@ unpack_ramdisk() {
mv -f ramdisk.cpio.gz ramdisk.cpio;
fi;
comp=$($bin/magiskboot decompress ramdisk.cpio 2>&1 | head -n1 | cut -d[ -f2 | cut -d] -f1 | grep -v 'compressed');
if [ -f ramdisk.cpio ]; then
comp=$($bin/magiskboot decompress ramdisk.cpio 2>&1 | head -n1 | cut -d[ -f2 | cut -d] -f1 | grep -v 'compressed');
else
abort "No ramdisk found to unpack. Aborting...";
fi;
if [ "$comp" -a "$comp" != "raw" ]; then
mv -f ramdisk.cpio ramdisk.cpio.$comp;
$bin/magiskboot decompress ramdisk.cpio.$comp ramdisk.cpio;
@@ -310,7 +314,7 @@ flash_boot() {
fi;
if [ ! -f boot-new.img ]; then
abort "Repacked image could not be found. Aborting...";
abort "No repacked image found to flash. Aborting...";
elif [ "$(wc -c < boot-new.img)" -gt "$(wc -c < boot.img)" ]; then
abort "New image larger than boot partition. Aborting...";
fi;