Skip to content

Commit d836ab0

Browse files
authored
Extend validate_bootloader_layout with UEFI-dependent checks (#4474)
* Extend validate_bootloader_layout with UEFI-dependent checks Add is_uefi parameter and three new validations: Systemd-boot, Efistub and rEFInd require UEFI; Efistub additionally requires a FAT boot partition. Move the rEFInd UEFI-only check out of GlobalMenu so guided.py and Installer silent-install paths get the same coverage. * Encapsulate UEFI-only flag in Bootloader enum Replace module-level _UEFI_ONLY_BOOTLOADERS tuple with an is_uefi_only() method on the Bootloader enum, mirroring the existing has_uki_support() / has_removable_support() pattern. * Drop is_uefi parameter from validate_bootloader_layout The UEFI flag is a constant system fact for the run, so the validator retrieves it via SysInfo.has_uefi() directly instead of having every caller pass it in. Updates all three call sites in global_menu.py, installer.py and guided.py, and removes the now-unused SysInfo import from guided.py.
1 parent 3c4c87b commit d836ab0

3 files changed

Lines changed: 34 additions & 9 deletions

File tree

archinstall/lib/bootloader/utils.py

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
from enum import Enum, auto
33
from pathlib import Path
44

5+
from archinstall.lib.hardware import SysInfo
56
from archinstall.lib.models.bootloader import Bootloader, BootloaderConfiguration
67
from archinstall.lib.models.device import DiskLayoutConfiguration
78

89

910
class BootloaderValidationFailureKind(Enum):
1011
LimineNonFatBoot = auto()
1112
LimineLayout = auto()
13+
BootloaderRequiresUefi = auto()
14+
EfistubNonFatBoot = auto()
1215

1316

1417
@dataclass(frozen=True)
@@ -29,12 +32,32 @@ def validate_bootloader_layout(
2932
if not (bootloader_config and disk_config):
3033
return None
3134

32-
if bootloader_config.bootloader == Bootloader.Limine:
33-
boot_part = next(
34-
(p for m in disk_config.device_modifications if (p := m.get_boot_partition())),
35-
None,
35+
bootloader = bootloader_config.bootloader
36+
37+
if bootloader == Bootloader.NO_BOOTLOADER:
38+
return None
39+
40+
if bootloader.is_uefi_only() and not SysInfo.has_uefi():
41+
return BootloaderValidationFailure(
42+
kind=BootloaderValidationFailureKind.BootloaderRequiresUefi,
43+
description=f'{bootloader.value} requires a UEFI system.',
3644
)
3745

46+
boot_part = next(
47+
(p for m in disk_config.device_modifications if (p := m.get_boot_partition())),
48+
None,
49+
)
50+
51+
if bootloader == Bootloader.Efistub:
52+
# The UEFI firmware reads the kernel directly from the boot partition,
53+
# which must be FAT.
54+
if boot_part and (boot_part.fs_type is None or not boot_part.fs_type.is_fat()):
55+
return BootloaderValidationFailure(
56+
kind=BootloaderValidationFailureKind.EfistubNonFatBoot,
57+
description='Efistub does not support booting with a non-FAT boot partition.',
58+
)
59+
60+
if bootloader == Bootloader.Limine:
3861
# Limine reads its config and kernels from the boot partition, which
3962
# must be FAT.
4063
if boot_part and (boot_part.fs_type is None or not boot_part.fs_type.is_fat()):

archinstall/lib/global_menu.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -461,8 +461,6 @@ def _validate_bootloader(self) -> str | None:
461461
if not bootloader_config or bootloader_config.bootloader == Bootloader.NO_BOOTLOADER:
462462
return None
463463

464-
bootloader = bootloader_config.bootloader
465-
466464
if disk_config := self._item_group.find_by_key('disk_config').value:
467465
for layout in disk_config.device_modifications:
468466
if root_partition := layout.get_root_partition():
@@ -490,9 +488,6 @@ def _validate_bootloader(self) -> str | None:
490488
if efi_partition.fs_type is None or not efi_partition.fs_type.is_fat():
491489
return 'ESP must be formatted as a FAT filesystem'
492490

493-
if bootloader == Bootloader.Refind and not self._uefi:
494-
return 'rEFInd can only be used on UEFI systems'
495-
496491
if failure := validate_bootloader_layout(bootloader_config, disk_config):
497492
return failure.description
498493

archinstall/lib/models/bootloader.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ def has_removable_support(self) -> bool:
2525
case _:
2626
return False
2727

28+
def is_uefi_only(self) -> bool:
29+
match self:
30+
case Bootloader.Systemd | Bootloader.Efistub | Bootloader.Refind:
31+
return True
32+
case _:
33+
return False
34+
2835
def json(self) -> str:
2936
return self.value
3037

0 commit comments

Comments
 (0)