AK3: update for latest magiskboot, don't un/repack kernel if not patched

This commit is contained in:
osm0sis committed 2023-04-18 13:27:44 -03:00
1 parent ddbb40edc8
commit d6e040c227
2 files changed
+11 -6

No files matched your search

+1 -1
View File
@@ -3,4 +3,4 @@
# Dummy file; update-binary is a shell script (DO NOT CHANGE)
#
#
# AK_BASE_VERSION=20230416
# AK_BASE_VERSION=20230418
+10 -5
View File
@@ -237,7 +237,7 @@ repack_ramdisk() {
# flash_boot (build, sign and write image only)
flash_boot() {
local varlist i kernel ramdisk fdt cmdline comp part0 part1 nocompflag signfail pk8 cert avbtype;
local varlist i kernel ramdisk fdt cmdline comp part0 part1 needskernelpatch nocompflag signfail pk8 cert avbtype;
cd $split_img;
if [ -f "$bin/mkimage" ]; then
@@ -326,10 +326,12 @@ flash_boot() {
echo "Attempting kernel unpack with busybox $comp..." >&2;
$comp -dc $kernel > kernel;
fi;
$bin/magiskboot hexpatch kernel 736B69705F696E697472616D667300 77616E745F696E697472616D667300;
# legacy SAR kernel string skip_initramfs -> want_initramfs
$bin/magiskboot hexpatch kernel 736B69705F696E697472616D6673 77616E745F696E697472616D6673 && needskernelpatch=1;
if [ "$(file_getprop $home/anykernel.sh do.systemless)" == 1 ]; then
strings kernel 2>/dev/null | grep -E -m1 'Linux version.*#' > $home/vertmp;
fi;
if [ "$needskernelpatch" ]; then
if [ "$comp" ]; then
$bin/magiskboot compress=$comp kernel kernel.$comp;
if [ $? != 0 ] && $comp --help 2>/dev/null; then
@@ -338,18 +340,21 @@ flash_boot() {
fi;
mv -f kernel.$comp kernel;
fi;
else
echo "Restoring untouched new kernel since no patching required..." >&2;
cp -f $kernel kernel;
fi;
[ ! -f .magisk ] && $bin/magiskboot cpio ramdisk.cpio "extract .backup/.magisk .magisk";
export $(cat .magisk);
[ $((magisk_patched & 8)) -ne 0 ] && export TWOSTAGEINIT=true;
for fdt in dtb extra kernel_dtb recovery_dtbo; do
[ -f $fdt ] && $bin/magiskboot dtb $fdt patch;
[ -f $fdt ] && $bin/magiskboot dtb $fdt patch; # remove dtb verity/avb
done;
else
case $kernel in
*-dtb) rm -f kernel_dtb;;
esac;
fi;
unset magisk_patched KEEPFORCEENCRYPT KEEPVERITY SHA1 TWOSTAGEINIT; # leave PATCHVBMETAFLAG set for repack
unset magisk_patched KEEPVERITY KEEPFORCEENCRYPT RECOVERYMODE PREINITDEVICE SHA1 RANDOMSEED; # leave PATCHVBMETAFLAG set for repack
;;
esac;
case $ramdisk_compression in