From acf0b8cd52ac3a1abe3dbdf12eaf89d3188096fb Mon Sep 17 00:00:00 2001 From: Knox Hutchinson Date: Tue, 8 Sep 2026 20:16:54 -0500 Subject: [PATCH] Ship the fork's user units in the aarch64 omarchy-settings package Upstream's omarchy-settings PKGBUILD installs its user units from an explicit list, so a unit this fork adds under default/systemd/user/ lands in /usr/share/omarchy/default/ but never in /usr/lib/systemd/user/, where first-run and the migration enable it. 4.0.2-2 shipped the ambient keyboard backlight unit that way: on every updated Mac, `systemctl --user is-enabled omarchy-brightness-keyboard-auto.service` reports not-found and the wants symlink the migration wrote dangles, so the feature never runs. Patch the PKGBUILD the same way the limine and mkinitcpio deltas are applied, adding one install line per fork unit right after upstream's own, and stepping aside for any unit upstream has since adopted. The test drives the function against a stand-in package(), checks it adds the line once, and checks it refuses a PKGBUILD that no longer looks like upstream's. Co-Authored-By: Claude Fable 5.1 Claude-Session: https://claude.ai/code/session_015BSgNp56iTuhMy7XLHsRC2 --- build-packages.sh | 38 ++++++++++++++++++++++++++++++++ test/shell.d/install-mac-test.sh | 37 +++++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) diff --git a/build-packages.sh b/build-packages.sh index b07d84fc647..ba995c84e13 100755 --- a/build-packages.sh +++ b/build-packages.sh @@ -120,6 +120,43 @@ keep_apple_silicon_mkinitcpio_drop_ins() { fail "lost the limine-entry-tool.d cleanup in $pkgbuild" } +# Upstream's omarchy-settings PKGBUILD installs its user units from an explicit +# list rather than a glob, so a unit this fork adds under default/systemd/user/ +# ships under /usr/share/omarchy/default/ but never reaches +# /usr/lib/systemd/user/, where first-run and the migration enable it. That is +# what 4.0.2-2 did with the ambient keyboard backlight unit: every install got +# a wants symlink to a unit systemd reports as not-found. Add an install line +# for each fork unit right after upstream's own, and step aside for a unit +# upstream has since adopted. +readonly fork_user_units=( + omarchy-brightness-keyboard-auto.service +) + +install_fork_user_units() { + local pkgbuild="$1" unit last line + + for unit in "${fork_user_units[@]}"; do + [[ -f "$checkout/default/systemd/user/$unit" ]] || + fail "default/systemd/user/$unit is listed in fork_user_units but missing from the checkout" + if grep -qF "default/systemd/user/$unit " "$pkgbuild"; then + continue + fi + + # Fail loudly if upstream restructures this. Silently not matching would + # ship a package without the unit, which is the failure this exists to + # prevent and the one that only shows as a dangling symlink after install. + last=$(grep -nE '^[[:space:]]*install -Dm644 default/systemd/user/[^[:space:]]+\.service ' "$pkgbuild" | + tail -n 1 | cut -d: -f1) + [[ -n $last ]] || + fail "omarchy-settings PKGBUILD no longer installs user units as expected; re-check it against $pkgbuild" + + line=" install -Dm644 default/systemd/user/$unit \"\$pkgdir/usr/lib/systemd/user/$unit\"" + awk -v n="$last" -v line="$line" '{ print } NR == n { print line }' "$pkgbuild" >"$pkgbuild.tmp" && + mv "$pkgbuild.tmp" "$pkgbuild" + grep -qF "$line" "$pkgbuild" || fail "could not add $unit to $pkgbuild" + done +} + # makepkg runs with --nodeps because the runtime dependencies include packages # built here, so pacman cannot resolve them yet. That skips makedepends too, # leaving the build tools to be installed up front. @@ -172,6 +209,7 @@ build_package() { fi if [[ $package == "omarchy-settings" ]]; then keep_apple_silicon_mkinitcpio_drop_ins "$build_dir/$package/PKGBUILD" + install_fork_user_units "$build_dir/$package/PKGBUILD" fi if [[ $package == "omarchy" || $package == "omarchy-settings" ]]; then set_pkgrel "$build_dir/$package/PKGBUILD" diff --git a/test/shell.d/install-mac-test.sh b/test/shell.d/install-mac-test.sh index 1067348521e..28b253a7dc0 100755 --- a/test/shell.d/install-mac-test.sh +++ b/test/shell.d/install-mac-test.sh @@ -64,6 +64,43 @@ if ! ( fail "set_pkgrel no-ops without OMARCHY_PKGREL, writes a number, and rejects junk" fi rm -rf "$rel_dir" +# Upstream's package() lists its user units one by one, so a unit only this +# fork ships has to be added to that list or it never reaches +# /usr/lib/systemd/user/ and the migration that enables it dangles. +units_dir=$(mktemp -d) +cat >"$units_dir/PKGBUILD" <<'PKG' +package() { + install -Dm644 default/systemd/user/bt-agent.service "$pkgdir/usr/lib/systemd/user/bt-agent.service" + install -Dm644 default/systemd/user/omarchy-crash-watch.service "$pkgdir/usr/lib/systemd/user/omarchy-crash-watch.service" + install -d "$pkgdir/usr/share/omarchy/applications" +} +PKG +if ! ( + source "$build_script" + install_fork_user_units "$units_dir/PKGBUILD" + # A second pass, or upstream adopting the unit, must not add it twice. + install_fork_user_units "$units_dir/PKGBUILD" + added='install -Dm644 default/systemd/user/omarchy-brightness-keyboard-auto.service "$pkgdir/usr/lib/systemd/user/omarchy-brightness-keyboard-auto.service"' + [[ $(grep -cF "$added" "$units_dir/PKGBUILD") == 1 ]] || exit 1 + # Directly after upstream's last unit, so it stays inside package(). + grep -A1 -F 'omarchy-crash-watch.service' "$units_dir/PKGBUILD" | grep -qF "$added" || exit 1 + printf 'package() {\n install -d "$pkgdir/usr/share"\n}\n' >"$units_dir/PKGBUILD" + if ( install_fork_user_units "$units_dir/PKGBUILD" >/dev/null 2>&1 ); then + exit 1 + fi +); then + rm -rf "$units_dir" + fail "install_fork_user_units adds each fork unit once after upstream's units and refuses an unrecognised package()" +fi +rm -rf "$units_dir" +pass "install_fork_user_units adds each fork unit once after upstream's units and refuses an unrecognised package()" + +grep -A3 'package == "omarchy-settings"' "$build_script" | grep -q install_fork_user_units || + fail "the package build installs the fork's user units into omarchy-settings" +grep -qF ' omarchy-brightness-keyboard-auto.service' "$build_script" || + fail "the package build lists the ambient keyboard backlight unit as a fork unit" +pass "the package build installs the fork's user units into omarchy-settings" + grep -A2 'package == "omarchy-settings"' "$build_script" | grep -q set_pkgrel || fail "the package build stamps pkgrel on omarchy and omarchy-settings" pass "the package build can stamp a Mac-only pkgrel on omarchy and omarchy-settings"