diff --git a/AnyKernel3/LICENSE b/AnyKernel3/LICENSE index 9b115a72c766..8507f36ff741 100644 --- a/AnyKernel3/LICENSE +++ b/AnyKernel3/LICENSE @@ -76,8 +76,9 @@ busybox: GPLv2 (pre-patched source tree used to build available upon request) lptools_static: Apache License 2.0 +fec: Apache License 2.0 - Copyright (C) 2020 Pierre-Hugues Husson + Copyright their respective authors, (linked below). Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -91,8 +92,9 @@ lptools_static: Apache License 2.0 See the License for the specific language governing permissions and limitations under the License. - Source not required, however, respective source is provided: + Source not required, however, respective sources are provided: https://github.com/phhusson/vendor_lptools + https://android.googlesource.com/platform/system/extras/+/master/verity/fec/ httools_static: MIT @@ -119,25 +121,6 @@ httools_static: MIT Source not required, however, respective source is provided: https://github.com/capntrips/HashtreePatcher -fec: Apache License 2.0 - - Copyright (c) 2013-2015, The Android Open Source Project - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. - - Source not required, however, respective source is provided: - https://android.googlesource.com/platform/system/extras/+/refs/tags/android-12.1.0_r5/verity/fec/ - ## Optional Binary Licenses: @@ -163,7 +146,7 @@ boot_signer*.jar: Apache License 2.0 https://github.com/osm0sis/mkbootfs https://github.com/osm0sis/mkbootimg https://github.com/osm0sis/mkmtkhdr - https://android.googlesource.com/platform/system/extras/+/master + https://android.googlesource.com/platform/system/extras/+/master/verity/ flash_erase, nanddump, nandwrite (mtd-utils): GPLv2 dumpimage, mkimage (U-Boot): GPLv2+ diff --git a/AnyKernel3/META-INF/com/google/android/update-binary b/AnyKernel3/META-INF/com/google/android/update-binary index 07f78e70c74c..78cf12236986 100755 --- a/AnyKernel3/META-INF/com/google/android/update-binary +++ b/AnyKernel3/META-INF/com/google/android/update-binary @@ -38,6 +38,7 @@ find_slot() { [ "$slot" ] || slot=$($BB grep -o 'androidboot.slot=.*$' /proc/cmdline | $BB cut -d\ -f1 | $BB cut -d= -f2); [ "$slot" ] && slot=_$slot; fi; + [ "$slot" == "normal" ] && unset slot; [ "$slot" ] && echo "$slot"; } setup_mountpoint() { @@ -66,7 +67,7 @@ mount_apex() { $BB unzip -qo $apex apex_payload.img -d /apex; $BB mv -f /apex/original_apex $dest.apex 2>/dev/null; $BB mv -f /apex/apex_payload.img $dest.img; - $BB mount -t ext4 -o ro,noatime $dest.img $dest 2>/dev/null; + $BB mount -t ext4 -o ro,noatime $dest.img $dest 2>/dev/null && echo "$dest (direct)" >&2; if [ $? != 0 ]; then while [ $num -lt 64 ]; do loop=/dev/block/loop$num; @@ -75,22 +76,24 @@ mount_apex() { num=$((num + 1)); $BB losetup $loop | $BB grep -q $dest.img && break; done; - $BB mount -t ext4 -o ro,loop,noatime $loop $dest; + $BB mount -t ext4 -o ro,loop,noatime $loop $dest && echo "$dest (loop)" >&2; if [ $? != 0 ]; then $BB losetup -d $loop 2>/dev/null; fi; fi; ;; - *) $BB mount -o bind $apex $dest;; + *) $BB mount -o bind $apex $dest && echo "$dest (bind)" >&2;; esac; done; for var in $($BB grep -o 'export .* /.*' /system_root/init.environ.rc | $BB awk '{ print $2 }'); do eval OLD_${var}=\$$var; done; $($BB grep -o 'export .* /.*' /system_root/init.environ.rc | $BB sed 's; /;=/;'); unset export; + $BB touch /apex/apexak3; } umount_apex() { - [ -d /apex ] || return 1; + [ -f /apex/apexak3 ] || return 1; + echo "Unmounting apex..." >&2; local dest loop var; for var in $($BB grep -o 'export .* /.*' /system_root/init.environ.rc 2>/dev/null | $BB awk '{ print $2 }'); do if [ "$(eval echo \$OLD_$var)" ]; then @@ -106,22 +109,23 @@ umount_apex() { [ "$loop" ] && $BB losetup -d $loop; done; [ -f /apex/apextmp ] && $BB umount /apex; - $BB rm -rf /apex 2>/dev/null; + $BB rm -rf /apex/apexak3 /apex 2>/dev/null; } mount_all() { local byname mount slot system; + echo "Mounting..." >&2; if ! is_mounted /cache; then - $BB mount /cache 2>/dev/null && UMOUNT_CACHE=1; + $BB mount /cache 2>/dev/null && echo "/cache" >&2 && UMOUNT_CACHE=1; fi; if ! is_mounted /data; then - $BB mount /data && UMOUNT_DATA=1; + $BB mount /data && echo "/data" >&2 && UMOUNT_DATA=1; fi; - (for mount in /vendor /product /system_ext /persist; do - $BB mount -o ro -t auto $mount; - done) 2>/dev/null; + for mount in /vendor /product /system_ext /persist; do + $BB mount -o ro -t auto $mount 2>/dev/null && echo "$mount (fstab)" >&2; + done; setup_mountpoint $ANDROID_ROOT; if ! is_mounted $ANDROID_ROOT; then - $BB mount -o ro -t auto $ANDROID_ROOT 2>/dev/null; + $BB mount -o ro -t auto $ANDROID_ROOT 2>/dev/null && echo "$ANDROID_ROOT (\$ANDROID_ROOT)" >&2; fi; byname=bootdevice/by-name; [ -d /dev/block/$byname ] || byname=$($BB find /dev/block/platform -type d -name by-name 2>/dev/null | $BB head -n1 | $BB cut -d/ -f4-); @@ -132,15 +136,15 @@ mount_all() { /system) if ! is_mounted /system && ! is_mounted /system_root; then setup_mountpoint /system_root; - $BB mount -o ro -t auto /system_root; + $BB mount -o ro -t auto /system_root && echo "/system_root (fstab)" >&2; elif [ -f /system/system/build.prop ]; then setup_mountpoint /system_root; - $BB mount --move /system /system_root; + $BB mount --move /system /system_root && echo "/system_root (moved)" >&2; fi; if [ $? != 0 ]; then ($BB umount /system; $BB umount -l /system) 2>/dev/null; - $BB mount -o ro -t auto /dev/block/$byname/system$slot /system_root; + $BB mount -o ro -t auto /dev/block/$byname/system$slot /system_root && echo "/system_root (direct)" >&2; fi; ;; esac; @@ -148,20 +152,22 @@ mount_all() { for mount in /vendor /product /system_ext; do if ! is_mounted $mount && [ -L /system$mount -o -L /system_root$system$mount ]; then setup_mountpoint $mount; - $BB mount -o ro -t auto /dev/block/$byname$mount$slot $mount; + $BB mount -o ro -t auto /dev/block/$byname$mount$slot $mount && echo "$mount (direct)" >&2; fi; done; if is_mounted /system_root; then mount_apex; - $BB mount -o bind /system_root$system /system; + $BB mount -o bind /system_root$system /system && echo "/system (bind)" >&2; fi; if ! is_mounted /persist && [ -e /dev/block/bootdevice/by-name/persist ]; then setup_mountpoint /persist; - $BB mount -o ro -t auto /dev/block/bootdevice/by-name/persist /persist; + $BB mount -o ro -t auto /dev/block/bootdevice/by-name/persist /persist && echo "/persist (direct)" >&2; fi; + echo " " >&2; } umount_all() { local mount; + echo "Unmounting..." >&2; (if [ ! -d /postinstall/tmp ]; then $BB umount /system; $BB umount -l /system; @@ -203,7 +209,7 @@ setup_env() { if [ ! "$(getprop 2>/dev/null)" ]; then getprop() { local propdir propfile propval; - for propdir in / /system_root /system /vendor /product /system_ext /odm; do + for propdir in / /system_root /system /vendor /product /product/etc /system_ext/etc /odm/etc; do for propfile in default.prop build.prop; do if [ "$propval" ]; then break 2; @@ -232,6 +238,7 @@ restore_env() { [ "$OLD_LD_PRE" ] && export LD_PRELOAD=$OLD_LD_PRE; [ "$OLD_LD_CFG" ] && export LD_CONFIG_FILE=$OLD_LD_CFG; unset OLD_LD_PATH OLD_LD_PRE OLD_LD_CFG; + $BB sleep 1; umount_all; [ -L /etc_link ] && $BB rm -rf /etc/*; (for dir in /etc /apex /system_root /system /vendor /product /system_ext /persist; do @@ -432,7 +439,7 @@ do_modules() { cd $AKHOME; } -show_progress 1.34 4; +show_progress 1.34 25; ui_print " "; cleanup; mkdir -p $AKHOME/bin; @@ -485,7 +492,7 @@ do_levelcheck; ui_print "Installing..."; CORE=$($BB grep -oE 'ak.*core.sh' anykernel.sh); [ -f tools/$CORE ] || $BB ln -s $AKHOME/tools/ak*-core.sh $AKHOME/tools/$CORE; -PATH="$AKHOME/bin:$PATH" home=$AKHOME $BB ash anykernel.sh $2; +PATH="$AKHOME/bin:$PATH" ZIPFILE="$3" home=$AKHOME $BB ash anykernel.sh $2; if [ $? != 0 ]; then abort; fi; @@ -493,10 +500,11 @@ fi; do_modules; debugging; +ui_print " "; restore_env; if [ "$(file_getprop anykernel.sh do.cleanup)" == 1 ]; then cleanup; fi; -ui_print " " " " "Done!"; +ui_print " " "Done!"; diff --git a/AnyKernel3/META-INF/com/google/android/updater-script b/AnyKernel3/META-INF/com/google/android/updater-script index ad31cce66b51..b22830466800 100644 --- a/AnyKernel3/META-INF/com/google/android/updater-script +++ b/AnyKernel3/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=20220608 +# AK_BASE_VERSION=20230208 diff --git a/AnyKernel3/README.md b/AnyKernel3/README.md index 8d7e22e9cd73..2f2383568eb4 100644 --- a/AnyKernel3/README.md +++ b/AnyKernel3/README.md @@ -27,6 +27,7 @@ supported.patchlevels=2019-07 - block=/dev/block/platform/omap/omap_hsmmc.0/by-name/boot; is_slot_device=0; ramdisk_compression=auto; +patch_vbmeta_flag=auto; ``` __do.devicecheck=1__ specified requires at least device.name1 to be present. This should match ro.product.device, ro.build.product, ro.product.vendor.device or ro.vendor.product.device from the build.prop files for your device. There is support for as many device.name# properties as needed. You may remove any empty ones that aren't being used. @@ -43,7 +44,7 @@ __supported.versions=__ will match against ro.build.version.release from the cur __supported.patchlevels=__ will match against ro.build.version.security_patch from the current ROM's build.prop. It can be set as a closed or open-ended range of dates in the format YYYY-MM, whitespace optional, e.g. `2019-04 - 2019-06`, `2019-04 -` or `- 2019-06` where the last two examples show setting a minimum and maximum, respectively. -`block=auto` instead of a direct block filepath enables detection of the device boot partition for use with broad, device non-specific zips. Also accepts specifically `boot`, `recovery` or `vendor_boot`. +`block=auto` instead of a direct block filepath enables detection of the device boot partition for use with broad, device non-specific zips. Also accepts any partition filename (from by-name), e.g. `boot`, `recovery` or `vendor_boot`. `is_slot_device=1` enables detection of the suffix for the active boot partition on slot-based devices and will add this to the end of the supplied `block=` path. Also accepts `auto` for use with broad, device non-specific zips. @@ -142,9 +143,9 @@ Optionally moving ARM builds to tools/arm and putting x86 builds in tools/x86 wi 1. Place final kernel build product, e.g. Image.gz-dtb or zImage to name a couple, in the zip root (any separate dt, dtb or recovery_dtbo, dtbo and/or vendor_dlkm should also go here for devices that require custom ones, each will fallback to the original if not included) -2. Place any required ramdisk files in /ramdisk (/vendor_ramdisk for simple multi-partition vendor_boot support) and module files in /modules (with the full path like /modules/system/lib/modules) +2. Place any required ramdisk files in /ramdisk (/vendor_ramdisk for simple multi-partition vendor_boot v3 support) and module files in /modules (with the full path like /modules/system/lib/modules) -3. Place any required patch files (generally partial files which go with AK3 file editing commands) in /patch (/vendor_patch for simple multi-partition vendor_boot support) +3. Place any required patch files (generally partial files which go with AK3 file editing commands) in /patch (/vendor_patch for simple multi-partition vendor_boot v3 support) 4. Modify the anykernel.sh to add your kernel's name, boot partition location, permissions for any added ramdisk files, and use methods for any required ramdisk modifications (optionally, also place banner and/or version files in the root to have these displayed during flash) diff --git a/AnyKernel3/banner b/AnyKernel3/banner index aa5b719fd7cf..3bff0e8378f6 100644 --- a/AnyKernel3/banner +++ b/AnyKernel3/banner @@ -1,16 +1,16 @@ - _ - | | - ___| |__ ___ _ __ _ __ _ _ - / __| '_ \ / _ \ '__| '__| | | | -| (__| | | | __/ | | | | |_| | - \___|_| |_|\___|_| |_| \__, | - __/ | - |___/ - __.--~~.,-.__ - `~-._.-(`-.__`-. - \ `~~` - .--./ \ - /# \ \.--. - \ / /# \ - '--' \ / + _ + | | + ___| |__ ___ _ __ _ __ _ _ + / __| '_ \ / _ \ '__| '__| | | | +| (__| | | | __/ | | | | |_| | + \___|_| |_|\___|_| |_| \__, | + __/ | + |___/ + __.--~~.,-.__ + `~-._.-(`-.__`-. + \ `~~` + .--./ \ + /# \ \.--. + \ / /# \ + '--' \ / '--' \ No newline at end of file diff --git a/AnyKernel3/tools/ak3-core.sh b/AnyKernel3/tools/ak3-core.sh index a64f2da95425..15c8c135df69 100755 --- a/AnyKernel3/tools/ak3-core.sh +++ b/AnyKernel3/tools/ak3-core.sh @@ -328,7 +328,7 @@ flash_boot() { fi; $bin/magiskboot hexpatch kernel 736B69705F696E697472616D667300 77616E745F696E697472616D667300; if [ "$(file_getprop $home/anykernel.sh do.systemless)" == 1 ]; then - strings kernel | grep -E -m1 'Linux version.*#' > $home/vertmp; + strings kernel 2>/dev/null | grep -E -m1 'Linux version.*#' > $home/vertmp; fi; if [ "$comp" ]; then $bin/magiskboot compress=$comp kernel kernel.$comp; @@ -415,7 +415,7 @@ flash_boot() { # flash_generic flash_generic() { - local avb avbblock file flags img imgblock isro path; + local avb avbblock avbpath file flags img imgblock isro isunmounted path; cd $home; for file in $1 $1.img; do @@ -426,7 +426,7 @@ flash_generic() { done; if [ "$img" -a ! -f ${1}_flashed ]; then - for path in /dev/block/bootdevice/by-name /dev/block/mapper; do + for path in /dev/block/mapper /dev/block/by-name /dev/block/bootdevice/by-name; do for file in $1 $1$slot; do if [ -e $path/$file ]; then imgblock=$path/$file; @@ -437,6 +437,9 @@ flash_generic() { if [ ! "$imgblock" ]; then abort "$1 partition could not be found. Aborting..."; fi; + if [ ! "$no_block_display" ]; then + ui_print " " "$imgblock"; + fi; if [ "$path" == "/dev/block/mapper" ]; then avb=$($bin/httools_static avb $1); [ $? == 0 ] || abort "Failed to parse fstab entry for $1. Aborting..."; @@ -444,35 +447,45 @@ flash_generic() { flags=$($bin/httools_static disable-flags); [ $? == 0 ] || abort "Failed to parse top-level vbmeta. Aborting..."; if [ "$flags" == "enabled" ]; then - [ "$1" == "vendor_dlkm" -a "$avb" == "vbmeta" ] || abort "Unable to patch $1 on $avb. Aborting ..."; - ui_print " " "dm-verity detected! Patching vbmeta..."; - for path in /dev/block/bootdevice/by-name /dev/block/mapper; do + ui_print " " "dm-verity detected! Patching $avb..."; + for avbpath in /dev/block/mapper /dev/block/by-name /dev/block/bootdevice/by-name; do for file in $avb $avb$slot; do - if [ -e $path/$file ]; then - avbblock=$path/$file; + if [ -e $avbpath/$file ]; then + avbblock=$avbpath/$file; break 2; fi; done; done; cd $bin; - $bin/httools_static patch $home/$img $avbblock || abort "Failed to patch $1 on $avb. Aborting..."; + $bin/httools_static patch $1 $home/$img $avbblock || abort "Failed to patch $1 on $avb. Aborting..."; cd $home; fi fi + echo "Removing any existing $1_ak3..." >&2; $bin/lptools_static remove $1_ak3; - $bin/lptools_static create $1_ak3 $(wc -c < $img) || abort "Creating $1_ak3 failed. Aborting..."; - $bin/lptools_static unmap $1_ak3 || abort "Unmapping $1_ak3 failed. Aborting..."; - $bin/lptools_static map $1_ak3 || abort "Mapping $1_ak3 failed. Aborting..."; - $bin/lptools_static replace $1_ak3 $1$slot || abort "Replacing $1$slot failed. Aborting..."; - imgblock=/dev/block/mapper/$1_ak3; + echo "Attempting to create $1_ak3..." >&2; + if $bin/lptools_static create $1_ak3 $(wc -c < $img); then + echo "Replacing $1$slot with $1_ak3..." >&2; + $bin/lptools_static unmap $1_ak3 || abort "Unmapping $1_ak3 failed. Aborting..."; + $bin/lptools_static map $1_ak3 || abort "Mapping $1_ak3 failed. Aborting..."; + $bin/lptools_static replace $1_ak3 $1$slot || abort "Replacing $1$slot failed. Aborting..."; + imgblock=/dev/block/mapper/$1_ak3; + else + echo "Creating $1_ak3 failed. Attempting to resize $1$slot..." >&2; + $bin/httools_static umount $1 || abort "Unmounting $1 failed. Aborting..."; + if [ -e $path/$1-verity ]; then + $bin/lptools_static unmap $1-verity || abort "Unmapping $1-verity failed. Aborting..."; + fi + $bin/lptools_static unmap $1$slot || abort "Unmapping $1$slot failed. Aborting..."; + $bin/lptools_static resize $1$slot $(wc -c < $img) || abort "Resizing $1$slot failed. Aborting..."; + $bin/lptools_static map $1$slot || abort "Mapping $1$slot failed. Aborting..."; + isunmounted=1; + fi elif [ "$(wc -c < $img)" -gt "$(wc -c < $imgblock)" ]; then abort "New $1 image larger than $1 partition. Aborting..."; fi; isro=$(blockdev --getro $imgblock 2>/dev/null); blockdev --setrw $imgblock 2>/dev/null; - if [ ! "$no_block_display" ]; then - ui_print " " "$imgblock"; - fi; if [ -f "$bin/flash_erase" -a -f "$bin/nandwrite" ]; then $bin/flash_erase $imgblock 0 0; $bin/nandwrite -p $imgblock $img; @@ -488,6 +501,9 @@ flash_generic() { if [ "$isro" != 0 ]; then blockdev --setro $imgblock 2>/dev/null; fi; + if [ "$isunmounted" -a "$path" == "/dev/block/mapper" ]; then + $bin/httools_static mount $1 || abort "Mounting $1 failed. Aborting..."; + fi touch ${1}_flashed; fi; } @@ -500,6 +516,7 @@ write_boot() { repack_ramdisk; flash_boot; flash_generic vendor_boot; # temporary until hdr v4 can be unpacked/repacked fully by magiskboot + flash_generic vendor_kernel_boot; # temporary until hdr v4 can be unpacked/repacked fully by magiskboot flash_generic vendor_dlkm; flash_generic dtbo; } @@ -669,10 +686,10 @@ patch_cmdline() { if ! grep -q "$1" $cmdfile; then cmdtmp=$(cat $cmdfile); echo "$cmdtmp $2" > $cmdfile; - sed -i -e 's; *; ;g' -e 's;[ \t]*$;;' $cmdfile; + sed -i -e 's;^[ \t]*;;' -e 's; *; ;g' -e 's;[ \t]*$;;' $cmdfile; else match=$(grep -o "$1.*$" $cmdfile | cut -d\ -f1); - sed -i -e "s;${match};${2};" -e 's; *; ;g' -e 's;[ \t]*$;;' $cmdfile; + sed -i -e "s;${match};${2};" -e 's;^[ \t]*;;' -e 's; *; ;g' -e 's;[ \t]*$;;' $cmdfile; fi; if [ -f "$home/cmdtmp" ]; then sed -i "s|^cmdline=.*|cmdline=$(cat $cmdfile)|" $split_img/header; @@ -736,7 +753,7 @@ reset_ak() { # setup_ak setup_ak() { - local blockfiles parttype name part mtdmount mtdpart mtdname target; + local blockfiles plistboot plistinit plistreco parttype name part mtdmount mtdpart mtdname target; # slot detection enabled by is_slot_device=1 or auto (from anykernel.sh) case $is_slot_device in @@ -748,6 +765,7 @@ setup_ak() { [ "$slot" ] || slot=$(grep -o 'androidboot.slot=.*$' /proc/cmdline | cut -d\ -f1 | cut -d= -f2); [ "$slot" ] && slot=_$slot; fi; + [ "$slot" == "normal" ] && unset slot; if [ "$slot" ]; then if [ -d /postinstall/tmp -a ! "$slot_select" ]; then slot_select=inactive; @@ -772,8 +790,20 @@ setup_ak() { rm -f modules/system/lib/modules/placeholder patch/placeholder ramdisk/placeholder; rmdir -p modules patch ramdisk 2>/dev/null; - # automate simple multi-partition setup for boot_img_hdr_v3 + vendor_boot - if [ -e "/dev/block/bootdevice/by-name/vendor_boot$slot" -a ! -f vendor_setup ] && [ -f dtb -o -d vendor_ramdisk -o -d vendor_patch ]; then + # automate simple multi-partition setup for hdr_v4 boot + init_boot + vendor_kernel_boot (for dtb only until magiskboot supports hdr v4 vendor_ramdisk unpack/repack) + if [ -e "/dev/block/bootdevice/by-name/init_boot$slot" -a ! -f init_v4_setup ] && [ -f dtb -o -d vendor_ramdisk -o -d vendor_patch ]; then + echo "Setting up for simple automatic init_boot flashing..." >&2; + (mkdir boot-files; + mv -f Image* boot-files; + mkdir init_boot-files; + mv -f ramdisk patch init_boot-files; + mkdir vendor_kernel_boot-files; + mv -f dtb vendor_kernel_boot-files; + mv -f vendor_ramdisk vendor_kernel_boot-files/ramdisk; + mv -f vendor_patch vendor_kernel_boot-files/patch) 2>/dev/null; + touch init_v4_setup; + # automate simple multi-partition setup for hdr_v3+ boot + vendor_boot with dtb/dlkm (for v3 only until magiskboot supports hdr v4 vendor_ramdisk unpack/repack) + elif [ -e "/dev/block/bootdevice/by-name/vendor_boot$slot" -a ! -f vendor_v3_setup ] && [ -f dtb -o -d vendor_ramdisk -o -d vendor_patch ]; then echo "Setting up for simple automatic vendor_boot flashing..." >&2; (mkdir boot-files; mv -f Image* ramdisk patch boot-files; @@ -781,7 +811,7 @@ setup_ak() { mv -f dtb vendor_boot-files; mv -f vendor_ramdisk vendor_boot-files/ramdisk; mv -f vendor_patch vendor_boot-files/patch) 2>/dev/null; - touch vendor_setup; + touch vendor_v3_setup; fi; # allow multi-partition ramdisk modifying configurations (using reset_ak) @@ -795,16 +825,26 @@ setup_ak() { touch $blockfiles/current; fi; - # target block partition detection enabled by block=boot recovery or auto (from anykernel.sh) - case $block in - auto|"") block=boot;; - esac; + # target block partition detection enabled by block= or auto (from anykernel.sh) case $block in - boot|recovery|vendor_boot) + /dev/*) + if [ "$slot" ] && [ -e "$block$slot" ]; then + target=$block$slot; + elif [ -e "$block" ]; then + target=$block; + fi; + ;; + *) + # maintain brief lists of historic matching partition type names for boot, recovery and init_boot/ramdisk + plistboot="boot BOOT LNX android_boot bootimg KERN-A kernel KERNEL"; + plistreco="recovery RECOVERY SOS android_recovery recovery_ramdisk"; + plistinit="init_boot ramdisk"; case $block in - boot) parttype="ramdisk init_boot boot BOOT LNX android_boot bootimg KERN-A kernel KERNEL";; - recovery) parttype="ramdisk_recovery recovery RECOVERY SOS android_recovery";; - vendor_boot) parttype="vendor_boot";; + auto) parttype="$plistinit $plistboot";; + boot|kernel) parttype=$plistboot;; + recovery|recovery_ramdisk) parttype=$plistreco;; + init_boot|ramdisk) parttype=$plistinit;; + *) parttype=$block;; esac; for name in $parttype; do for part in $name$slot $name; do @@ -816,9 +856,7 @@ setup_ak() { else abort "Unable to determine mtd $block partition. Aborting..."; fi; - if [ -e /dev/mtd/$mtdname ]; then - target=/dev/mtd/$mtdname; - fi; + [ -e /dev/mtd/$mtdname ] && target=/dev/mtd/$mtdname; elif [ -e /dev/block/by-name/$part ]; then target=/dev/block/by-name/$part; elif [ -e /dev/block/bootdevice/by-name/$part ]; then @@ -833,18 +871,13 @@ setup_ak() { [ "$target" ] && break 2; done; done; - if [ "$target" ]; then - block=$(ls $target 2>/dev/null); - else - abort "Unable to determine $block partition. Aborting..."; - fi; - ;; - *) - if [ "$slot" ]; then - [ -e "$block$slot" ] && block=$block$slot; - fi; ;; esac; + if [ "$target" ]; then + block=$(ls $target 2>/dev/null); + else + abort "Unable to determine $block partition. Aborting..."; + fi; if [ ! "$no_block_display" ]; then ui_print "$block"; fi; diff --git a/AnyKernel3/tools/httools_static b/AnyKernel3/tools/httools_static index cbb02bd9eb72..574fcfb9c311 100755 Binary files a/AnyKernel3/tools/httools_static and b/AnyKernel3/tools/httools_static differ diff --git a/AnyKernel3/tools/lptools_static b/AnyKernel3/tools/lptools_static index b7556c4eb649..7e17e9873d81 100755 Binary files a/AnyKernel3/tools/lptools_static and b/AnyKernel3/tools/lptools_static differ diff --git a/AnyKernel3/tools/magiskboot b/AnyKernel3/tools/magiskboot index 1b96e4ea1e94..2eca159bf958 100755 Binary files a/AnyKernel3/tools/magiskboot and b/AnyKernel3/tools/magiskboot differ diff --git a/AnyKernel3/tools/magiskpolicy b/AnyKernel3/tools/magiskpolicy index ff52a8dd9162..67cc10eb19cb 100755 Binary files a/AnyKernel3/tools/magiskpolicy and b/AnyKernel3/tools/magiskpolicy differ