From e13dbc621a1abcaf211e6241bc3682af96ef00da Mon Sep 17 00:00:00 2001 From: Evan Maddock Date: Sun, 26 Nov 2023 17:27:57 -0500 Subject: [PATCH 1/2] bootloader: Add clr-boot-manager support This adds support for Clear Boot Manager to handle the bootloader installation and configuration. When this option is selected in the bootloader.conf, clr-boot-manager will be used to install the bootloader (systemd-boot on EFI systems). If the system is non-EFI, Grub must be installed first, because clr-boot-manager doesn't do that, despite it running grub_mkconfig after. Signed-off-by: Evan Maddock --- src/modules/bootloader/main.py | 36 +++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index a72a4fe9e..fc5d3bce8 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -502,6 +502,35 @@ def get_kernels(installation_root_path): return kernel_list +def install_clr_boot_manager(): + """ + Installs clr-boot-manager as the bootloader for EFI systems + """ + libcalamares.utils.debug("Bootloader: clr-boot-manager") + + installation_root_path = libcalamares.globalstorage.value("rootMountPoint") + kernel_dir = os.path.join(installation_root_path, "etc", "kernel", "cmdline.d") + kernel_resume_file = os.path.join(kernel_dir, "10_resume.conf") + + partitions = libcalamares.globalstorage.value("partitions") + swap_uuid = "" + + # Get the UUID of the swap partition, if present + for partition in partitions: + if partition["fs"] == "linuxswap" and not partition.get("claimed", None): + continue + has_luks = "luksMapperName" in partition + if partition["fs"] == "linuxswap" and not has_luks: + swap_uuid = partition["uuid"] + + # Write out the resume.conf for clr-boot-manager + if swap_uuid != "": + with open(kernel_resume_file, "w") as resume_file: + resume_file.write("resume={}\n".format(swap_uuid)) + + check_target_env_call(["clr-boot-manager", "update"]) + + def install_systemd_boot(efi_directory): """ Installs systemd-boot as bootloader for EFI setups. @@ -855,7 +884,12 @@ def prepare_bootloader(fw_type): efi_directory = libcalamares.globalstorage.value("efiSystemPartition") - if efi_boot_loader == "systemd-boot" and fw_type == "efi": + if efi_boot_loader == "clr-boot-manager": + if fw_type != "efi": + # Grub has to be installed first on non-EFI systems + install_grub(efi_directory, fw_type) + install_clr_boot_manager() + elif efi_boot_loader == "systemd-boot" and fw_type == "efi": install_systemd_boot(efi_directory) elif efi_boot_loader == "sb-shim" and fw_type == "efi": install_secureboot(efi_directory) From 7a4d03e2c13ac14eb488705519e7cc7ff566ea00 Mon Sep 17 00:00:00 2001 From: Evan Maddock Date: Mon, 27 Nov 2023 10:47:51 -0500 Subject: [PATCH 2/2] bootloader: Write all kernel params to the kernel cmdline file for CBM Signed-off-by: Evan Maddock --- src/modules/bootloader/main.py | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index fc5d3bce8..189902839 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -509,24 +509,17 @@ def install_clr_boot_manager(): libcalamares.utils.debug("Bootloader: clr-boot-manager") installation_root_path = libcalamares.globalstorage.value("rootMountPoint") - kernel_dir = os.path.join(installation_root_path, "etc", "kernel", "cmdline.d") - kernel_resume_file = os.path.join(kernel_dir, "10_resume.conf") + kernel_config_path = os.path.join(installation_root_path, "etc", "kernel") + os.makedirs(kernel_config_path, exist_ok=True) + cmdline_path = os.path.join(kernel_config_path, "cmdline") - partitions = libcalamares.globalstorage.value("partitions") - swap_uuid = "" + # Get the kernel params + uuid = get_uuid() + kernel_params = " ".join(get_kernel_params(uuid)) - # Get the UUID of the swap partition, if present - for partition in partitions: - if partition["fs"] == "linuxswap" and not partition.get("claimed", None): - continue - has_luks = "luksMapperName" in partition - if partition["fs"] == "linuxswap" and not has_luks: - swap_uuid = partition["uuid"] - - # Write out the resume.conf for clr-boot-manager - if swap_uuid != "": - with open(kernel_resume_file, "w") as resume_file: - resume_file.write("resume={}\n".format(swap_uuid)) + # Write out the cmdline file for clr-boot-manager + with open(cmdline_path, "w") as cmdline_file: + cmdline_file.write(kernel_params) check_target_env_call(["clr-boot-manager", "update"])