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
8 changes: 5 additions & 3 deletions bin/omarchy-update-keyring
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ if omarchy-pkg-missing omarchy-keyring || ! sudo pacman-key --list-keys 40DFB630
sudo pacman-key --list-keys 40DFB630FF42BCFFB047046CF0134EE680CAC571
fi

# Ensure we have the latest archlinux-keyring, maintainer keys might have changed
# Always reinstall, as the keyring can be updated without a package version bump.
# Ensure we have the latest archlinux-keyring, maintainer keys might have changed.
# --needed installs only a newer keyring: new or revoked keys reach the repos
# as a new package version, and an installed version was populated when it
# went in, so reinstalling the same one only repeats that populate.
# An aarch64 machine's Arch Linux ARM repositories are signed with keys of
# their own, so its keyring is kept current the same way.
keyrings=(archlinux-keyring)
Expand All @@ -47,7 +49,7 @@ if [[ -f $platform_keyrings ]]; then
done <"$platform_keyrings"
fi
echo -e "\e[32m\nUpdate Arch signing keys\e[0m"
sudo pacman -Sy --noconfirm "${keyrings[@]}" >/dev/null 2> >(grep -vE '^warning: [a-z0-9@._+-]+-keyring-[^ ]+ is up to date -- reinstalling$' >&2)
sudo pacman -Sy --needed --noconfirm "${keyrings[@]}" >/dev/null 2> >(grep -vE '^warning: [a-z0-9@._+-]+-keyring-[^ ]+ is up to date -- skipping$' >&2)

# Say "correct" only once the key verifiably is: before the failure checks
# above, a failed recv or reinstall still ended here with exit 0.
Expand Down
2 changes: 1 addition & 1 deletion docs/file-layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ A platform's runtime package (omarchy-mac on Apple Silicon, say) adds its deskto

