diff --git a/main/postmarketos-mkinitfs/APKBUILD b/main/postmarketos-mkinitfs/APKBUILD index 574205701..5e108ee67 100644 --- a/main/postmarketos-mkinitfs/APKBUILD +++ b/main/postmarketos-mkinitfs/APKBUILD @@ -1,5 +1,5 @@ pkgname=postmarketos-mkinitfs -pkgver=0.7.21 +pkgver=0.8.0 pkgrel=1 pkgdesc="Tool to generate initramfs images for postmarketOS" url="https://postmarketos.org" @@ -24,5 +24,5 @@ package() { mkdir -p "$pkgdir/etc/postmarketos-mkinitfs/hooks/" } sha512sums="8be7f29394f8cd4e1c4b93f018f6314350f7e37e20d242c97284c1b112a106f882318a101bc0c70b391590b969023901580c677ee9f869850e90e69171a44e80 init.sh.in -8b8c304c6962cfd1284e5631e32102d49da835bebf6d9d599c20e50849e16783aa1ade9f8d721160877e9bc1ae8d10da5e4588338d487eca5c4bfef62b7833fc init_functions.sh +44571b62e4d326355fa7d96add9a9115a89db3b6ce12c17aa4b0d5bd02d63d5b5d3152305af18795938bc9479d37b44e9a14268efa28a8c114c77ed498a7d65b init_functions.sh 3f918f8b5967b73e507c2ddf36dccc24fee98298f05ca23e22605400de95137f8877e09769616e7db388557c645fb45c03e1e6b5bab815ec9f853c318f0431f1 mkinitfs.sh" diff --git a/main/postmarketos-mkinitfs/init_functions.sh b/main/postmarketos-mkinitfs/init_functions.sh index 09dd9b3fe..a39c83952 100644 --- a/main/postmarketos-mkinitfs/init_functions.sh +++ b/main/postmarketos-mkinitfs/init_functions.sh @@ -102,19 +102,30 @@ find_root_partition() { # mount_subpartitions() must get executed before calling # find_root_partition(), so partitions from b) also get found. - # Try partitions in /dev/mapper and /dev/dm-* first - for id in pmOS_root crypto_LUKS; do - for path in /dev/mapper /dev/dm; do - DEVICE="$(blkid | grep "$path" | grep "$id" \ - | cut -d ":" -f 1)" - [ -z "$DEVICE" ] || break 2 - done + # Short circuit all autodetection logic if pmos_root= is supplied + # on the kernel cmdline + # shellcheck disable=SC2013 + for x in $(cat /proc/cmdline); do + [ "$x" = "${x#pmos_root=}" ] && continue + DEVICE="${x#pmos_root=}" done + # Try partitions in /dev/mapper and /dev/dm-* first + if [ -z "$DEVICE" ]; then + for id in pmOS_root crypto_LUKS; do + for path in /dev/mapper /dev/dm; do + DEVICE="$(blkid | grep "$path" | grep "$id" \ + | cut -d ":" -f 1 | head -n 1)" + [ -z "$DEVICE" ] || break 2 + done + done + fi + # Then try all devices if [ -z "$DEVICE" ]; then for id in pmOS_root crypto_LUKS; do - DEVICE="$(blkid | grep "$id" | cut -d ":" -f 1)" + DEVICE="$(blkid | grep "$id" | cut -d ":" -f 1 \ + | head -n 1)" [ -z "$DEVICE" ] || break done fi @@ -122,6 +133,12 @@ find_root_partition() { } find_boot_partition() { + # shellcheck disable=SC2013 + for x in $(cat /proc/cmdline); do + [ "$x" = "${x#pmos_boot=}" ] && continue + echo "${x#pmos_boot=}" + return + done findfs LABEL="pmOS_boot" }