diff --git a/META-INF/com/google/android/updater-script b/META-INF/com/google/android/updater-script index 230fcfd..ccbad3a 100644 --- a/META-INF/com/google/android/updater-script +++ b/META-INF/com/google/android/updater-script @@ -3,4 +3,4 @@ # Dummy file; update-binary is a shell script (DO NOT CHANGE) # # -# AK_BASE_VERSION=20230416 +# AK_BASE_VERSION=20230418 diff --git a/tools/ak3-core.sh b/tools/ak3-core.sh index 45c6ca6..1582038 100755 --- a/tools/ak3-core.sh +++ b/tools/ak3-core.sh @@ -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,30 +326,35 @@ 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 [ "$comp" ]; then - $bin/magiskboot compress=$comp kernel kernel.$comp; - if [ $? != 0 ] && $comp --help 2>/dev/null; then - echo "Attempting kernel repack with busybox $comp..." >&2; - $comp -9c kernel > kernel.$comp; + if [ "$needskernelpatch" ]; then + if [ "$comp" ]; then + $bin/magiskboot compress=$comp kernel kernel.$comp; + if [ $? != 0 ] && $comp --help 2>/dev/null; then + echo "Attempting kernel repack with busybox $comp..." >&2; + $comp -9c kernel > kernel.$comp; + fi; + mv -f kernel.$comp kernel; fi; - mv -f kernel.$comp kernel; + 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