See [lifecycle-dispatch.md](lifecycle-dispatch.md#platform-files).

`omarchy-update-keyring` reinstalls each installed package `keyrings` names (`#` comments and blank lines skipped, and a line that isn't a `*-keyring` package name skipped with a warning) with Arch's, before the system upgrade, so a key rotation in the platform's own repository never fails that upgrade's signature checks. On Apple Silicon, omarchy-mac names `asahi-alarm-keyring` there.
`omarchy-update-keyring` refreshes each installed package `keyrings` names (`#` comments and blank lines skipped, and a line that isn't a `*-keyring` package name skipped with a warning) along with Arch's, before the system upgrade, installing any newer version the repository has, so a key rotation in the platform's own repository never fails that upgrade's signature checks. On Apple Silicon, omarchy-mac names `asahi-alarm-keyring` there.

#### Display hints (`displays.conf`)

Expand Down
45 changes: 30 additions & 15 deletions test/shell.d/update-keyring-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ mkdir -p "$stub_bin"
# KEYRING_TEST_PKG_MISSING exit status of omarchy-pkg-missing (default 1: installed)
# KEYRING_TEST_LIST_FAIL_ON which --list-keys call fails, counted per run (default: none)
# KEYRING_TEST_RECV_STATUS exit status of --recv-keys (default 0)
# KEYRING_TEST_REINSTALL_STATUS exit status of the archlinux-keyring reinstall (default 0)
# KEYRING_TEST_REINSTALL_STATUS exit status of the archlinux-keyring refresh (default 0)
# KEYRING_TEST_WARN=1 pacman prints --needed's notice and another warning
cat >"$stub_bin/sudo" <<'SH'
#!/bin/bash

Expand Down Expand Up @@ -44,6 +45,13 @@ if [[ $1 == "pacman-key" && $2 == "--lsign-key" ]]; then
fi

if [[ $1 == "pacman" && $* == *archlinux-keyring* ]]; then
# What --needed prints for a keyring that is already current, plus a
# warning that must still reach the person running the update.
if [[ ${KEYRING_TEST_WARN:-0} == 1 ]]; then
echo "warning: archlinux-keyring-20260909-1 is up to date -- skipping" >&2
echo "warning: some other warning" >&2
echo " there is nothing to do"
fi
exit "${KEYRING_TEST_REINSTALL_STATUS:-0}"
fi

Expand Down Expand Up @@ -98,15 +106,22 @@ run_keyring() {
# Everything healthy: the key and package are present, the reinstall works.
: >"$log_file"
rm -f "$test_tmp/list-calls"
run_keyring >"$test_tmp/ok.out"
# stderr goes through a pipe read to EOF: the script's filtering grep runs in a
# process substitution, which can still be writing after the script exits.
KEYRING_TEST_WARN=1 run_keyring 2>&1 >"$test_tmp/ok.out" | cat >"$test_tmp/ok.err"

grep -F "Keys are correct" "$test_tmp/ok.out" >/dev/null ||
fail "update-keyring reports success when the keyring is healthy" "$(cat "$test_tmp/ok.out")"
pass "update-keyring reports success when the keyring is healthy"

grep -Eq $'^sudo\tpacman\t-Sy\t--noconfirm\tarchlinux-keyring$' "$log_file" ||
fail "update-keyring still reinstalls archlinux-keyring" "$(cat "$log_file")"
pass "update-keyring still reinstalls archlinux-keyring"
grep -Eq $'^sudo\tpacman\t-Sy\t--needed\t--noconfirm\tarchlinux-keyring$' "$log_file" ||
fail "update-keyring refreshes archlinux-keyring, installing only a newer one" "$(cat "$log_file")"
pass "update-keyring refreshes archlinux-keyring, installing only a newer one"

if grep -F "is up to date" "$test_tmp/ok.err" >/dev/null || ! grep -Fx "warning: some other warning" "$test_tmp/ok.err" >/dev/null; then
fail "update-keyring hides only the up-to-date notice of a current keyring" "$(cat "$test_tmp/ok.err")"
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
fi
pass "update-keyring hides only the up-to-date notice of a current keyring"

# An aarch64 machine keeps Arch Linux ARM's keyring current alongside Arch's.
: >"$log_file"
Expand All @@ -115,15 +130,15 @@ for platform in aarch64-apple aarch64; do
: >"$log_file"
rm -f "$test_tmp/list-calls"
KEYRING_TEST_ARM=1 KEYRING_TEST_PLATFORM=$platform run_keyring >"$test_tmp/arm.out"
grep -Eq $'^sudo\tpacman\t-Sy\t--noconfirm\tarchlinux-keyring\tarchlinuxarm-keyring$' "$log_file" ||
fail "update-keyring also reinstalls Arch Linux ARM's keyring on $platform" "$(cat "$log_file")"
grep -Eq $'^sudo\tpacman\t-Sy\t--needed\t--noconfirm\tarchlinux-keyring\tarchlinuxarm-keyring$' "$log_file" ||
fail "update-keyring also refreshes Arch Linux ARM's keyring on $platform" "$(cat "$log_file")"
done
: >"$log_file"
rm -f "$test_tmp/list-calls"
KEYRING_TEST_ARM=1 run_keyring >"$test_tmp/x86.out"
grep -Eq $'^sudo\tpacman\t-Sy\t--noconfirm\tarchlinux-keyring$' "$log_file" ||
fail "x86 reinstalls only Arch's keyring, even with Arch Linux ARM's installed" "$(cat "$log_file")"
pass "aarch64 machines also reinstall Arch Linux ARM's keyring where it is installed, x86 never"
grep -Eq $'^sudo\tpacman\t-Sy\t--needed\t--noconfirm\tarchlinux-keyring$' "$log_file" ||
fail "x86 refreshes only Arch's keyring, even with Arch Linux ARM's installed" "$(cat "$log_file")"
pass "aarch64 machines also refresh Arch Linux ARM's keyring where it is installed, x86 never"

# The platform package's list adds the installed keyrings it names: Apple
# Silicon's [asahi-alarm], with no platform branch here.
Expand All @@ -132,9 +147,9 @@ printf 'asahi-alarm-keyring' >>"$platform_keyrings"
: >"$log_file"
rm -f "$test_tmp/list-calls"
KEYRING_TEST_ARM=1 KEYRING_TEST_PLATFORM=aarch64-apple KEYRING_TEST_INSTALLED=asahi-alarm-keyring run_keyring >"$test_tmp/platform.out"
grep -Eq $'^sudo\tpacman\t-Sy\t--noconfirm\tarchlinux-keyring\tarchlinuxarm-keyring\tasahi-alarm-keyring$' "$log_file" ||
fail "update-keyring reinstalls the installed keyrings the platform names, once each" "$(cat "$log_file")"
pass "update-keyring reinstalls the installed keyrings the platform names, once each"
grep -Eq $'^sudo\tpacman\t-Sy\t--needed\t--noconfirm\tarchlinux-keyring\tarchlinuxarm-keyring\tasahi-alarm-keyring$' "$log_file" ||
fail "update-keyring refreshes the installed keyrings the platform names, once each" "$(cat "$log_file")"
pass "update-keyring refreshes the installed keyrings the platform names, once each"

for listed in 'asahi-alarm-keyring;reboot' '../asahi-alarm-keyring' 'asahi-alarm' '-Syu-keyring' 'asahi-alarm-keyring extra'; do
printf '%s\n%s\n' "$listed" asahi-alarm-keyring >"$platform_keyrings"
Expand All @@ -144,8 +159,8 @@ for listed in 'asahi-alarm-keyring;reboot' '../asahi-alarm-keyring' 'asahi-alarm
fail "update-keyring carries on past a platform list line naming $listed" "$(cat "$test_tmp/invalid.out")"
grep -qF "skipping $listed" "$test_tmp/invalid.out" ||
fail "update-keyring warns about $listed" "$(cat "$test_tmp/invalid.out")"
grep -Eq $'^sudo\tpacman\t-Sy\t--noconfirm\tarchlinux-keyring\tasahi-alarm-keyring$' "$log_file" ||
fail "update-keyring skips $listed and still reinstalls the valid keyrings, and nothing else" "$(cat "$log_file")"
grep -Eq $'^sudo\tpacman\t-Sy\t--needed\t--noconfirm\tarchlinux-keyring\tasahi-alarm-keyring$' "$log_file" ||
fail "update-keyring skips $listed and still refreshes the valid keyrings, and nothing else" "$(cat "$log_file")"
done
rm -f "$platform_keyrings"
pass "update-keyring skips a platform list line naming anything but a keyring package, with a warning"
Expand Down