diff --git a/contracts/bluefin-desktop.toml b/contracts/bluefin-desktop.toml index b4b9603a..51c2563c 100644 --- a/contracts/bluefin-desktop.toml +++ b/contracts/bluefin-desktop.toml @@ -137,6 +137,7 @@ enabled = [ "flatpak-nuke-fedora.service", "flatpak-preinstall.service", "gdm.service", + "input-remapper.service", "ublue-system-setup.service", "uupd.timer", ] diff --git a/docs/skills/desktop-contract.md b/docs/skills/desktop-contract.md index 073a3c1f..8d8a3c77 100644 --- a/docs/skills/desktop-contract.md +++ b/docs/skills/desktop-contract.md @@ -100,7 +100,7 @@ on `GjsPrivate.DBusImplementation`, gracefully degrading to an inert portal on G Hummingbird defaults to a server preset and disables unlisted services, so the desktop policy is applied explicitly. `scripts/configure-services.sh` mirrors bluefin-lts's `40-services.sh`: it applies the desktop presets, -enables GDM, firmware updates, Tailscale, uupd, user setup and resolved, +enables GDM, input-remapper, firmware updates, Tailscale, uupd, user setup and resolved, configures authselect, and removes the extension build toolchain before cleanup (Containerfile RUN comment; originated in `docs/building.md`'s former design section and now lives in this skill). diff --git a/scripts/configure-services.sh b/scripts/configure-services.sh index 68b9e014..9ce273d6 100644 --- a/scripts/configure-services.sh +++ b/scripts/configure-services.sh @@ -74,6 +74,10 @@ enable_unit uupd.timer enable_unit ublue-system-setup.service enable_unit systemd-resolved.service enable_unit bootc-unified-storage.service +# input-remapper is installed by Bluefin's package set, but without its root +# daemon running, udev autoload fails on input devices and the GUI prompts for +# root credentials on launch. Enable it next to the desktop units; see #99. +enable_unit input-remapper.service # Bluefin's Brewfile and Bazaar preinstall hook need the Flathub remote before # first boot. Keep this as a .flatpakrepo descriptor so the remote is available diff --git a/system_files/shared/usr/lib/systemd/system-preset/85-utah-desktop.preset b/system_files/shared/usr/lib/systemd/system-preset/85-utah-desktop.preset index ce3eabb8..56b42ae9 100644 --- a/system_files/shared/usr/lib/systemd/system-preset/85-utah-desktop.preset +++ b/system_files/shared/usr/lib/systemd/system-preset/85-utah-desktop.preset @@ -11,6 +11,7 @@ enable ublue-system-setup.service enable systemd-resolved.service enable bootc-unified-storage.service enable dconf-update.service +enable input-remapper.service disable sshd.service disable rpm-ostree.service disable bootc-fetch-apply-updates.timer diff --git a/tests/test_desktop_contract.py b/tests/test_desktop_contract.py index 96d65c0c..f3c46bc8 100644 --- a/tests/test_desktop_contract.py +++ b/tests/test_desktop_contract.py @@ -59,6 +59,12 @@ def test_shipped_contract_is_valid(self): data = tomllib.loads((ROOT / "contracts/bluefin-desktop.toml").read_text()) self.assertEqual(desktop.validate_contract(data), []) + def test_shipped_contract_enables_input_remapper(self): + import tomllib + + data = tomllib.loads((ROOT / "contracts/bluefin-desktop.toml").read_text()) + self.assertIn("input-remapper.service", data.get("services", {}).get("enabled", [])) + def test_every_missing_section_is_named(self): errors = desktop.validate_contract({}) for section in ("branding", "configuration", "flatpak", "services"): diff --git a/tests/test_package_resolution.py b/tests/test_package_resolution.py index 5aaf2d31..688b9dc5 100644 --- a/tests/test_package_resolution.py +++ b/tests/test_package_resolution.py @@ -271,5 +271,80 @@ def test_live_initramfs_build_fails_on_a_dracut_error(self): self.assertIn("dracut\\[E\\]: FAILED", source) +class DesktopUnitEnablementTests(unittest.TestCase): + """A build-time enablement with no preset line behind it does not survive. + + bootc applies systemd presets on first boot, so `systemctl enable` at + build time is undone unless 85-utah-desktop.preset agrees. That trap is + documented in configure-services.sh's sshd branch and was confirmed from + the other side by projectbluefin/utah#98 and #99. Hold the two files in + agreement so units enabled at build time cannot silently omit the preset. + """ + + PRESET = ROOT / ( + "system_files/shared/usr/lib/systemd/system-preset/85-utah-desktop.preset" + ) + SERVICES = ROOT / "scripts/configure-services.sh" + + def preset_directives(self, verb): + return { + line.split()[1] + for line in self.PRESET.read_text().splitlines() + if line.startswith(f"{verb} ") + } + + def script_units(self, function): + # Leading whitespace matters: sshd is enabled inside a conditional + # block, so an anchored pattern misses it and the allowlist below + # would look stale when it is not. + return set( + re.findall(rf"^[ \t]*{function} (\S+)$", self.SERVICES.read_text(), re.M) + ) + + # sshd is deliberately excluded: configure-services.sh rewrites the preset + # in place for the opt-in debug build rather than shipping it enabled, + # which is the one case where the two files may legitimately disagree. + # + # The other three predate this test and are NOT asserted to be correct. + # They come from ublue packages that may ship their own vendor presets, in + # which case Utah's preset has nothing to add -- but that was not verified + # here, because it needs the built image rather than the source tree. They + # are listed so the guard below can be exact about what it does not yet + # cover, instead of being weakened into passing for everything. If one of + # them turns out to have no preset behind it either, it is the same bug as + # #98 and belongs in the preset. + WITHOUT_PRESET = { + "sshd.service", + "brew-setup.service", + "flatpak-nuke-fedora.service", + "flatpak-preinstall.service", + } + + def test_no_new_unit_is_enabled_without_a_preset_entry(self): + enabled = self.script_units("enable_unit") - self.WITHOUT_PRESET + missing = sorted(enabled - self.preset_directives("enable")) + self.assertEqual( + missing, + [], + "enabled at build time with no preset entry, so bootc's first-boot " + f"preset application will undo it: {missing}", + ) + + def test_the_exception_list_does_not_cover_absent_units(self): + # A stale allowlist silently widens the hole above. Every name in it + # must still be a unit configure-services.sh actually enables. + enabled = self.script_units("enable_unit") + stale = sorted(self.WITHOUT_PRESET - enabled) + self.assertEqual(stale, [], f"allowlisted but no longer enabled: {stale}") + + def test_the_reported_desktop_units_are_enabled(self): + # projectbluefin/utah#99: input-remapper package was installed and its + # unit never started. Name them so a refactor cannot drop one. + for unit in ("input-remapper.service",): + with self.subTest(unit=unit): + self.assertIn(unit, self.script_units("enable_unit")) + self.assertIn(unit, self.preset_directives("enable")) + + if __name__ == "__main__": unittest.main()