From 5c6f2dd0d9427bd5608120a7a872322fdeae0256 Mon Sep 17 00:00:00 2001 From: Caleb Connolly Date: Mon, 16 Oct 2023 23:59:44 +0100 Subject: [PATCH] postmarketos-initramfs: fix partition cmdline priority (MR 4487) The "pmos_[br]oot(_uuid)?" kernel cmdline args can be used to specify how to mount the root and boot partitions. During a previous rework, the behaviour of these was made inconsistent (becoming dependent on the order they were specified on the cmdline). Undo the previous "optimisation" by splitting them back out into two FOR loops, where the _uuid variants take precedence. --- main/postmarketos-initramfs/init_functions.sh | 44 ++++++++++++------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/main/postmarketos-initramfs/init_functions.sh b/main/postmarketos-initramfs/init_functions.sh index 0ec3e98a2..3506530fe 100644 --- a/main/postmarketos-initramfs/init_functions.sh +++ b/main/postmarketos-initramfs/init_functions.sh @@ -181,15 +181,20 @@ find_root_partition() { break fi fi - if ! [ "$x" = "${x#pmos_root=}" ]; then - path="${x#pmos_root=}" - if [ -e "$path" ]; then - PMOS_ROOT="$path" - break - fi - fi done + if [ -z "$PMOS_ROOT" ]; then + for x in $(cat /proc/cmdline); do + if ! [ "$x" = "${x#pmos_root=}" ]; then + path="${x#pmos_root=}" + if [ -e "$path" ]; then + PMOS_ROOT="$path" + break + fi + fi + done + fi + # On-device installer: before postmarketOS is installed, # we want to use the installer partition as root. It is the # partition behind pmos_root. pmos_root will either point to @@ -244,18 +249,25 @@ find_boot_partition() { PMOS_BOOT="$path" break fi - elif ! [ "$x" = "${x#pmos_boot=}" ]; then - # If the boot partition is specified explicitly - # then we need to check if it's a valid path, and - # fall back if not... - path="${x#pmos_boot=}" - if [ -e "$path" ]; then - PMOS_BOOT="$path" - break - fi fi done + if [ -z "$PMOS_BOOT" ]; then + # shellcheck disable=SC2013 + for x in $(cat /proc/cmdline); do + if ! [ "$x" = "${x#pmos_boot=}" ]; then + # If the boot partition is specified explicitly + # then we need to check if it's a valid path, and + # fall back if not... + path="${x#pmos_boot=}" + if [ -e "$path" ]; then + PMOS_BOOT="$path" + break + fi + fi + done + fi + # Finally fall back to findfs by label if [ -z "$PMOS_BOOT" ]; then # * "pmOS_i_boot" installer boot partition (fits 11 chars for fat32)