[bootloader] Mimic openSUSE's efibootmgr calls

This commit is contained in:
Adriaan de Groot 2018-05-28 11:47:47 -04:00
parent dad3669eae
commit fdda1ef840
2 changed files with 33 additions and 2 deletions

View File

@ -20,9 +20,13 @@ timeout: "10"
# GRUB 2 binary names and boot directory
# Some distributions (e.g. Fedora) use grub2-* (resp. /boot/grub2/) names.
# These names are also used when using sb-shim, since that needs some
# GRUB functionality (notably grub-probe) to work.
#
grubInstall: "grub-install"
grubMkconfig: "grub-mkconfig"
grubCfg: "/boot/grub/grub.cfg"
grubProbe: "/usr/sbin/grub2-probe"
# Optionally set the bootloader ID to use for EFI. This is passed to
# grub-install --bootloader-id.

View File

@ -323,13 +323,40 @@ def install_secureboot(efi_directory):
else:
install_efi_bin = "shim.efi"
# Copied, roughly, from openSUSE's install script,
# and pythonified. *disk* is something like /dev/sda,
# while *drive* may return "(disk/dev/sda,gpt1)" ..
# we're interested in the numbers in the second part
# of that tuple.
efi_drive = subprocess.check_output([
libcalamares.job.configuration["grubProbe"],
"-t", "drive", "--device-map=", install_efi_directory])
efi_disk = subprocess.check_output([
libcalamares.job.configuration["grubProbe"],
"-t", "disk", "--device-map=", install_efi_directory])
efi_drive_partition = efi_drive.replace("(","").replace(")","").split(",")[1]
# Get the first run of digits from the partition
efi_partititon_number = None
c = 0
start = None
while c < len(efi_drive_partition):
if efi_drive_partition[c].isdigit() and start is None:
start = c
if not efi_drive_partition[c].isdigit() and start is not None:
efi_drive_number = efi_drive_partition[start:c]
break
c += 1
if efi_partititon_number is None:
raise ValueError("No partition number found for %s" % install_efi_directory)
subprocess.call([
"/usr/sbin/efibootmgr",
"-c",
"-w",
"-L", efi_bootloader_id,
"-d", path, # TODO
"-p", num, # TODO
"-d", efi_disk,
"-p", efi_partititon_number,
"-l", install_efi_directory + "/" + install_efi_bin])