diff --git a/CHANGES b/CHANGES index a541d7380..f430a7910 100644 --- a/CHANGES +++ b/CHANGES @@ -16,7 +16,8 @@ This release contains contributions from (alphabetically by first name): - The *productWallpaper* setting is documented and works. (Thanks Bill) ## Modules ## - - No module changes yet + - The *bootloader* module can force a UEFI-based machine to boot into + the newly-installed system. #1394 (Thanks Gaƫl) # 3.2.23 (2020-04-17) # diff --git a/src/modules/bootloader/main.py b/src/modules/bootloader/main.py index 786b5e7da..674484527 100644 --- a/src/modules/bootloader/main.py +++ b/src/modules/bootloader/main.py @@ -237,6 +237,25 @@ def efi_word_size(): return efi_bitness +def efi_boot_next(): + """ + Tell EFI to definitely boot into the just-installed + system next time. + """ + boot_mgr = libcalamares.job.configuration["efiBootMgr"] + boot_entry = None + efi_bootvars = subprocess.check_output([boot_mgr], text=True) + for line in efi_bootvars.split('\n'): + if not line: + continue + words = line.split() + if len(words) >= 2 and words[0] == "BootOrder:": + boot_entry = words[1].split(',')[0] + break + if boot_entry: + subprocess.call([boot_mgr, "-n", boot_entry]) + + def install_systemd_boot(efi_directory): """ Installs systemd-boot as bootloader for EFI setups. @@ -403,20 +422,7 @@ def install_secureboot(efi_directory): "-p", efi_partition_number, "-l", install_efi_directory + "/" + install_efi_bin]) - boot_entry = None - efi_bootvars = subprocess.check_output( - [libcalamares.job.configuration["efiBootMgr"]], text=True) - for line in efi_bootvars.split('\n'): - if not line: - continue - words = line.split() - if len(words) >= 2 and words[0] == "BootOrder:": - boot_entry = words[1].split(',')[0] - break - if boot_entry: - subprocess.call([ - libcalamares.job.configuration["efiBootMgr"], - "-n", boot_entry]) + efi_boot_next() # The input file /etc/default/grub should already be filled out by the # grubcfg job module.