[bootloader] Refactor efi-next-boot

- move the setup-next-boot code to a function on its own
- credit to Gaë
This commit is contained in:
Adriaan de Groot 2020-05-06 13:31:02 +02:00
parent 7c633f1253
commit 9e344f50a7
2 changed files with 22 additions and 15 deletions

View file

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