Refactor `_add_efistub_bootloader()` cmdline (#2059)

This commit is contained in:
codefiles 2023-09-17 03:17:48 -04:00 committed by GitHub
parent b9d962bec2
commit 15e52b7768
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 26 deletions

View File

@ -1047,27 +1047,22 @@ TIMEOUT=5
# points towards the same disk and/or partition. # points towards the same disk and/or partition.
# And in which case we should do some clean up. # And in which case we should do some clean up.
for kernel in self.kernels: microcode = []
# Setup the firmware entry
label = f'Arch Linux ({kernel})'
loader = f"/vmlinuz-{kernel}"
kernel_parameters = []
if not SysInfo.is_vm(): if not SysInfo.is_vm():
vendor = SysInfo.cpu_vendor() vendor = SysInfo.cpu_vendor()
if vendor == "AuthenticAMD": if vendor == "AuthenticAMD":
kernel_parameters.append("initrd=\\amd-ucode.img") microcode.append("initrd=\\amd-ucode.img")
elif vendor == "GenuineIntel": elif vendor == "GenuineIntel":
kernel_parameters.append("initrd=\\intel-ucode.img") microcode.append("initrd=\\intel-ucode.img")
else: else:
debug(f"Unknown CPU vendor '{vendor}' detected. Archinstall won't add any ucode to firmware boot entry.") debug(f"Unknown CPU vendor '{vendor}' detected. Archinstall won't add any ucode to firmware boot entry.")
kernel_parameters.append(f"initrd=\\initramfs-{kernel}.img")
# blkid doesn't trigger on loopback devices really well, # blkid doesn't trigger on loopback devices really well,
# so we'll use the old manual method until we get that sorted out. # so we'll use the old manual method until we get that sorted out.
kernel_parameters = []
if root_partition in self._disk_encryption.partitions: if root_partition in self._disk_encryption.partitions:
# TODO: We need to detect if the encrypted device is a whole disk encryption, # TODO: We need to detect if the encrypted device is a whole disk encryption,
# or simply a partition encryption. Right now we assume it's a partition (and we always have) # or simply a partition encryption. Right now we assume it's a partition (and we always have)
@ -1079,13 +1074,24 @@ TIMEOUT=5
parent_dev_path = disk.device_handler.get_parent_device_path(boot_partition.safe_dev_path) parent_dev_path = disk.device_handler.get_parent_device_path(boot_partition.safe_dev_path)
for kernel in self.kernels:
# Setup the firmware entry
label = f'Arch Linux ({kernel})'
loader = f"/vmlinuz-{kernel}"
cmdline = []
cmdline.extend(microcode)
cmdline.append(f"initrd=\\initramfs-{kernel}.img")
cmdline.extend(kernel_parameters)
cmd = f'efibootmgr ' \ cmd = f'efibootmgr ' \
f'--disk {parent_dev_path} ' \ f'--disk {parent_dev_path} ' \
f'--part {boot_partition.safe_dev_path} ' \ f'--part {boot_partition.safe_dev_path} ' \
f'--create ' \ f'--create ' \
f'--label "{label}" ' \ f'--label "{label}" ' \
f'--loader {loader} ' \ f'--loader {loader} ' \
f'--unicode \'{" ".join(kernel_parameters)}\' ' \ f'--unicode \'{" ".join(cmdline)}\' ' \
f'--verbose' f'--verbose'
SysCommand(cmd) SysCommand(cmd)