[bootloader] Mimic openSUSE's efibootmgr calls
This commit is contained in:
parent
dad3669eae
commit
fdda1ef840
@ -20,9 +20,13 @@ timeout: "10"
|
|||||||
|
|
||||||
# GRUB 2 binary names and boot directory
|
# GRUB 2 binary names and boot directory
|
||||||
# Some distributions (e.g. Fedora) use grub2-* (resp. /boot/grub2/) names.
|
# 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"
|
grubInstall: "grub-install"
|
||||||
grubMkconfig: "grub-mkconfig"
|
grubMkconfig: "grub-mkconfig"
|
||||||
grubCfg: "/boot/grub/grub.cfg"
|
grubCfg: "/boot/grub/grub.cfg"
|
||||||
|
grubProbe: "/usr/sbin/grub2-probe"
|
||||||
|
|
||||||
# Optionally set the bootloader ID to use for EFI. This is passed to
|
# Optionally set the bootloader ID to use for EFI. This is passed to
|
||||||
# grub-install --bootloader-id.
|
# grub-install --bootloader-id.
|
||||||
|
@ -323,13 +323,40 @@ def install_secureboot(efi_directory):
|
|||||||
else:
|
else:
|
||||||
install_efi_bin = "shim.efi"
|
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([
|
subprocess.call([
|
||||||
"/usr/sbin/efibootmgr",
|
"/usr/sbin/efibootmgr",
|
||||||
"-c",
|
"-c",
|
||||||
"-w",
|
"-w",
|
||||||
"-L", efi_bootloader_id,
|
"-L", efi_bootloader_id,
|
||||||
"-d", path, # TODO
|
"-d", efi_disk,
|
||||||
"-p", num, # TODO
|
"-p", efi_partititon_number,
|
||||||
"-l", install_efi_directory + "/" + install_efi_bin])
|
"-l", install_efi_directory + "/" + install_efi_bin])
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user