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
+17 -12

No files matched your search

+1 -1
View File
@@ -3,4 +3,4 @@
# Dummy file; update-binary is a shell script (DO NOT CHANGE) # Dummy file; update-binary is a shell script (DO NOT CHANGE)
# #
# #
# AK_BASE_VERSION=20230416 # AK_BASE_VERSION=20230418
+16 -11
View File
@@ -237,7 +237,7 @@ repack_ramdisk() {
# flash_boot (build, sign and write image only) # flash_boot (build, sign and write image only)
flash_boot() { 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; cd $split_img;
if [ -f "$bin/mkimage" ]; then if [ -f "$bin/mkimage" ]; then
@@ -326,30 +326,35 @@ flash_boot() {
echo "Attempting kernel unpack with busybox $comp..." >&2; echo "Attempting kernel unpack with busybox $comp..." >&2;
$comp -dc $kernel > kernel; $comp -dc $kernel > kernel;
fi; 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 if [ "$(file_getprop $home/anykernel.sh do.systemless)" == 1 ]; then
strings kernel 2>/dev/null | grep -E -m1 'Linux version.*#' > $home/vertmp; strings kernel 2>/dev/null | grep -E -m1 'Linux version.*#' > $home/vertmp;
fi; fi;
if [ "$comp" ]; then if [ "$needskernelpatch" ]; then
$bin/magiskboot compress=$comp kernel kernel.$comp; if [ "$comp" ]; then
if [ $? != 0 ] && $comp --help 2>/dev/null; then $bin/magiskboot compress=$comp kernel kernel.$comp;
echo "Attempting kernel repack with busybox $comp..." >&2; if [ $? != 0 ] && $comp --help 2>/dev/null; then
$comp -9c kernel > kernel.$comp; echo "Attempting kernel repack with busybox $comp..." >&2;
$comp -9c kernel > kernel.$comp;
fi;
mv -f kernel.$comp kernel;
fi; fi;
mv -f kernel.$comp kernel; else
echo "Restoring untouched new kernel since no patching required..." >&2;
cp -f $kernel kernel;
fi; fi;
[ ! -f .magisk ] && $bin/magiskboot cpio ramdisk.cpio "extract .backup/.magisk .magisk"; [ ! -f .magisk ] && $bin/magiskboot cpio ramdisk.cpio "extract .backup/.magisk .magisk";
export $(cat .magisk); export $(cat .magisk);
[ $((magisk_patched & 8)) -ne 0 ] && export TWOSTAGEINIT=true;
for fdt in dtb extra kernel_dtb recovery_dtbo; do 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; done;
else else
case $kernel in case $kernel in
*-dtb) rm -f kernel_dtb;; *-dtb) rm -f kernel_dtb;;
esac; esac;
fi; 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; esac;
case $ramdisk_compression in case $ramdisk_compression in