find_boot_image: keep symlink

This commit is contained in:
vvb2060 2024-08-13 02:03:03 +08:00 committed by John Wu
parent 821a6c6954
commit ab04c6ab39

View File

@ -207,7 +207,7 @@ find_block() {
for BLOCK in "$@"; do for BLOCK in "$@"; do
DEVICE=$(find /dev/block \( -type b -o -type c -o -type l \) -iname $BLOCK | head -n 1) 2>/dev/null DEVICE=$(find /dev/block \( -type b -o -type c -o -type l \) -iname $BLOCK | head -n 1) 2>/dev/null
if [ ! -z $DEVICE ]; then if [ ! -z $DEVICE ]; then
readlink -f $DEVICE echo $DEVICE
return 0 return 0
fi fi
done done
@ -226,7 +226,7 @@ find_block() {
for DEV in "$@"; do for DEV in "$@"; do
DEVICE=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname $DEV | head -n 1) 2>/dev/null DEVICE=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname $DEV | head -n 1) 2>/dev/null
if [ ! -z $DEVICE ]; then if [ ! -z $DEVICE ]; then
readlink -f $DEVICE echo $DEVICE
return 0 return 0
fi fi
done done
@ -371,13 +371,13 @@ find_boot_image() {
BOOTIMAGE= BOOTIMAGE=
if $RECOVERYMODE; then if $RECOVERYMODE; then
BOOTIMAGE=$(find_block "recovery$SLOT" "sos") BOOTIMAGE=$(find_block "recovery$SLOT" "sos")
elif [ -L "/dev/block/by-name/init_boot$SLOT" ] && uname -r | grep -vq "android12-"; then elif [ -e "/dev/block/by-name/init_boot$SLOT" ] && uname -r | grep -vq "android12-"; then
# init_boot is only used with GKI 13+. It is possible that some devices with init_boot # init_boot is only used with GKI 13+. It is possible that some devices with init_boot
# partition still uses Android 12 GKI, so we need to explicitly detect that scenario. # partition still uses Android 12 GKI, so we need to explicitly detect that scenario.
BOOTIMAGE=$(readlink -f "/dev/block/by-name/init_boot$SLOT") BOOTIMAGE="/dev/block/by-name/init_boot$SLOT"
elif [ -L "/dev/block/by-name/boot$SLOT" ]; then elif [ -e "/dev/block/by-name/boot$SLOT" ]; then
# Standard location since AOSP Android 10+ # Standard location since AOSP Android 10+
BOOTIMAGE=$(readlink -f "/dev/block/by-name/boot$SLOT") BOOTIMAGE="/dev/block/by-name/boot$SLOT"
elif [ -n "$SLOT" ]; then elif [ -n "$SLOT" ]; then
# Fallback for A/B devices running < Android 10 # Fallback for A/B devices running < Android 10
BOOTIMAGE=$(find_block "ramdisk$SLOT" "boot$SLOT") BOOTIMAGE=$(find_block "ramdisk$SLOT" "boot$SLOT")