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
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Omarchy keeps no Mac code of its own. It knows which platform it runs on and giv

**Here, in the packages:**

- `omarchy-mac`: the files in the platform root (key names, the notch cutouts, display and audio hints, keyrings), the Mac's services (the Wi-Fi backend and resume recovery, microphone mapping, speaker safety), its setup and app hooks, battery charge limits, and the hardware video decode default.
- `omarchy-mac`: the files in the platform root (key names, the notch cutouts, display and audio hints), the Mac's services (the Wi-Fi backend and resume recovery, microphone mapping, speaker safety), its setup and app hooks, battery charge limits, and the hardware video decode default.
- `omarchy-mac-boot`: the Mac's lifecycle entrypoints and boot chain: the initramfs drop-ins and vendor firmware, in-place encryption, first boot, Limine and U-Boot, update verification, update takeover, factory reset and snapshot restore checks. Moving an existing Mac onto these packages is a standalone migration, not part of either package.

**Some examples:**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ make_keyring() {
splash_progress 5 "Setting up secure updates..."
rm -f "$keyring_record"
rm -rf "$keyring_dir"
local -a keyrings=(archlinuxarm asahi-alarm)
local -a keyrings=(archlinuxarm)
[[ ! -f $keyring_import_dir/omarchy.gpg ]] || keyrings+=(omarchy)
pacman-key --gpgdir "$keyring_dir" --init >>"$log_file" 2>&1 &&
pacman-key --gpgdir "$keyring_dir" --populate-from "$keyring_import_dir" --populate "${keyrings[@]}" \
Expand Down
6 changes: 3 additions & 3 deletions omarchy-mac-boot/test/mac-first-boot-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ expect_handoff "keyring init"
"$case_dir/pacman-key.log") == $'init\npopulate' ]] ||
fail "pacman-key initializes and populates the existing platform policy in order"
! grep -Eq -- '--(add|lsign-key)' "$case_dir/pacman-key.log" || fail "first boot imports no additional repository key"
grep -Eq -- '--populate archlinuxarm asahi-alarm omarchy$' "$case_dir/pacman-key.log" ||
grep -Eq -- '--populate archlinuxarm omarchy$' "$case_dir/pacman-key.log" ||
fail "the Omarchy release keyring is populated when omarchy-keyring ships it (omarchy-update-keyring requires it)"

new_case keyring-retry
Expand All @@ -523,8 +523,8 @@ mv "$case_dir/omarchy-provision-owner" "$root/usr/bin/omarchy-provision-owner"
: >"$case_dir/systemctl.log"
expect_handoff "retry after keyring init"
[[ $(grep -c -- '--init' "$case_dir/pacman-key.log") == 1 ]] || fail "a retry does not initialise the keyring again"
grep -Eq -- '--populate archlinuxarm asahi-alarm$' "$case_dir/pacman-key.log" ||
fail "without omarchy.gpg the populate list stays archlinuxarm asahi-alarm"
grep -Eq -- '--populate archlinuxarm$' "$case_dir/pacman-key.log" ||
fail "without omarchy.gpg only Arch Linux ARM's keyring is populated"

new_case no-rearm-provisioning
write_esp 'format=1' 'encrypt=0'
Expand Down
10 changes: 9 additions & 1 deletion omarchy-mac/README.md

Large diffs are not rendered by default.

137 changes: 137 additions & 0 deletions omarchy-mac/bin/omarchy-mac-drop-asahi-alarm
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
#!/bin/bash
# Moves this Mac off the [asahi-alarm] repository: drops its pacman.conf
# section, then the asahi-alarm-keyring package and its signing key. Omarchy
# builds every package Macs took from it, and this package is only published
# with them. Machine-wide and idempotent: omarchy-mac-drop-asahi-alarm.service
# runs it as root at boot and after every pacman transaction until it records
# a verified cleanup, and again if [asahi-alarm] comes back. Anything that still needs the keyring leaves everything
# in place for the next run, since omarchy-update-keyring reinstalls a listed
# keyring from a repository that must still exist.
set -euo pipefail

state=${OMARCHY_MAC_ASAHI_ALARM_STATE:-/var/lib/omarchy/mac-drop-asahi-alarm}
pacman_conf=${OMARCHY_MAC_PACMAN_CONF:-/etc/pacman.conf}
platform_keyrings=${OMARCHY_MAC_PLATFORM_KEYRINGS:-/usr/share/omarchy-platform/keyrings}
pacman_lock=${OMARCHY_MAC_PACMAN_LOCK:-/var/lib/pacman/db.lck}
lock_wait=${OMARCHY_MAC_PACMAN_LOCK_WAIT:-600}
repo=asahi-alarm
keyring=asahi-alarm-keyring
key=12CE6799A94A3F1B5DDFFE88F576553597FB8FEB
# Each package Omarchy builds in place of asahi-alarm's, as old:new.
imports=(asahi-scripts:aurora-scripts asahi-fwextract:aurora-fwextract lzfse:lzfse
speakersafetyd:speakersafetyd bankstown:bankstown triforce-lv2:triforce-lv2
widevine:widevine muvm:muvm FEX-Emu:fex-emu)

