Files
omarchy-pkgs/tests/passwordless-package-files.sh
T
40ea1555f2 Ship the complete passwordless-sudo lifecycle in settings-dev (#645)
* Move the dev sudo grant lifecycle into omarchy-settings-dev

The hardened omarchy-sudo-passwordless publishes a grant only when its revocation hook is installed and no package transaction has left /run/omarchy-sudo-passwordless-package-removing behind. The hook sets that marker before every settings upgrade, and the settings scriptlets are what clear it, so shipping the hook alone let the first grant work and then refused every grant after the next update until a reboot.

omarchy-settings-dev now ships the command, omarchy-security-functions, the boot cleanup rule and the hook together, with the scriptlets from #257 that revoke before the package changes and clear the marker once no grant remains. omarchy-dev stops shipping the two helpers and requires the settings release that does: without it omarchy-update has no library to source.

Co-authored-by: Afonso Oliveira <afonso.oliveira707@gmail.com>

* Check that settings-dev registers the scriptlet the lifecycle test exercises

The lifecycle test reads the .install file directly, so it kept passing with the recipe's install= line gone, which is the one change that would strand the hook's marker again.

Co-Authored-By: Codex XHigh <noreply@openai.com>

* Keep omarchy-dev's settings dependency unversioned

The dev pair builds each package on its own against the published edge repository, in the PR build and in publish alike, so omarchy-dev cannot require a settings-dev release that only this change produces: the floor failed both omarchy-dev builds on this PR, and an exact pkgver match would fail the same way on every upstream pin bump. Nothing needs it. The upstream watch moves both pins together, publish stops the run before anything is published when one package fails, and a new settings-dev over an old runtime is refused on the files they would both own.

* Refuse settings-dev releases that predate the grant helper move

With the dependency unversioned, a new omarchy-dev could still install over a settings-dev that is held back or not yet published, removing omarchy-security-functions from both, and omarchy-update cannot start without it. A versioned conflict refuses that pairing at install time without constraining the per-package builds, which resolve only depends.

Co-Authored-By: Codex XHigh <noreply@openai.com>

* Require the security library as a capability instead of a version floor

The conflict named the last settings-dev release without the helpers, a version that moves with every upstream pin bump and settings-only pkgrel while this change waits to merge, and a rebase that kept a stale floor still passed the tests while the published release slipped past it. omarchy-settings-dev now provides omarchy-security-functions and omarchy-dev's package() requires it. makepkg checks only the top-level depends before building, so the per-package builds still resolve against the published repository, while pacman refuses a runtime without a settings release that ships the library, and pulls that release in when only the runtime is asked for.

Co-Authored-By: Codex XHigh <noreply@openai.com>

---------

Co-authored-by: Spencer Bull <spencer@omarchy.org>
Co-authored-by: Afonso Oliveira <afonso.oliveira707@gmail.com>
Co-authored-by: Codex XHigh <noreply@openai.com>
2026-10-11 09:56:47 -05:00

90 lines
4.4 KiB
Bash
Executable File

#!/bin/bash
# Build the dev pair from a synthetic source tree: the sudo grant command, its
# library, boot cleanup and revocation hook ship from settings, and no path
# ships from both packages, which pacman would refuse to install together.
set -euo pipefail
BUILD_ROOT=$(realpath "${BASH_SOURCE[0]%/*}/..")
scratch=$(mktemp -d)
trap 'rm -rf "$scratch"' EXIT
fixture=$scratch/src/omarchy
mapfile -t files < "$BUILD_ROOT/tests/fixtures/settings-source-files"
files+=(
bin/omarchy-update
default/libalpm/hooks/00-omarchy-update-guard.hook
default/libalpm/hooks/10-omarchy-hyprland-reload-pause.hook
default/libalpm/hooks/90-omarchy-hyprland-reload-resume.hook
install/omarchy-base.packages
themes/fixture/colors.toml
migrations/1788163635.sh
shell/shell.qml
version
)
for path in "${files[@]}"; do
mkdir -p "$(dirname "$fixture/$path")"
printf 'fixture for %s\n' "$path" > "$fixture/$path"
done
# The aarch64 recipe parses the HOOKS line.
cp "$BUILD_ROOT/tests/fixtures/settings-boot/omarchy_hooks-v4.0.4.conf" "$fixture/etc/mkinitcpio.conf.d/omarchy_hooks.conf"
fail() {
echo "FAIL: $*" >&2
exit 1
}
hook=usr/share/libalpm/hooks/05-omarchy-passwordless-revoke.hook
boot_cleanup=etc/tmpfiles.d/omarchy-nopasswd-sudo.conf
# The scriptlets are what clear the hook's marker, and
# passwordless-package-lifecycle.py only tests the file, not that it ships.
registered=$(CARCH=x86_64 && source "$BUILD_ROOT/pkgbuilds/omarchy-settings-dev/PKGBUILD" && echo "${install:-}")
[[ $registered == omarchy-settings-dev.install ]] ||
fail "omarchy-settings-dev does not register omarchy-settings-dev.install"
# The runtime needs the library settings provides, but only once installed:
# the per-package builds resolve the top-level depends against what the
# repository already publishes.
build_depends=$(CARCH=x86_64 && source "$BUILD_ROOT/pkgbuilds/omarchy-dev/PKGBUILD" && printf '%s\n' "${depends[@]}")
! grep -Fxq omarchy-security-functions <<<"$build_depends" ||
fail "omarchy-dev asks for omarchy-security-functions before building, which a published settings-dev may not provide"
for target_arch in x86_64 aarch64; do
for recipe in omarchy-dev omarchy-settings-dev; do
(
export CARCH=$target_arch OMARCHY_SRC=$fixture
export srcdir=$scratch/src pkgdir=$scratch/$recipe-$target_arch
backup=()
# shellcheck disable=SC1090 # Exercise each recipe's actual package function.
source "$BUILD_ROOT/pkgbuilds/$recipe/PKGBUILD"
package
printf '%s\n' "${depends[@]}" >"$scratch/$recipe-$target_arch.depends"
printf '%s\n' "${provides[@]}" >"$scratch/$recipe-$target_arch.provides"
) >/dev/null
done
runtime=$scratch/omarchy-dev-$target_arch
settings=$scratch/omarchy-settings-dev-$target_arch
for helper in omarchy-sudo-passwordless omarchy-security-functions; do
cmp -s "$fixture/bin/$helper" "$settings/usr/bin/$helper" && [[ -x $settings/usr/bin/$helper ]] ||
fail "$target_arch: omarchy-settings-dev does not ship /usr/bin/$helper"
[[ $(readlink "$settings/usr/share/omarchy/bin/$helper") == "/usr/bin/$helper" ]] ||
fail "$target_arch: omarchy-settings-dev does not link /usr/share/omarchy/bin/$helper"
done
cmp -s "$fixture/default/libalpm/hooks/05-omarchy-passwordless-revoke.hook" "$settings/$hook" &&
[[ $(stat -c %a "$settings/$hook") == 644 ]] ||
fail "$target_arch: omarchy-settings-dev does not ship /$hook"
cmp -s "$fixture/$boot_cleanup" "$settings/$boot_cleanup" ||
fail "$target_arch: omarchy-settings-dev does not ship /$boot_cleanup"
[[ -x $runtime/usr/bin/omarchy-update && -f $runtime/usr/share/libalpm/hooks/00-omarchy-update-guard.hook ]] ||
fail "$target_arch: omarchy-dev lost its own commands or hooks"
grep -Fxq omarchy-security-functions "$scratch/omarchy-dev-$target_arch.depends" ||
fail "$target_arch: the omarchy-dev package does not require omarchy-security-functions"
grep -Fxq omarchy-security-functions "$scratch/omarchy-settings-dev-$target_arch.provides" ||
fail "$target_arch: the omarchy-settings-dev package does not provide omarchy-security-functions"
overlap=$(comm -12 <(cd "$runtime" && find . ! -type d | sort) <(cd "$settings" && find . ! -type d | sort))
[[ -z $overlap ]] || fail "$target_arch: shipped by both omarchy-dev and omarchy-settings-dev:"$'\n'"$overlap"
echo "PASS: $target_arch: omarchy-settings-dev owns the sudo grant lifecycle and shares no file with omarchy-dev"
done