From e8c76175f699b40357a229cbb98d0a7f0dcac2df Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Fri, 18 Dec 2020 22:36:42 +0100 Subject: [PATCH] main/postmarketos-mkinitfs: add pmOS_inst_boot (MR 1820) Find partitions with the label "pmOS_inst_boot" too, and prefer using them as boot partition over ones with label "pmOS_boot". (I'd use "pmOS_install_boot", but there is a character limit in the label.) Without this, the initramfs may choose the wrong boot partition if postmarketOS is available once as install OS (on device installer) on the SD card and once on the eMMC (installed). I just had this problem with QEMU when simulating the install from SD to eMMC use case with pmbootstrap qemu --second-storage. The pmOS initramfs scripts would detect the previously created eMMC boot partition as the proper one and mount it. It would boot into the right root partition, because that already has a different label (pmOS_install instead of pmOS_root), but because the wrong boot partition is already mounted, during the install it would not be possible to run mkfs on it. --- main/postmarketos-mkinitfs/APKBUILD | 4 ++-- main/postmarketos-mkinitfs/init_functions.sh | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/main/postmarketos-mkinitfs/APKBUILD b/main/postmarketos-mkinitfs/APKBUILD index 20972de00..a328c52d4 100644 --- a/main/postmarketos-mkinitfs/APKBUILD +++ b/main/postmarketos-mkinitfs/APKBUILD @@ -1,6 +1,6 @@ # Maintainer: Oliver Smith pkgname=postmarketos-mkinitfs -pkgver=0.20 +pkgver=0.21 pkgrel=0 pkgdesc="Tool to generate initramfs images for postmarketOS" url="https://postmarketos.org" @@ -55,7 +55,7 @@ check() { sha512sums="5037cb7285bb7c0c40ca9e6df332d882ef9a8b379756c785f921e062dab1b7e7f3139d00897f69323a916d709ced4297fea8cbd3a13ebae575b873ec9e2cbfae 00-default.modules bafd06286594102b8b3b126c3ae0a77a97f004ab804f03426154310c5107a1acaf3636bdba92626333adfe4fb0df32ff42c6d8d9e7adf35f6da620c6e14407a1 init.sh.in -e4b5bb7206a4a8f99a23414d6830ccf6ecaf2990ca4923842e99fa14dc50a0a4ae88e0368129b423f9e7e7b446f25b641ad629b7aa08682f269aed7a234762cb init_functions.sh +7e44c39393587e73d69533eb58362245bcb6cdb28a91eadd7878af54831b0c0ab264e8e9984b138e68b207d1f7544adab2b64b6ec68b4f528ea1273819670210 init_functions.sh dfc01ee0547ea88b7aa45a005e842b636e9e19bbf1705f3dad53a66d57af7c5c513c092b5469a06d9b00322e56a4d25f1b47e4c5324aafa99f5291679968d1f1 mkinitfs.sh 6a034e52e7e0d2eb4db632d1a08a47e58ccfc82780e3d1fbc08759ae0c7a1c7c6a222ad91fe346c45d82bec4487cc9c4b71adad96061865153c0e98e1e8e1c37 mkinitfs_functions.sh c7a3c33daeb12b33ac72207191941c4d634f15c22958273b52af381a70ebaba1d3a9299483f0c447d9e66c560151fe7b9588bb4bbef2c8914f83185984ee4622 mkinitfs_test.sh" diff --git a/main/postmarketos-mkinitfs/init_functions.sh b/main/postmarketos-mkinitfs/init_functions.sh index 362c4ca2a..79566964e 100644 --- a/main/postmarketos-mkinitfs/init_functions.sh +++ b/main/postmarketos-mkinitfs/init_functions.sh @@ -60,7 +60,7 @@ setup_mdev() { mount_subpartitions() { # Do not create subpartition mappings if pmOS_boot # already exists (e.g. installed on an sdcard) - blkid |grep -q "pmOS_boot" && return + [ -n "$(find_boot_partition)" ] && return attempt_count=0 echo "Trying to mount subpartitions for 10 seconds..." while [ -z "$(find_boot_partition)" ]; do @@ -74,7 +74,7 @@ mount_subpartitions() { # Ensure that this was the *correct* subpartition # Some devices have mmc partitions that appear to have # subpartitions, but aren't our subpartition. - if blkid | grep -q "pmOS_boot"; then + if [ -n "$(find_boot_partition)" ]; then break fi kpartx -d "$partition" @@ -161,7 +161,7 @@ find_boot_partition() { echo "${x#pmos_boot=}" return done - findfs LABEL="pmOS_boot" + findfs LABEL="pmOS_inst_boot" || findfs LABEL="pmOS_boot" } # $1: path