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 <maddock.evan@vivaldi.net>
This commit is contained in:
Evan Maddock 2023-11-26 17:27:57 -05:00
parent 26236fe63a
commit e13dbc621a
No known key found for this signature in database

View File

@ -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)