From a56e4eae5a051f691ed499790a457eec51a1700e Mon Sep 17 00:00:00 2001 From: Oliver Smith Date: Sun, 7 Jun 2020 08:50:28 +0200 Subject: [PATCH] install_system_image: add root_label parameter (MR 1946) Prepare for on-device installer, so it can use something other than "pmOS_root" as label. --- pmb/install/_install.py | 5 +++-- pmb/install/format.py | 10 ++++++---- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/pmb/install/_install.py b/pmb/install/_install.py index b8d3915f..e9af7c72 100644 --- a/pmb/install/_install.py +++ b/pmb/install/_install.py @@ -373,11 +373,12 @@ def sanity_check_sdcard(device): raise RuntimeError("{} is read-only, is the sdcard locked?".format(device)) -def install_system_image(args, size_reserve, suffix): +def install_system_image(args, size_reserve, suffix, root_label="pmOS_root"): """ :param size_reserve: empty partition between root and boot in MiB (pma#463) :param suffix: the chroot suffix, where the rootfs that will be installed on the device has been created (e.g. "rootfs_qemu-amd64") + :param root_label: label of the root partition (e.g. "pmOS_root") """ # Partition and fill image/sdcard logging.info("*** (3/5) PREPARE INSTALL BLOCKDEVICE ***") @@ -392,7 +393,7 @@ def install_system_image(args, size_reserve, suffix): root_id = 3 if size_reserve else 2 pmb.install.partitions_mount(args, root_id) - pmb.install.format(args, size_reserve) + pmb.install.format(args, size_reserve, root_label) # Just copy all the files logging.info("*** (4/5) FILL INSTALL BLOCKDEVICE ***") diff --git a/pmb/install/format.py b/pmb/install/format.py index a6e00105..acfa5767 100644 --- a/pmb/install/format.py +++ b/pmb/install/format.py @@ -43,9 +43,10 @@ def format_and_mount_root(args, device): raise RuntimeError("Failed to open cryptdevice!") -def format_and_mount_pm_crypt(args, device): +def format_and_mount_pm_crypt(args, device, root_label): """ :param device: root partition on install block device (e.g. /dev/installp2) + :param root_label: label of the root partition (e.g. "pmOS_root") """ # Block device if args.full_disk_encryption: @@ -58,7 +59,7 @@ def format_and_mount_pm_crypt(args, device): # When changing the options of mkfs.ext4, also change them in the # recovery zip code (see 'grep -r mkfs\.ext4')! mkfs_ext4_args = ["mkfs.ext4", "-O", "^metadata_csum", "-F", - "-q", "-L", "pmOS_root"] + "-q", "-L", root_label] # When we don't know the file system size before hand like # with non-block devices, we need to explicitely set a number of @@ -75,11 +76,12 @@ def format_and_mount_pm_crypt(args, device): pmb.chroot.root(args, ["mount", device, mountpoint]) -def format(args, size_reserve): +def format(args, size_reserve, root_label): """ :param size_reserve: empty partition between root and boot in MiB (pma#463) + :param root_label: label of the root partition (e.g. "pmOS_root") """ root_dev = "/dev/installp3" if size_reserve else "/dev/installp2" format_and_mount_root(args, root_dev) - format_and_mount_pm_crypt(args, root_dev) + format_and_mount_pm_crypt(args, root_dev, root_label) format_and_mount_boot(args)