From 5eff8ef878ea788f3917e41d4d7e4b6a2deda95f Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Mar 03 2019 07:31:18 +0000 Subject: Simplify the partition detection Two levels of conditioning are unnecessary. Also, broken: this wouldn't detect the partitions correctly on devices that prepend 'n' to the partitions on devices other than mmcblk, such as loop devices. --- diff --git a/arm-image-installer b/arm-image-installer index c17d1f4..0bbec5a 100755 --- a/arm-image-installer +++ b/arm-image-installer @@ -276,48 +276,37 @@ get_lvm_name () { fi } - - - -sleep 1 -case $MEDIA in - "/dev/mmcblk"*) - if [ -e "$MEDIA"p5 ]; then - export FIRMPART="${MEDIA}p1" - BOOTPART="${MEDIA}p2" - ROOTPART="${MEDIA}p5" - PARTNUM=5 - elif [ -e "$MEDIA"p4 ]; then - export FIRMPART="${MEDIA}p1" - BOOTPART="${MEDIA}p2" - ROOTPART="${MEDIA}p4" - PARTNUM=4 - else - export FIRMPART="${MEDIA}p1" - BOOTPART="${MEDIA}p2" - ROOTPART="${MEDIA}p3" - PARTNUM=3 - fi - ;; - *) - if [ -e "$MEDIA"5 ]; then - export FIRMPART="${MEDIA}1" - BOOTPART="${MEDIA}2" - ROOTPART="${MEDIA}5" - PARTNUM=5 - elif [ -e "$MEDIA"4 ]; then - export FIRMPART="${MEDIA}1" - BOOTPART="${MEDIA}2" - ROOTPART="${MEDIA}4" - PARTNUM=4 - else - export FIRMPART="${MEDIA}1" - BOOTPART="${MEDIA}2" - ROOTPART="${MEDIA}3" - PARTNUM=3 - fi - ;; -esac +if [ -e "$MEDIA"p5 ]; then + export FIRMPART="${MEDIA}p1" + BOOTPART="${MEDIA}p2" + ROOTPART="${MEDIA}p5" + PARTNUM=5 +elif [ -e "$MEDIA"p4 ]; then + export FIRMPART="${MEDIA}p1" + BOOTPART="${MEDIA}p2" + ROOTPART="${MEDIA}p4" + PARTNUM=4 +elif [ -e "$MEDIA"p3 ]; then + export FIRMPART="${MEDIA}p1" + BOOTPART="${MEDIA}p2" + ROOTPART="${MEDIA}p3" + PARTNUM=3 +elif [ -e "$MEDIA"5 ]; then + export FIRMPART="${MEDIA}1" + BOOTPART="${MEDIA}2" + ROOTPART="${MEDIA}5" + PARTNUM=5 +elif [ -e "$MEDIA"4 ]; then + export FIRMPART="${MEDIA}1" + BOOTPART="${MEDIA}2" + ROOTPART="${MEDIA}4" + PARTNUM=4 +else + export FIRMPART="${MEDIA}1" + BOOTPART="${MEDIA}2" + ROOTPART="${MEDIA}3" + PARTNUM=3 +fi # resize root filesystem before mounting if [ "$RESIZEFS" != "" ]; then