From bf38d208c821fb8ffdcd914f01bbd5d88063ab00 Mon Sep 17 00:00:00 2001 From: osm0sis Date: Fri, 7 Jun 2019 21:35:10 -0300 Subject: [PATCH] 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 --- tools/ak3-core.sh | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/ak3-core.sh b/tools/ak3-core.sh index c1fbf44..531ca00 100755 --- a/tools/ak3-core.sh +++ b/tools/ak3-core.sh @@ -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;