pending() {
echo "Pending: $*"
exit 0
}

omarchy-hw-apple-silicon || exit 0
# An older Omarchy's pacman templates still carry [asahi-alarm], so a channel
# switch or omarchy-refresh-pacman can write it back after the move. done only
# stands for a pacman.conf without it.
if [[ -e $state/done ]]; then
pacman-conf --config "$pacman_conf" --repo-list | grep -qx "$repo" || exit 0
echo "[$repo] is back in $pacman_conf; moving off it again"
rm -f "$state/done"
fi
install -d -m 0755 "$state"
exec {lock_fd}>"$state/lock"
flock -n "$lock_fd" || pending "another run is in progress"

# Queued by a pacman hook, so the transaction that queued it may still hold
# the database. Never run pacman under someone else's transaction.
for (( waited = 0; waited < lock_wait; waited++ )); do
[[ -e $pacman_lock ]] || break
sleep 1
done
[[ ! -e $pacman_lock ]] || pending "pacman is still busy"

repos=$(pacman-conf --config "$pacman_conf" --repo-list)
has_repo() { grep -qx "$repo" <<<"$repos"; }

if has_repo; then
# What came from the repository, kept from the first run so a retry after
# the section is gone still knows.
if [[ ! -e $state/inventory ]]; then
comm -12 <(pacman -Slq "$repo" | sort -u) <(pacman -Qq | sort) >"$state/inventory.new"
mv -f "$state/inventory.new" "$state/inventory"
Comment on lines +58 to +59

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Failed queries erase package warnings

If the repository database is missing or unreadable, pacman -Slq can fail without making comm fail. The helper then saves an empty inventory file and never rebuilds it. Later reports permanently miss packages that no longer get updates. Check that both package queries succeed before saving the inventory.

fi

for import in "${imports[@]}"; do
pacman -Q -- "${import%%:*}" &>/dev/null || continue
pacman -Si "omarchy/${import#*:}" &>/dev/null ||
pending "omarchy/${import#*:} is not in this channel's database yet"
done
if pacman -Q -- "$keyring" &>/dev/null; then
required_by=$(LC_ALL=C pacman -Qi -- "$keyring" | sed -n 's/^Required By *: //p')
[[ $required_by == "None" ]] || pending "$required_by still requires $keyring"
fi
if [[ -f $platform_keyrings ]] && grep -qx "[[:space:]]*${keyring}[[:space:]]*" "$platform_keyrings"; then
pending "$platform_keyrings still lists $keyring"
fi

# Rewrite the file pacman reads, through a symlink if there is one, keeping
# its mode and owner. Sections end where pacman sees the next header.
target=$(readlink -f -- "$pacman_conf")
new=$(mktemp "$target.XXXXXX")
trap 'rm -f "$new"' EXIT
awk -v drop="[$repo]" '
{ header = $0; gsub(/^[[:space:]]+|[[:space:]]+$/, "", header) }
header ~ /^\[.*\]$/ { skip = (header == drop) }
!skip
' "$target" >"$new"
chmod --reference="$target" "$new"
chown --reference="$target" "$new"
if [[ $(pacman-conf --config "$new" --repo-list) != "$(grep -vx "$repo" <<<"$repos")" ]]; then
echo "Could not remove [$repo] from $target by itself; remove it by hand" >&2
exit 1
fi
[[ -e $target.bak-asahi-alarm ]] || cp -p -- "$target" "$target.bak-asahi-alarm"
mv -f -- "$new" "$target"
trap - EXIT
repos=$(pacman-conf --config "$pacman_conf" --repo-list)
fi

if pacman -Q -- "$keyring" &>/dev/null; then
required_by=$(LC_ALL=C pacman -Qi -- "$keyring" | sed -n 's/^Required By *: //p')
[[ $required_by == "None" ]] || pending "$required_by still requires $keyring"
pacman -R --noconfirm -- "$keyring" || pending "$keyring could not be removed yet"
fi
# Removing the keyring package never removes its key from pacman's keyring.
if pacman-key --list-keys "$key" &>/dev/null; then
pacman-key --delete "$key"
fi

