* 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>
85 lines
3.3 KiB
Python
85 lines
3.3 KiB
Python
#!/usr/bin/python
|
|
|
|
import re
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
sys.path.insert(0, str(ROOT / "configs/airootfs/usr/share/omarchy-iso"))
|
|
|
|
from orchestrator import keyboard as KEYBOARD # noqa: E402
|
|
|
|
# The layout list lives in the Omarchy runtime now, shared verbatim with the
|
|
# first-boot owner setup; build-iso.sh vendors it onto the ISO. Read it from
|
|
# wherever this checkout can see a runtime, and skip the coverage test rather
|
|
# than fail when none is around (a bare CI checkout of just this repo).
|
|
SETUP_FORM_CANDIDATES = (
|
|
Path("/omarchy-source/install/provisioning/setup-form.sh"),
|
|
ROOT.parent / "omarchy/install/provisioning/setup-form.sh",
|
|
Path("/usr/share/omarchy/install/provisioning/setup-form.sh"),
|
|
)
|
|
|
|
|
|
def supported_keymaps():
|
|
for candidate in SETUP_FORM_CANDIDATES:
|
|
if not candidate.is_file():
|
|
continue
|
|
block = re.search(
|
|
r"OMARCHY_KEYBOARD_LAYOUTS=\$'(.*?)'\n", candidate.read_text(), re.DOTALL
|
|
)
|
|
assert block, f"no layout list in {candidate}"
|
|
return [line.split("|", 1)[1] for line in block.group(1).splitlines()]
|
|
return None
|
|
|
|
|
|
SUPPORTED_KEYMAPS = supported_keymaps()
|
|
|
|
|
|
class KeyboardConfigurationTest(unittest.TestCase):
|
|
def target(self, directory: str) -> Path:
|
|
target = Path(directory)
|
|
(target / "etc").mkdir()
|
|
(target / "etc/vconsole.conf").write_text(
|
|
"KEYMAP=us\nFONT=default8x16\n"
|
|
)
|
|
return target
|
|
|
|
def test_writes_keymap_and_xkb_settings_and_preserves_font(self):
|
|
# XKBLAYOUT is load-bearing: omarchy's detect-keyboard-layout.sh copies
|
|
# it into Hyprland's kb_layout on the installed system.
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
target = self.target(directory)
|
|
self.assertTrue(KEYBOARD.configure_keyboard(target, "us"))
|
|
lines = (target / "etc/vconsole.conf").read_text().splitlines()
|
|
self.assertIn("KEYMAP=us", lines)
|
|
self.assertIn("XKBLAYOUT=us", lines)
|
|
self.assertEqual(lines.count("FONT=default8x16"), 1)
|
|
|
|
def test_all_configurator_keymaps_are_known_to_localectl(self):
|
|
if SUPPORTED_KEYMAPS is None:
|
|
self.skipTest("no Omarchy runtime checkout to read the layout list from")
|
|
for keymap in SUPPORTED_KEYMAPS:
|
|
with self.subTest(keymap=keymap), tempfile.TemporaryDirectory() as directory:
|
|
target = self.target(directory)
|
|
self.assertTrue(KEYBOARD.configure_keyboard(target, keymap))
|
|
lines = (target / "etc/vconsole.conf").read_text().splitlines()
|
|
self.assertIn(f"KEYMAP={keymap}", lines)
|
|
self.assertEqual(lines.count("FONT=default8x16"), 1)
|
|
|
|
def test_unknown_and_empty_keymaps_match_archinstall_behavior(self):
|
|
for keymap, expected in (("definitely-not-a-keymap", False), ("", True)):
|
|
with self.subTest(keymap=keymap), tempfile.TemporaryDirectory() as directory:
|
|
target = self.target(directory)
|
|
self.assertEqual(KEYBOARD.configure_keyboard(target, keymap), expected)
|
|
self.assertEqual(
|
|
(target / "etc/vconsole.conf").read_text(),
|
|
"KEYMAP=us\nFONT=default8x16\n",
|
|
)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|