From 142dec4618cfbbffc1b561f5e7fd2fc162530d67 Mon Sep 17 00:00:00 2001 From: Markus Hoffrogge Date: Mon, 20 Mar 2023 00:44:25 +0100 Subject: [PATCH] Fix $sduuid being overlapped by a probable emmc device existing - if $emmccheck is not empty, then exclude this from the lookups for $sdblkid - simplified $sduuid assignment within a single line closes AR-1611 --- packages/bsp/common/usr/sbin/armbian-install | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/packages/bsp/common/usr/sbin/armbian-install b/packages/bsp/common/usr/sbin/armbian-install index 527421eee3..c681fee067 100755 --- a/packages/bsp/common/usr/sbin/armbian-install +++ b/packages/bsp/common/usr/sbin/armbian-install @@ -63,13 +63,14 @@ mtdcheck=$(grep 'mtdblock' /proc/partitions | awk '{print $NF}' | xargs) # SD card boot part - to be considered more than one entry on various platforms # UUID=xxx... -# 1 - Lookup mmc devices excluding the mmc device probably providing the current root partition: -sdblkid=$(blkid -o full /dev/mmcblk*p1 | grep -v "$root_partition_device") -# 2 - If there is nothing, then lookup any mmc partition matching /dev/mmcblk*p1: -[[ -z $sdblkid ]] && sdblkid=$(blkid -o full /dev/mmcblk*p1) -# 3 - Extract the UUID from $sdblkid via regex: -sduuid=$(echo "$sdblkid" | sed -nE 's/^.*[[:space:]]UUID="([0-9a-zA-Z-]*)".*/\1/p') -[[ -n $sduuid ]] && sduuid="UUID=${sduuid}" +# 1 - Lookup mmc devices excluding the mmc device probably providing the current root partition as well as a probable emmc device found above: +[[ -z $emmccheck ]] && sdblkid=$(blkid -o full /dev/mmcblk*p1 | grep -v "$root_partition_device") +[[ -n $emmccheck ]] && sdblkid=$(blkid -o full /dev/mmcblk*p1 | grep -v "$root_partition_device" | grep -v "$emmccheck") +# 2 - If there is nothing, then lookup any mmc partition matching /dev/mmcblk*p1 excluding probable emmc device found above +[[ -z $sdblkid && -z $emmccheck ]] && sdblkid=$(blkid -o full /dev/mmcblk*p1) +[[ -z $sdblkid && -n $emmccheck ]] && sdblkid=$(blkid -o full /dev/mmcblk*p1 | grep -v "$emmccheck") +# 3 - Extract the UUID= from $sdblkid via regex without " - as e.g.: UUID=2e1d1509-a8fc-4f8b-8a51-88fb8593f8d6 +sduuid=$(echo "$sdblkid" | sed -nE 's/^.*[[:space:]](UUID="[0-9a-zA-Z-]*").*/\1/p' | tr -d '"') #recognize EFI [[ -d /sys/firmware/efi ]] && DEVICE_TYPE="uefi" @@ -855,7 +856,7 @@ main() if [[ -n $emmccheck ]]; then umount_device "$emmccheck" format_emmc "$emmccheck" - else + else umount_device '/dev/nand' format_nand fi