# What the repository carried that this channel's [omarchy] doesn't take over.
report=()
if [[ -s $state/inventory ]]; then
while IFS= read -r package; do
[[ $package != "$keyring" ]] && local_version=$(pacman -Q -- "$package" 2>/dev/null) || continue
local_version=${local_version#* }
renamed=""
for import in "${imports[@]}"; do
[[ ${import%%:*} == "$package" && ${import#*:} != "$package" ]] && renamed=${import#*:}
done
if [[ -n $renamed ]]; then
report+=("$package $local_version: replaced by omarchy/$renamed at the next update")
elif sync_version=$(LC_ALL=C pacman -Si "omarchy/$package" 2>/dev/null | sed -n 's/^Version *: //p') &&
[[ -n $sync_version ]]; then
if (( $(vercmp "$local_version" "$sync_version") > 0 )); then
report+=("$package $local_version: newer than omarchy's $sync_version, so pacman keeps it; switch with: pacman -S omarchy/$package")
fi
elif ! pacman -Si -- "$package" &>/dev/null; then
report+=("$package $local_version: no repository carries it any more, so it gets no updates")
fi
done <"$state/inventory"
fi
printf '%s\n' ${report[@]+"${report[@]}"} >"$state/report"
(( ${#report[@]} == 0 )) || printf '%s\n' "Left from [$repo]:" "${report[@]}"

# Done only once all three are verifiably gone.
! grep -qx "$repo" <<<"$(pacman-conf --config "$pacman_conf" --repo-list)" || pending "[$repo] is still configured"
! pacman -Q -- "$keyring" &>/dev/null || pending "$keyring is still installed"
! pacman-key --list-keys "$key" &>/dev/null || pending "key $key is still in pacman's keyring"
: >"$state/done"
echo "Removed [$repo], $keyring and its key"
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Queue the move off [asahi-alarm] after every transaction until it is done,
# and again whenever [asahi-alarm] is back in pacman.conf.
# The unit waits for this transaction to release the database, so pacman never
# runs inside pacman.
[Trigger]
Type = Package
Operation = Install
Operation = Upgrade
Target = *
Comment on lines +7 to +9

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Removals do not retry cleanup

The hook runs after installs and upgrades, but not removals. If cleanup is waiting for a package that requires asahi-alarm-keyring, removing that package does not queue another attempt. Cleanup waits for a reboot or an unrelated install or upgrade. Add Operation = Remove so removing the last blocker also retries cleanup.

Suggested change
Operation = Install
Operation = Upgrade
Target = *
Operation = Install
Operation = Upgrade
Operation = Remove
Target = *

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!


[Action]
Description = Queueing the asahi-alarm cleanup...
When = PostTransaction
# Skipped in a chroot or an unbooted root, like 90-omarchy-mac-touchid.hook.
# --no-block returns at once and never fails the transaction.
Exec = /usr/bin/sh -c 'systemd-detect-virt --quiet --chroot || ! systemd-notify --booted || { [ -e /var/lib/omarchy/mac-drop-asahi-alarm/done ] && ! pacman-conf --repo-list 2>/dev/null | grep -qx asahi-alarm; } || systemctl --quiet --no-block start omarchy-mac-drop-asahi-alarm.service; true'
4 changes: 0 additions & 4 deletions omarchy-mac/share/omarchy-platform/keyrings

This file was deleted.

6 changes: 3 additions & 3 deletions omarchy-mac/test/desktop-setup-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ for entry in setup-system setup-user; do
fail "the $entry entrypoint is staged for omarchy-lifecycle-dispatch"
done
platform=$stage/usr/share/omarchy-platform
for file in key-names display-cutouts.json displays.conf keyrings audio.json fingerprint-readers; do
for file in key-names display-cutouts.json displays.conf audio.json fingerprint-readers; do
[[ -f $platform/$file && ! -L $platform/$file ]] || fail "$file is staged in the platform root"
done
[[ $(grep -v '^#' "$platform/keyrings") == asahi-alarm-keyring ]] ||
fail 'the platform names the [asahi-alarm] keyring for omarchy update to refresh'
[[ ! -e $platform/keyrings ]] ||
fail 'the platform names no keyring: a Mac adds no signed repository to Arch Linux ARM and Omarchy'
[[ $(grep -v '^#' "$platform/fingerprint-readers") == $'/run/omarchy-mac/touchid ready\n/run/omarchy-mac/touchid available' ]] ||
fail 'the platform names Touch ID by its status: ready to enrol and match, or available to turn on'
python3 -c 'import json, sys; json.load(open(sys.argv[1]))' "$platform/display-cutouts.json" ||
Expand Down
Loading
Loading