* Stop the install dying on non-UTF-8 command output efibootmgr prints what firmware gave it, and an HP ProBook's NVRAM held a legacy BBS entry whose device path was raw binary. `_read_efibootmgr` captured that with `text=True`, so Python decoded it strictly and a byte in a boot entry nothing here reads killed the whole "Installing Arch + Omarchy" phase. Two machines have hit it now, on 0x80 and 0xe0. Every text capture in the orchestrator had the same exposure — partition labels reach lsblk and blkid the same way firmware strings reach efibootmgr — so they all go through one `capture()` that replaces what it cannot decode. The file reads here already did this; the command reads were the gap. Replacing bytes has its own failure mode, and it is worse than the crash: a mangled UUID would be written into fstab and the kernel cmdline, and `_validate_pre_mounted_filesystems` reads it back from the same command, agrees with itself, and ships a machine that cannot find its root. So `require_text()` refuses a value the installed system depends on — UUIDs, device names, the btrfs device handed to mount — while the boot-entry labels stay tolerant on purpose: the decisions taken from those are advisory, and refusing a junk one would abort the install this change exists to let finish. The regression test runs a stand-in efibootmgr emitting the reported byte sequence, so it exercises the decode rather than a mock. test_keyboard.py loads the module through the package now that keyboard.py imports a sibling. Closes #116 🤖 Generated by Opus 5 in Claude Code. Reviewed by Codex XHigh. Co-Authored-By: Codex XHigh <noreply@openai.com> * Say accurately why the boot-entry parsing stays tolerant The previous commit called the decisions taken from a firmware label "advisory". They are not: a label match selects entries for deletion and rewrites the boot order, and a missing one aborts validation. Staying tolerant is still right, for a reason the comment did not give — an entry's text is its label and its device path together, the junk lives in the path, and nothing mangled reaches efibootmgr from there anyway, since only four-digit ASCII boot numbers become arguments and a boot order is filtered through the entries that parsed. A label that loses a byte costs a stale entry left behind, not a broken system. The test docstring credited one machine with a fixture that carries the bytes from two. Co-Authored-By: Codex XHigh <noreply@openai.com> --------- Co-authored-by: Codex XHigh <noreply@openai.com>
55 lines
2.1 KiB
Python
55 lines
2.1 KiB
Python
"""Offline target keyboard configuration.
|
|
|
|
archinstall's set_keyboard_language boots the installed system in a
|
|
systemd-nspawn container just to run localectl. systemd-firstboot --root
|
|
produces the part of that output Omarchy actually consumes — KEYMAP for the
|
|
console plus the XKB* settings in vconsole.conf that omarchy's
|
|
detect-keyboard-layout.sh copies into Hyprland's kb_layout — without booting
|
|
anything. The Xorg 00-keyboard.conf that localectl also writes is not
|
|
generated: nothing on an Omarchy system reads it.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
from .command import capture
|
|
|
|
|
|
def configure_keyboard(target: Path, language: str) -> bool:
|
|
"""Write the console keymap into a mounted target without booting it.
|
|
|
|
Returns False for layouts localectl doesn't know, matching archinstall:
|
|
warn and keep the default. Every layout the configurator offers is known;
|
|
the guard is for the kb_layout an autoinstall drive can name freely.
|
|
"""
|
|
if not language.strip():
|
|
return True
|
|
|
|
result = capture(["localectl", "--no-pager", "list-keymaps"])
|
|
if result.returncode != 0:
|
|
detail = result.stderr.strip() or "localectl returned an error"
|
|
raise RuntimeError(f"Unable to list keyboard layouts: {detail}")
|
|
if language.lower() not in {layout.lower() for layout in result.stdout.splitlines()}:
|
|
return False
|
|
|
|
# systemd-firstboot --force rewrites vconsole.conf wholesale, dropping the
|
|
# FONT= line archinstall's set_vconsole wrote earlier.
|
|
vconsole_path = target / "etc" / "vconsole.conf"
|
|
font = None
|
|
if vconsole_path.exists():
|
|
font = next(
|
|
(line for line in vconsole_path.read_text().splitlines() if line.startswith("FONT=")),
|
|
None,
|
|
)
|
|
|
|
result = capture(["systemd-firstboot", f"--root={target}", f"--keymap={language}", "--force"])
|
|
if result.returncode != 0:
|
|
detail = result.stderr.strip() or "systemd-firstboot returned an error"
|
|
raise RuntimeError(f"Unable to configure keyboard layout {language}: {detail}")
|
|
|
|
if font:
|
|
vconsole_path.write_text(vconsole_path.read_text() + font + "\n")
|
|
|
|
return True
|