pmb.install: add boot label arg to several funcs (MR 2008)

Allow to set a different label for the boot partition than "pmOS_boot".
This commit is contained in:
Oliver Smith 2020-12-18 22:14:13 +01:00 committed by Martijn Braam
parent 7d1c8d29df
commit b07ff9444c
No known key found for this signature in database
GPG Key ID: C4280ACB000B060F
2 changed files with 17 additions and 8 deletions

View File

@ -445,13 +445,15 @@ def sanity_check_ondev_version(args):
def install_system_image(args, size_reserve, suffix, step, steps,
root_label="pmOS_root", split=False, sdcard=None):
boot_label="pmOS_boot", root_label="pmOS_root",
split=False, sdcard=None):
"""
: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 step: next installation step
:param steps: total installation steps
:param boot_label: label of the boot partition (e.g. "pmOS_boot")
:param root_label: label of the root partition (e.g. "pmOS_root")
:param split: create separate images for boot and root partitions
:param sdcard: path to sdcard device (e.g. /dev/mmcblk0) or None
@ -469,7 +471,7 @@ def install_system_image(args, size_reserve, suffix, step, steps,
root_id = 3 if size_reserve else 2
pmb.install.partitions_mount(args, root_id, sdcard)
pmb.install.format(args, size_reserve, root_label, sdcard)
pmb.install.format(args, size_reserve, boot_label, root_label, sdcard)
# Just copy all the files
logging.info(f"*** ({step + 1}/{steps}) FILL INSTALL BLOCKDEVICE ***")

View File

@ -5,18 +5,24 @@ import logging
import pmb.chroot
def format_and_mount_boot(args):
def format_and_mount_boot(args, boot_label):
"""
:param boot_label: label of the root partition (e.g. "pmOS_boot")
"""
mountpoint = "/mnt/install/boot"
device = "/dev/installp1"
filesystem = args.deviceinfo["boot_filesystem"] or "ext2"
logging.info("(native) format " + device + " (boot, " + filesystem + "), mount to " +
mountpoint)
if filesystem == "fat16":
pmb.chroot.root(args, ["mkfs.fat", "-F", "16", "-n", "pmOS_boot", device])
pmb.chroot.root(args, ["mkfs.fat", "-F", "16", "-n", boot_label,
device])
elif filesystem == "fat32":
pmb.chroot.root(args, ["mkfs.fat", "-F", "32", "-n", "pmOS_boot", device])
pmb.chroot.root(args, ["mkfs.fat", "-F", "32", "-n", boot_label,
device])
elif filesystem == "ext2":
pmb.chroot.root(args, ["mkfs.ext2", "-F", "-q", "-L", "pmOS_boot", device])
pmb.chroot.root(args, ["mkfs.ext2", "-F", "-q", "-L", boot_label,
device])
else:
raise RuntimeError("Filesystem " + filesystem + " is not supported!")
pmb.chroot.root(args, ["mkdir", "-p", mountpoint])
@ -79,9 +85,10 @@ def format_and_mount_root(args, device, root_label, sdcard):
pmb.chroot.root(args, ["mount", device, mountpoint])
def format(args, size_reserve, root_label, sdcard):
def format(args, size_reserve, boot_label, root_label, sdcard):
"""
:param size_reserve: empty partition between root and boot in MiB (pma#463)
:param boot_label: label of the boot partition (e.g. "pmOS_boot")
:param root_label: label of the root partition (e.g. "pmOS_root")
:param sdcard: path to sdcard device (e.g. /dev/mmcblk0) or None
"""
@ -92,4 +99,4 @@ def format(args, size_reserve, root_label, sdcard):
root_dev = "/dev/mapper/pm_crypt"
format_and_mount_root(args, root_dev, root_label, sdcard)
format_and_mount_boot(args)
format_and_mount_boot(args, boot_label)