Refactor `_add_grub_bootloader()` installation (#1968)
* Refactor `_add_grub_bootloader()` installation * Remove whitespace
This commit is contained in:
parent
f4a6d11373
commit
b9d962bec2
|
|
@ -876,45 +876,43 @@ class Installer:
|
||||||
|
|
||||||
info(f"GRUB boot partition: {boot_partition.dev_path}")
|
info(f"GRUB boot partition: {boot_partition.dev_path}")
|
||||||
|
|
||||||
|
command = [
|
||||||
|
'/usr/bin/arch-chroot',
|
||||||
|
str(self.target),
|
||||||
|
'grub-install',
|
||||||
|
'--debug'
|
||||||
|
]
|
||||||
|
|
||||||
if SysInfo.has_uefi():
|
if SysInfo.has_uefi():
|
||||||
self.pacman.strap('efibootmgr') # TODO: Do we need? Yes, but remove from minimal_installation() instead?
|
self.pacman.strap('efibootmgr') # TODO: Do we need? Yes, but remove from minimal_installation() instead?
|
||||||
|
|
||||||
|
add_options = [
|
||||||
|
'--target=x86_64-efi',
|
||||||
|
f'--efi-directory={boot_partition.mountpoint}',
|
||||||
|
'--bootloader-id=GRUB',
|
||||||
|
'--removable'
|
||||||
|
]
|
||||||
|
|
||||||
|
command.extend(add_options)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
SysCommand(
|
SysCommand(command, peek_output=True)
|
||||||
f'/usr/bin/arch-chroot {self.target} grub-install '
|
|
||||||
f'--debug '
|
|
||||||
f'--target=x86_64-efi '
|
|
||||||
f'--efi-directory={boot_partition.mountpoint} '
|
|
||||||
f'--bootloader-id=GRUB '
|
|
||||||
f'--removable',
|
|
||||||
peek_output=True
|
|
||||||
)
|
|
||||||
except SysCallError:
|
except SysCallError:
|
||||||
try:
|
try:
|
||||||
SysCommand(
|
SysCommand(command, peek_output=True)
|
||||||
f'/usr/bin/arch-chroot {self.target} '
|
|
||||||
f'grub-install '
|
|
||||||
f'--debug '
|
|
||||||
f'--target=x86_64-efi '
|
|
||||||
f'--efi-directory={boot_partition.mountpoint} '
|
|
||||||
f'--bootloader-id=GRUB '
|
|
||||||
f'--removable',
|
|
||||||
peek_output=True
|
|
||||||
)
|
|
||||||
except SysCallError as err:
|
except SysCallError as err:
|
||||||
raise DiskError(f"Could not install GRUB to {self.target}{boot_partition.mountpoint}: {err}")
|
raise DiskError(f"Could not install GRUB to {self.target}{boot_partition.mountpoint}: {err}")
|
||||||
else:
|
else:
|
||||||
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)
|
||||||
|
|
||||||
try:
|
add_options = [
|
||||||
cmd = f'/usr/bin/arch-chroot' \
|
'--target=i386-pc',
|
||||||
f' {self.target}' \
|
'--recheck',
|
||||||
f' grub-install' \
|
str(parent_dev_path)
|
||||||
f' --debug' \
|
]
|
||||||
f' --target=i386-pc' \
|
|
||||||
f' --recheck {parent_dev_path}'
|
|
||||||
|
|
||||||
SysCommand(cmd, peek_output=True)
|
try:
|
||||||
|
SysCommand(command + add_options, peek_output=True)
|
||||||
except SysCallError as err:
|
except SysCallError as err:
|
||||||
raise DiskError(f"Failed to install GRUB boot on {boot_partition.dev_path}: {err}")
|
raise DiskError(f"Failed to install GRUB boot on {boot_partition.dev_path}: {err}")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue