diff --git a/tests/test_app.py b/tests/test_app.py index 425c414..6ab75b4 100644 --- a/tests/test_app.py +++ b/tests/test_app.py @@ -390,3 +390,16 @@ def test_error_page_offers_retry(monkeypatch, tmp_path): html = app_module.app.test_client().get("/install/log").get_data(as_text=True) assert "Try again" in html assert "next-steps" not in html + + +def test_detect_bootloader_by_firmware(tmp_path): + import app as app_module + + efi = tmp_path / "efi" + assert app_module._detect_bootloader(efi) == "Grub" # BIOS / legacy + efi.mkdir() + assert app_module._detect_bootloader(efi) == "Systemd-boot" # no bitness file + (efi / "fw_platform_size").write_text("64\n") + assert app_module._detect_bootloader(efi) == "Systemd-boot" + (efi / "fw_platform_size").write_text("32\n") + assert app_module._detect_bootloader(efi) == "Limine" diff --git a/webinstaller/app.py b/webinstaller/app.py index a3b9ed9..160d4c7 100644 --- a/webinstaller/app.py +++ b/webinstaller/app.py @@ -515,10 +515,20 @@ def _post_install_commands(hostname, admin_username, admin_password): ] -def _detect_bootloader(): +def _detect_bootloader(efi_dir=Path("/sys/firmware/efi")): # systemd-boot is UEFI-only; on BIOS/legacy it trips HardwareIncompatibilityError # inside archinstall. /sys/firmware/efi exists iff we were booted via UEFI. - return "Systemd-boot" if Path("/sys/firmware/efi").exists() else "Grub" + if not efi_dir.exists(): + return "Grub" + # 64-bit CPU behind 32-bit UEFI (Atom Bay Trail / Cherry Trail mini-PCs + # and tablets): Arch ships no ia32 systemd-boot, and archinstall's GRUB + # path hardcodes --target=x86_64-efi. Its Limine path installs both + # BOOTIA32.EFI and BOOTX64.EFI and picks the entry by firmware bitness. + try: + bitness = (efi_dir / "fw_platform_size").read_text().strip() + except OSError: + bitness = "64" + return "Limine" if bitness == "32" else "Systemd-boot" def build_archinstall_config(s):