Source the setup form from the Omarchy runtime (#104)
The keyboard layout list, the account and hostname validation rules, and the gum prompts that ask for them existed here and again in the runtime's first-boot owner setup, with nothing keeping the copies honest. They had already drifted: dropping two layouts from this list moved English (US) from the top of one gum choose page to the bottom of the previous one, leaving the preselected default pinned under a screenful of layouts. The form now lives in the runtime at install/provisioning/setup-form.sh, and build-iso.sh vendors it out of the very runtime package this ISO bundles — the same two-branch machinery already used for omarchy-base.packages, so a --local-source build takes it from the mounted checkout and everything else extracts it from the downloaded package. An ISO therefore ships the form belonging to the runtime it installs. That file is extracted on its own rather than alongside the package lists: bsdtar exits non-zero for a member it cannot find, so bundling the request would abort the build under set -e with a bare "Not found in archive" instead of the actionable error about publishing a runtime that carries the form. Cancel handling is unified with first-boot setup, which is what made the prompts shareable. Every prompt reports 0 (answered), 1 (Esc), or 130 (Ctrl+C). Esc now unwinds to the start of the form instead of ending the install — it previously hit the same `|| abort` as Ctrl+C. Ctrl+C keeps both of its hidden affordances: arming deferred provisioning on the first keyboard screen, and toggling unencrypted on the disk screens. test_keyboard.py reads the layout list from a runtime checkout now, and skips its localectl coverage rather than failing when there is none to read. Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
6b2f8a6ac7
commit
8858ac2544
5 files changed
+116
-140
No files matched your search
+30
-14
@@ -14,14 +14,30 @@ KEYBOARD = importlib.util.module_from_spec(SPEC)
|
||||
assert SPEC.loader
|
||||
SPEC.loader.exec_module(KEYBOARD)
|
||||
|
||||
CONFIGURATOR = (ROOT / "configs/airootfs/root/configurator").read_text()
|
||||
KEYBOARD_BLOCK = re.search(r"keyboards=\$'(.*?)'\n choice=", CONFIGURATOR, re.DOTALL)
|
||||
assert KEYBOARD_BLOCK
|
||||
SUPPORTED_KEYMAPS = [
|
||||
line.split("|", 1)[1]
|
||||
for line in KEYBOARD_BLOCK.group(1).splitlines()
|
||||
]
|
||||
UNSUPPORTED_KEYMAPS = {"ba", "khmer"}
|
||||
# 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):
|
||||
@@ -45,15 +61,15 @@ class KeyboardConfigurationTest(unittest.TestCase):
|
||||
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)
|
||||
configured = KEYBOARD.configure_keyboard(target, keymap)
|
||||
self.assertEqual(configured, keymap not in UNSUPPORTED_KEYMAPS)
|
||||
if configured:
|
||||
lines = (target / "etc/vconsole.conf").read_text().splitlines()
|
||||
self.assertIn(f"KEYMAP={keymap}", lines)
|
||||
self.assertEqual(lines.count("FONT=default8x16"), 1)
|
||||
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)):
|
||||
|
||||
Reference in new issue
Block a user