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
36 changes: 31 additions & 5 deletions bin/omarchy-update-system-pkgs-when-conflicted
Original file line number Diff line number Diff line change
Expand Up @@ -94,17 +94,43 @@ mapfile -t leftovers < <(
)
((${#leftovers[@]})) || exit 1

# On Apple Silicon the boot chain, initramfs, and pacman configuration are
# platform-owned: the Asahi image writes them and nothing in Omarchy's packages
# may take them over. Quarantining one of these would leave the machine
# unbootable or unable to update, so refuse the whole report instead.
# On Apple Silicon the boot chain and pacman configuration are platform-owned:
# the Asahi image writes them and nothing in Omarchy's packages may take them
# over. Quarantining one of these would leave the machine unbootable or unable
# to update, so refuse the whole report instead. So does an mkinitcpio file
# whose own HOOKS carry the asahi or busybox encrypt hook: the HOOKS baseline
# sorts before it, so replacing it switches a legacy Mac's initramfs to the
# systemd line while GRUB still unlocks with cryptdevice=. The memory, USB and
# other mkinitcpio drop-ins omarchy-settings ships on aarch64 too may go.
# omarchy-mac-boot's update-takeover entrypoint carries the same list.
#
# A top-level line only: an indented one sits in a branch, as in the HOOKS
# baseline itself, and doesn't say what this Mac boots. An unreadable file
# can't be checked, so it counts.
apple_platform_hooks() {
[[ -e $1 ]] || return 1
[[ -r $1 ]] || return 0
grep -Eq '^HOOKS\+?=\(([^)#]*[[:space:]])?(asahi|encrypt)([[:space:]][^)#]*)?\)' "$1"
}
if omarchy-hw-apple-silicon; then
for path in "${leftovers[@]}"; do
case "$path" in
/boot|/boot/*|/etc/default/grub|/etc/grub|/etc/grub/*|/etc/limine|/etc/limine/*|/etc/mkinitcpio*|/etc/modprobe.d/omarchy-usb-autosuspend.conf|/etc/pacman.conf|/etc/pacman.d|/etc/pacman.d/*|/etc/systemd/oomd.conf.d|/etc/systemd/oomd.conf.d/*|/etc/tmpfiles.d/omarchy-zswap.conf|/usr/lib/initcpio|/usr/lib/initcpio/*|/usr/lib/systemd/user/app.slice.d|/usr/lib/systemd/user/app.slice.d/*|/usr/lib/systemd/zram-generator.conf.d|/usr/lib/systemd/zram-generator.conf.d/*)
/boot|/boot/*|/etc/default/grub|/etc/grub|/etc/grub/*|/etc/limine|/etc/limine/*|/etc/pacman.conf|/etc/pacman.d|/etc/pacman.d/*|/usr/lib/initcpio|/usr/lib/initcpio/*)
echo "Refusing to replace Apple Silicon platform path: $path" >&2
exit 1
;;
/etc/mkinitcpio.conf)
if apple_platform_hooks "$path"; then
echo "Refusing to replace $path: its HOOKS set how this Mac's initramfs unlocks and boots" >&2
exit 1
fi
;;
/etc/mkinitcpio.conf.d/*)
if apple_platform_hooks "$path"; then
echo "Refusing to replace $path: its HOOKS set how this Mac's initramfs unlocks and boots; move that HOOKS line into /etc/mkinitcpio.conf, then run omarchy update again" >&2
exit 1
fi
;;
esac
done
fi
Expand Down
2 changes: 1 addition & 1 deletion packages/omarchy-mac/boot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This subtree is built into `omarchy-mac-boot`, separately from the kernel-neutra

While first boot keeps the splash up, a laptop with its lid open shows it on the built-in screen only: `70-omarchy-mac-external-displays.rules` has `/usr/lib/omarchy/mac-boot/external-displays hold` force the Apple display card's external connectors off as the card appears, before Plymouth sees it. The lid is read from the kernel's lid switch (`/usr/lib/omarchy/mac-boot/lid-state`), since the card can appear before logind starts. Nothing is held on a shut or unknown lid, a desktop Mac or once the splash is over. `omarchy-mac-external-displays.service` turns them back on after Plymouth quits and owner setup or a password reset on tty1 ends, before the display manager starts, with a synthetic hotplug so the compositor rescans them. A held display may wake to a black console rather than stay asleep (the kernel console can light it before the hold), and a boot that never reaches multi-user.target keeps it off.

The implementation was moved from runtime integration `e82fe3c8850b184dfa22eefd571646ad85446122`, preserving Marcelo's provenance recorded in the runtime source-port ledger. The payload in `files/` comes from the boot recipe paired with #503 (omarchy-mac/omarchy-pkgs-aarch64#65 at `617a907f99a1`) with maralcbr/omarchy-pkgs#202 applied (omarchy-mac-boot 20260921-10: the owner's keyboard layout and dock keyboards at the disk prompt). The owner wizard, recovery-slot operations, journal/retry handling and shared Limine menu/hash operations remain core code. Hardware setup reaches its setup leaves through `omarchy-lifecycle-dispatch setup-boot [image-first-boot]` (`entrypoints/setup-boot`: `setup/grub-console.sh`, then `setup/limine-boot.sh`, which on an image's first boot asks for the deferred rebuild instead of building the UKI); the image builder and the migration engine source them directly. `entrypoints/update-takeover <path>...` answers an update that wants to move aside files no package owns (the step 6 seam asks before it moves anything): read-only, it refuses the whole takeover when any path is the Mac's boot chain, initramfs or pacman configuration, which its image and this package write, and lets anything else go. Owner provisioning, factory reset and `omarchy-drive-password` reach this package only through `omarchy-lifecycle-dispatch`, which runs the `entrypoints/` staged in `/usr/lib/omarchy/mac-boot` and fails on Apple Silicon when they are missing.
The implementation was moved from runtime integration `e82fe3c8850b184dfa22eefd571646ad85446122`, preserving Marcelo's provenance recorded in the runtime source-port ledger. The payload in `files/` comes from the boot recipe paired with #503 (omarchy-mac/omarchy-pkgs-aarch64#65 at `617a907f99a1`) with maralcbr/omarchy-pkgs#202 applied (omarchy-mac-boot 20260921-10: the owner's keyboard layout and dock keyboards at the disk prompt). The owner wizard, recovery-slot operations, journal/retry handling and shared Limine menu/hash operations remain core code. Hardware setup reaches its setup leaves through `omarchy-lifecycle-dispatch setup-boot [image-first-boot]` (`entrypoints/setup-boot`: `setup/grub-console.sh`, then `setup/limine-boot.sh`, which on an image's first boot asks for the deferred rebuild instead of building the UKI); the image builder and the migration engine source them directly. `entrypoints/update-takeover <path>...` answers an update that wants to move aside files no package owns (the step 6 seam asks before it moves anything): read-only, it refuses the whole takeover when any path is the Mac's boot chain, `/usr/lib/initcpio` or pacman configuration, which its image and this package write, or an mkinitcpio file whose own `HOOKS` carry the `asahi` or busybox `encrypt` hook (a legacy Mac's unlock), and lets anything else go, including the memory, USB and mkinitcpio drop-ins omarchy-settings ships on aarch64 too. Owner provisioning, factory reset and `omarchy-drive-password` reach this package only through `omarchy-lifecycle-dispatch`, which runs the `entrypoints/` staged in `/usr/lib/omarchy/mac-boot` and fails on Apple Silicon when they are missing.

## Temporary adaptations

Expand Down
47 changes: 38 additions & 9 deletions packages/omarchy-mac/boot/entrypoints/update-takeover
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,51 @@

# omarchy-lifecycle-dispatch update-takeover <path>..., run before an update
# moves aside files no package owns so an Omarchy package's upgrade can install
# its own. Read-only. The Mac's boot chain, initramfs and pacman configuration
# are written by its image and this package, not Omarchy's packages, and moving
# one aside can leave the Mac unable to boot or update: any such path refuses
# the whole takeover (exit 1), so every file stays. Anything else may go.
# its own. Read-only. The Mac's boot chain and pacman configuration are written
# by its image and this package, not Omarchy's packages, and moving one aside
# can leave the Mac unable to boot or update: any such path refuses the whole
# takeover (exit 1), so every file stays. So does an mkinitcpio file whose own
# HOOKS line carries the asahi or busybox encrypt hook: the HOOKS baseline sorts
# before it, so replacing it switches a legacy Mac's initramfs to the systemd
# line while GRUB still unlocks with cryptdevice=. Anything else may go,
# including the memory, USB and mkinitcpio drop-ins omarchy-settings ships on
# aarch64 too.

set -euo pipefail

# Unprivileged tests stage the files under a fixture root.
root=""
if (( EUID != 0 )); then
root=${OMARCHY_MAC_BOOT_ROOT:-}
fi

# A top-level line only: an indented one sits in a branch, as in the HOOKS
# baseline itself, and doesn't say what this Mac boots. An unreadable file
# can't be checked, so it counts.
platform_hooks() {
[[ -e $root$1 ]] || return 1
[[ -r $root$1 ]] || return 0
grep -Eq '^HOOKS\+?=\(([^)#]*[[:space:]])?(asahi|encrypt)([[:space:]][^)#]*)?\)' "$root$1"
}

for path in "$@"; do
case $path in
/boot | /boot/* | /etc/default/grub | /etc/grub | /etc/grub/* | /etc/limine | /etc/limine/* | /etc/mkinitcpio* | \
/etc/modprobe.d/omarchy-usb-autosuspend.conf | /etc/pacman.conf | /etc/pacman.d | /etc/pacman.d/* | \
/etc/systemd/oomd.conf.d | /etc/systemd/oomd.conf.d/* | /etc/tmpfiles.d/omarchy-zswap.conf | \
/usr/lib/initcpio | /usr/lib/initcpio/* | /usr/lib/systemd/user/app.slice.d | /usr/lib/systemd/user/app.slice.d/* | \
/usr/lib/systemd/zram-generator.conf.d | /usr/lib/systemd/zram-generator.conf.d/*)
/boot | /boot/* | /etc/default/grub | /etc/grub | /etc/grub/* | /etc/limine | /etc/limine/* | \
/etc/pacman.conf | /etc/pacman.d | /etc/pacman.d/* | /usr/lib/initcpio | /usr/lib/initcpio/*)
echo "Refusing to replace Apple Silicon platform path: $path" >&2
exit 1
;;
/etc/mkinitcpio.conf)
if platform_hooks "$path"; then
echo "Refusing to replace $path: its HOOKS set how this Mac's initramfs unlocks and boots" >&2
exit 1
fi
;;
/etc/mkinitcpio.conf.d/*)
if platform_hooks "$path"; then
echo "Refusing to replace $path: its HOOKS set how this Mac's initramfs unlocks and boots; move that HOOKS line into /etc/mkinitcpio.conf, then run omarchy update again" >&2
exit 1
fi
;;
esac
done
62 changes: 51 additions & 11 deletions packages/omarchy-mac/boot/test/mac-update-takeover-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,64 @@ set -euo pipefail
source "$(dirname "$0")/base-test.sh"

# update-takeover, which omarchy-lifecycle-dispatch runs before an update moves
# aside files no package owns: the Mac's boot chain, initramfs and pacman
# configuration refuse the whole takeover; anything else may go.
# aside files no package owns: the Mac's boot chain and pacman configuration
# refuse the whole takeover, and so does an mkinitcpio file whose own HOOKS carry
# the asahi or busybox encrypt hook; anything else may go.
work=$(mktemp -d)
trap 'rm -rf "$work"' EXIT
"$ROOT/install" "$work/root"
takeover=$work/root/usr/lib/omarchy/mac-boot/update-takeover
[[ -x $takeover && $(stat -c %a "$takeover") == 755 ]] || fail 'the update-takeover entrypoint is staged for omarchy-lifecycle-dispatch'
fixture=$work/fixture
export OMARCHY_MAC_BOOT_ROOT=$fixture

refuses() {
local expected=$1 status=0 output
shift
output=$("$takeover" /usr/share/omarchy/ok "$@" 2>&1) || status=$?
(( status == 1 )) && [[ $output == "$expected" ]] || fail "refused: $*" "status $status: $output"
}

"$takeover" || fail 'no path, nothing to refuse'
"$takeover" /usr/share/omarchy/default/foo /etc/xdg/omarchy.conf /usr/bin/omarchy-new ||
fail 'files outside the platform paths may be taken over'
for path in /boot /boot/efi/limine.conf /etc/default/grub /etc/grub/themes/x /etc/limine/x /etc/mkinitcpio.conf \
/etc/mkinitcpio.conf.d/omarchy_hooks.conf /etc/modprobe.d/omarchy-usb-autosuspend.conf /etc/pacman.conf /etc/pacman.d/mirrorlist \
/etc/systemd/oomd.conf.d/10-omarchy.conf /etc/tmpfiles.d/omarchy-zswap.conf /usr/lib/initcpio/install/x \
/usr/lib/systemd/user/app.slice.d/10-oomd.conf /usr/lib/systemd/zram-generator.conf.d/90-omarchy.conf; do
status=0
output=$("$takeover" /usr/share/omarchy/ok "$path" 2>&1) || status=$?
(( status == 1 )) && [[ $output == "Refusing to replace Apple Silicon platform path: $path" ]] ||
fail "a platform path refuses the whole takeover: $path" "status $status: $output"
for path in /boot /boot/efi/limine.conf /etc/default/grub /etc/grub/themes/x /etc/limine/x /etc/pacman.conf \
/etc/pacman.d/mirrorlist /usr/lib/initcpio /usr/lib/initcpio/install/x; do
refuses "Refusing to replace Apple Silicon platform path: $path" "$path"
done
pass 'the boot chain, pacman configuration and initcpio refuse the takeover'

# omarchy-settings ships these on aarch64 too, so an unowned copy must not stop
# every update.
settings=(/etc/mkinitcpio.conf.d/omarchy_hooks.conf /etc/mkinitcpio.conf.d/00-omarchy-hooks.conf
/etc/mkinitcpio.conf.d/thunderbolt_module.conf /etc/modprobe.d/omarchy-usb-autosuspend.conf
/etc/systemd/oomd.conf.d/10-omarchy.conf /etc/systemd/zram-generator.conf /etc/tmpfiles.d/omarchy-zswap.conf
/usr/lib/systemd/user/app.slice.d/10-oomd.conf /usr/lib/systemd/zram-generator.conf.d/90-omarchy.conf)
"$takeover" "${settings[@]}" || fail 'the drop-ins omarchy-settings ships on aarch64 may be taken over (absent)'
mkdir -p "$fixture/etc/mkinitcpio.conf.d"
printf '%s\n' '# Omarchy' 'MODULES+=(thunderbolt)' >"$fixture/etc/mkinitcpio.conf.d/thunderbolt_module.conf"
printf '%s\n' 'HOOKS=(base systemd plymouth autodetect microcode modconf kms keyboard sd-vconsole block sd-encrypt filesystems fsck)' \
>"$fixture/etc/mkinitcpio.conf.d/omarchy_hooks.conf"
"$takeover" "${settings[@]}" || fail 'a drop-in without asahi or busybox encrypt may be taken over'
printf '%s\n' '#HOOKS=(base udev asahi encrypt filesystems)' 'HOOKS=(base systemd block filesystems) # encrypt' \
>"$fixture/etc/mkinitcpio.conf.d/omarchy_hooks.conf"
"$takeover" /etc/mkinitcpio.conf.d/omarchy_hooks.conf || fail 'commented hooks do not count'
# The HOOKS baseline's own lines sit in its branches.
cp "$ROOT/../../../etc/mkinitcpio.conf.d/00-omarchy-hooks.conf" "$fixture/etc/mkinitcpio.conf.d/00-omarchy-hooks.conf"
grep -q '^ .*HOOKS=(.* encrypt ' "$fixture/etc/mkinitcpio.conf.d/00-omarchy-hooks.conf" || fail 'the baseline fixture has its busybox branch'
"$takeover" /etc/mkinitcpio.conf.d/00-omarchy-hooks.conf || fail 'an unowned copy of the HOOKS baseline may be taken over'
pass 'the memory, USB and mkinitcpio drop-ins omarchy-settings ships on aarch64 may be taken over'

# A legacy Mac whose drop-in carries its unlock: the baseline sorts first, so
# the drop-in's line is the one its initramfs boots with.
for line in 'HOOKS=(base udev autodetect modconf kms keyboard keymap consolefont block encrypt filesystems fsck)' \
'HOOKS=(base udev asahi block filesystems fsck)' 'HOOKS+=(encrypt)' 'HOOKS=(encrypt filesystems)' 'HOOKS=(base asahi)'; do
printf '# Omarchy\n%s\n' "$line" >"$fixture/etc/mkinitcpio.conf.d/omarchy_hooks.conf"
refuses "Refusing to replace /etc/mkinitcpio.conf.d/omarchy_hooks.conf: its HOOKS set how this Mac's initramfs unlocks and boots; move that HOOKS line into /etc/mkinitcpio.conf, then run omarchy update again" \
/etc/mkinitcpio.conf.d/omarchy_hooks.conf /etc/systemd/oomd.conf.d/10-omarchy.conf
done
pass 'the boot chain, initramfs and pacman configuration refuse the takeover; other files may go'
printf '%s\n' 'HOOKS=(base udev autodetect modconf kms keyboard keymap block encrypt filesystems fsck)' >"$fixture/etc/mkinitcpio.conf"
refuses "Refusing to replace /etc/mkinitcpio.conf: its HOOKS set how this Mac's initramfs unlocks and boots" /etc/mkinitcpio.conf
printf '%s\n' 'HOOKS=(base systemd autodetect block sd-encrypt filesystems fsck)' >"$fixture/etc/mkinitcpio.conf"
"$takeover" /etc/mkinitcpio.conf || fail 'an mkinitcpio.conf without asahi or busybox encrypt may be taken over'
pass 'an mkinitcpio file carrying the asahi or busybox encrypt hook refuses the takeover'
14 changes: 14 additions & 0 deletions test/shell.d/update-file-conflict-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,20 @@ grep -Fq 'Refusing to replace Apple Silicon platform path' "$test_tmp/err" ||
fail "an Apple Silicon platform-path conflict reaches a retry"
pass "Apple Silicon platform paths are never moved for package conflicts"

# omarchy-settings ships its memory, USB and mkinitcpio drop-ins on aarch64 too,
# so an unowned copy on a Mac is no longer refused. The live path can't be
# staged here: the move fails after the check, which is what this looks for.
for path in /etc/modprobe.d/omarchy-usb-autosuspend.conf /etc/systemd/oomd.conf.d/10-omarchy.conf \
/etc/tmpfiles.d/omarchy-zswap.conf /usr/lib/systemd/user/app.slice.d/10-oomd.conf \
/usr/lib/systemd/zram-generator.conf.d/90-omarchy.conf /etc/mkinitcpio.conf.d/zz-omarchy-test-absent.conf; do
fresh_work
write_report omarchy-settings "$path"
APPLE_SILICON=1 run_update >"$test_tmp/out" 2>"$test_tmp/err" || true
! grep -Fq 'Refusing to replace' "$test_tmp/err" ||
fail "an aarch64 omarchy-settings drop-in is refused on Apple Silicon: $path"
done
pass "the drop-ins omarchy-settings ships on aarch64 are not refused on Apple Silicon"

# The path is used literally, so glob characters in a name mean nothing.
fresh_work
globby="$work/omarchy-[1].conf"
Expand Down
Loading