[bootloader] Refactor efi-next-boot

- move the setup-next-boot code to a function on its own
- credit to Gaë
main
Adriaan de Groot 5 years ago
parent 7c633f1253
commit 9e344f50a7

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

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

Loading…
Cancel
Save