Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contracts/bluefin-desktop.toml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ enabled = [
"flatpak-nuke-fedora.service",
"flatpak-preinstall.service",
"gdm.service",
"input-remapper.service",
"ublue-system-setup.service",
"uupd.timer",
]
Expand Down
2 changes: 1 addition & 1 deletion docs/skills/desktop-contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
4 changes: 4 additions & 0 deletions scripts/configure-services.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions tests/test_desktop_contract.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"):
Expand Down
75 changes: 75 additions & 0 deletions tests/test_package_resolution.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Loading