From 082486d6fadbbdf1bbe586d31746bb0a51b26275 Mon Sep 17 00:00:00 2001 From: Christopher Roy Bratusek Date: Wed, 5 May 2021 14:27:58 +0200 Subject: [PATCH] when searching system/vendor partitions look for app/vnr aswell --- CommonInstaller | 47 ++++++++++-------- patcher/CommonPatcher | 49 +++++++++++-------- systest/SysTest | 49 +++++++++++-------- .../META-INF/com/google/android/update-binary | 47 ++++++++++-------- 4 files changed, 110 insertions(+), 82 deletions(-) diff --git a/CommonInstaller b/CommonInstaller index 72f15c4..ad0a2f0 100644 --- a/CommonInstaller +++ b/CommonInstaller @@ -236,31 +236,38 @@ toupper() { find_block () { local block partname devname device - block=${1}${SLOT} - device=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${block} | head -n 1) + for block in "${@}"; do + block=${block}${SLOT} + device=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${block} | head -n 1) - if [ -n "$device" ]; then - readlink -f "$device" - return 0 - fi - - for uevent in /sys/dev/block/*/uevent; do - partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent}) - devname=$(awk -F= '/DEVNAME/{print $2}' ${uevent}) - if [ "$(toupper ${block})" = "$(toupper ${partname})" ]; then - echo /dev/block/${devname} + if [ -n "$device" ]; then + readlink -f "$device" return 0 fi done - device=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${block} | head -n 1) - if [ -n "$device" ]; then - readlink -f "$device" - return 0 - fi + for block in "${@}"; do + block=${block}${SLOT} + for uevent in /sys/dev/block/*/uevent; do + partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent}) + devname=$(awk -F= '/DEVNAME/{print $2}' ${uevent}) + if [ "$(toupper ${block})" = "$(toupper ${partname})" ]; then + echo /dev/block/${devname} + return 0 + fi + done + done + + for block in "${@}"; do + block=${block}${SLOT} + device=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${block} | head -n 1) + if [ -n "$device" ]; then + readlink -f "$device" + return 0 + fi + done return 1 - } mount_partitions () { @@ -280,7 +287,7 @@ mount_partitions () { mount -o bind /dev/urandom /dev/random - SYSTEM_BLOCK=$(find_block system) + SYSTEM_BLOCK=$(find_block system app) decho " INFO: #5 [SYSTEM_BLOCK] ${SYSTEM_BLOCK}" [ -z "${SYSTEM_BLOCK}" ] && error "failed to detect block device for /system" @@ -306,7 +313,7 @@ mount_partitions () { mount -o bind /system_root/system /system fi - VENDOR_BLOCK=$(find_block vendor) + VENDOR_BLOCK=$(find_block vendor vnr) decho " INFO: #7 [VENDOR_BLOCK] ${VENDOR_BLOCK}" [ -z "${VENDOR_BLOCK}" ] && error "failed to detect block device for /vendor" diff --git a/patcher/CommonPatcher b/patcher/CommonPatcher index 78f1a75..3393b7c 100644 --- a/patcher/CommonPatcher +++ b/patcher/CommonPatcher @@ -101,33 +101,40 @@ toupper() { } find_block () { - local block tmp partname devname device + local block partname devname device - block=${1}${SLOT} - device=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${block} | head -n 1) + for block in "${@}"; do + block=${block}${SLOT} + device=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${block} | head -n 1) - if [ ! -z ${device} ]; then - readlink -f ${device} - return 0 - fi - - for uevent in /sys/dev/block/*/uevent; do - partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent}) - devname=$(awk -F= '/DEVNAME/{print $2}' ${uevent}) - if [ "$(toupper ${block})" = "$(toupper ${partname})" ]; then - echo /dev/block/${devname} + if [ -n "$device" ]; then + readlink -f "$device" return 0 fi done - device=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${block} | head -n 1) - if [ ! -z ${device} ]; then - readlink -f ${device} - return 0 - fi + for block in "${@}"; do + block=${block}${SLOT} + for uevent in /sys/dev/block/*/uevent; do + partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent}) + devname=$(awk -F= '/DEVNAME/{print $2}' ${uevent}) + if [ "$(toupper ${block})" = "$(toupper ${partname})" ]; then + echo /dev/block/${devname} + return 0 + fi + done + done + + for block in "${@}"; do + block=${block}${SLOT} + device=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${block} | head -n 1) + if [ -n "$device" ]; then + readlink -f "$device" + return 0 + fi + done return 1 - } mount_partitions () { @@ -147,7 +154,7 @@ mount_partitions () { mount -o bind /dev/urandom /dev/random - SYSTEM_BLOCK=$(find_block system) + SYSTEM_BLOCK=$(find_block system app) echo " INFO: #5 [SYSTEM_BLOCK] ${SYSTEM_BLOCK}" if is_mounted /system_root; then @@ -171,7 +178,7 @@ mount_partitions () { mount -o bind /system_root/system /system fi - VENDOR_BLOCK=$(find_block vendor) + VENDOR_BLOCK=$(find_block vendor vnr) echo " INFO: #7 [VENDOR_BLOCK] ${VENDOR_BLOCK}" ! is_mounted /vendor && mount -o ro /vendor diff --git a/systest/SysTest b/systest/SysTest index f12694d..f491f13 100644 --- a/systest/SysTest +++ b/systest/SysTest @@ -91,33 +91,40 @@ toupper() { } find_block () { - local block tmp partname devname device + local block partname devname device - block=${1}${SLOT} - device=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${block} | head -n 1) + for block in "${@}"; do + block=${block}${SLOT} + device=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${block} | head -n 1) - if [ ! -z ${device} ]; then - readlink -f ${device} - return 0 - fi - - for uevent in /sys/dev/block/*/uevent; do - partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent}) - devname=$(awk -F= '/DEVNAME/{print $2}' ${uevent}) - if [ "$(toupper ${block})" = "$(toupper ${partname})" ]; then - echo /dev/block/${devname} + if [ -n "$device" ]; then + readlink -f "$device" return 0 fi done - device=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${block} | head -n 1) - if [ ! -z ${device} ]; then - readlink -f ${device} - return 0 - fi + for block in "${@}"; do + block=${block}${SLOT} + for uevent in /sys/dev/block/*/uevent; do + partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent}) + devname=$(awk -F= '/DEVNAME/{print $2}' ${uevent}) + if [ "$(toupper ${block})" = "$(toupper ${partname})" ]; then + echo /dev/block/${devname} + return 0 + fi + done + done + + for block in "${@}"; do + block=${block}${SLOT} + device=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${block} | head -n 1) + if [ -n "$device" ]; then + readlink -f "$device" + return 0 + fi + done return 1 - } mount_partitions () { @@ -132,8 +139,8 @@ mount_partitions () { fi [ -z ${SLOT} ] && DEVICE_AB=FALSE || DEVICE_AB=TR - SYSTEM_BLOCK=$(find_block system) - VENDOR_BLOCK=$(find_block vendor) + SYSTEM_BLOCK=$(find_block system app) + VENDOR_BLOCK=$(find_block vendor vnr) if ${BOOTMODE}; then build_props=$(find /system /system_root /vendor -type f -name build.prop) diff --git a/uninstaller/META-INF/com/google/android/update-binary b/uninstaller/META-INF/com/google/android/update-binary index a33f851..f682b09 100644 --- a/uninstaller/META-INF/com/google/android/update-binary +++ b/uninstaller/META-INF/com/google/android/update-binary @@ -104,31 +104,38 @@ toupper() { find_block () { local block partname devname device - block=${1}${SLOT} - device=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${block} | head -n 1) + for block in "${@}"; do + block=${block}${SLOT} + device=$(find /dev/block \( -type b -o -type c -o -type l \) -name ${block} | head -n 1) - if [ -n "$device" ]; then - readlink -f "$device" - return 0 - fi - - for uevent in /sys/dev/block/*/uevent; do - partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent}) - devname=$(awk -F= '/DEVNAME/{print $2}' ${uevent}) - if [ "$(toupper ${block})" = "$(toupper ${partname})" ]; then - echo /dev/block/${devname} + if [ -n "$device" ]; then + readlink -f "$device" return 0 fi done - device=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${block} | head -n 1) - if [ -n "$device" ]; then - readlink -f "$device" - return 0 - fi + for block in "${@}"; do + block=${block}${SLOT} + for uevent in /sys/dev/block/*/uevent; do + partname=$(awk -F= '/PARTNAME/{print $2}' ${uevent}) + devname=$(awk -F= '/DEVNAME/{print $2}' ${uevent}) + if [ "$(toupper ${block})" = "$(toupper ${partname})" ]; then + echo /dev/block/${devname} + return 0 + fi + done + done + + for block in "${@}"; do + block=${block}${SLOT} + device=$(find /dev \( -type b -o -type c -o -type l \) -maxdepth 1 -iname ${block} | head -n 1) + if [ -n "$device" ]; then + readlink -f "$device" + return 0 + fi + done return 1 - } mount_partitions () { @@ -148,7 +155,7 @@ mount_partitions () { mount -o bind /dev/urandom /dev/random - SYSTEM_BLOCK=$(find_block system) + SYSTEM_BLOCK=$(find_block system app) echo " INFO: #5 [SYSTEM_BLOCK] ${SYSTEM_BLOCK}" if is_mounted /system_root; then @@ -172,7 +179,7 @@ mount_partitions () { mount -o bind /system_root/system /system fi - VENDOR_BLOCK=$(find_block vendor) + VENDOR_BLOCK=$(find_block vendor vnr) echo " INFO: #7 [VENDOR_BLOCK] ${VENDOR_BLOCK}" ! is_mounted /vendor && mount -o ro /vendor