diff --git a/bin/omarchy-lifecycle-dispatch b/bin/omarchy-lifecycle-dispatch index f7eb628adf12..7117bc925bec 100755 --- a/bin/omarchy-lifecycle-dispatch +++ b/bin/omarchy-lifecycle-dispatch @@ -120,10 +120,29 @@ trusted() { entrypoint=$root$implementation/$operation +# The package's own pacman record tells a machine without it from one whose +# copy predates the operation. +installed_version() { + local record + for record in "$root/var/lib/pacman/local/$package"-[0-9]*/; do + [[ -d $record ]] || continue + record=${record%/} + printf '%s\n' "${record##*/"$package"-}" + return 0 + done + return 1 +} + +# 3 is a machine without the platform's boot package at all, which a caller may +# tell apart from a failure; 1 is everything else. if [[ ! -e $entrypoint && ! -L $entrypoint ]]; then if listed "$operation" "${required[@]}"; then + if version=$(installed_version); then + echo "Error: $operation on $platform needs $implementation/$operation, which $package $version does not provide; update $package" >&2 + exit 1 + fi echo "Error: $operation on $platform needs $package, which provides $implementation/$operation; it is not installed" >&2 - exit 1 + exit 3 fi exit 0 fi diff --git a/bin/omarchy-update b/bin/omarchy-update index e71e808664ee..5b2be966ba44 100755 --- a/bin/omarchy-update +++ b/bin/omarchy-update @@ -39,6 +39,7 @@ if [[ ${1:-} == "-y" ]] || omarchy-update-confirm; then omarchy-update-stay-awake start omarchy-update-dev + omarchy-update-boot preflight omarchy-update-keyring # Migrations ship with the packages installed here and are written against @@ -51,6 +52,11 @@ if [[ ${1:-} == "-y" ]] || omarchy-update-confirm; then omarchy-update-mise omarchy-update-orphan-pkgs + # The update is not finished, and offers no reboot, until the boot files the + # steps above left are shown to boot the updated system. + boot_verified=true + omarchy-update-boot verify || boot_verified=false + omarchy-update-analyze-logs omarchy-update-status @@ -60,5 +66,10 @@ if [[ ${1:-} == "-y" ]] || omarchy-update-confirm; then omarchy-update-stay-awake stop trap - EXIT - omarchy-update-restart + if [[ $boot_verified == "true" ]]; then + omarchy-update-restart + else + echo -e "\e[31m\nThe update is not finished: its boot files did not pass verification (see above). Do not reboot until omarchy update completes.\e[0m" >&2 + exit 1 + fi fi diff --git a/bin/omarchy-update-boot b/bin/omarchy-update-boot new file mode 100755 index 000000000000..c9271170193f --- /dev/null +++ b/bin/omarchy-update-boot @@ -0,0 +1,43 @@ +#!/bin/bash + +# omarchy:summary=Run the platform's boot checks around the update's package changes +# omarchy:args= +# omarchy:hidden=true +# omarchy:requires-sudo=true + +# preflight can refuse an update the platform could not boot afterwards, before +# any package changes. verify proves that the boot files the package steps left +# boot the updated system, and omarchy update neither finishes nor offers a +# reboot until it passes. Both are lifecycle dispatch operations: no-ops where +# the platform registers no boot package, x86 included, and the platform's own +# entrypoint says what failed. + +set -e + +case ${1:-} in + preflight | verify) operation=update-$1 ;; + *) + echo "Usage: omarchy-update-boot " >&2 + exit 2 + ;; +esac + +# Resolving as the user keeps sudo, and its password prompt, out of updates +# with nothing to run. Root resolves again from its own fixed paths before +# anything runs. +errors=$(mktemp) +trap 'rm -f "$errors"' EXIT +status=0 +resolved=$(omarchy-lifecycle-dispatch --resolve "$operation" 2>"$errors") || status=$? + +# 3: the platform's boot package is not installed at all. Such a machine +# predates it and boots a chain the package does not manage, so verification +# warns instead of failing every update until its migration installs it. +if (( status == 3 )) && [[ $operation == "update-verify" ]]; then + echo -e "\e[33m\n$(sed 's/^Error: //' "$errors")\nThe boot files were not verified. This machine predates its platform's boot package; updates verify them once its migration installs it.\e[0m" >&2 +elif (( status != 0 )); then + cat "$errors" >&2 + exit "$status" +elif [[ -n $resolved ]]; then + sudo omarchy-lifecycle-dispatch "$operation" +fi diff --git a/docs/lifecycle-dispatch.md b/docs/lifecycle-dispatch.md index 5c53ab6ab7f4..38f002f3803f 100644 --- a/docs/lifecycle-dispatch.md +++ b/docs/lifecycle-dispatch.md @@ -15,7 +15,8 @@ The first form runs the operation. `--resolve` prints the entrypoint the operati | --- | --- | --- | | The platform registers no boot package (`generic`, `generic-aarch64`, and `qualcomm` today) | no-op, exit 0 | prints nothing, exit 0 | | The entrypoint exists and passes the trust rules | execs it; its exit status is the result | prints its path | -| A required operation has no entrypoint | exit 1: `Error: on needs , which provides ; it is not installed` | same error | +| A required operation has no entrypoint, and the package is not installed | exit 3 (an entrypoint's own status could also be 3; with `--resolve` it is only this): `Error: on needs , which provides ; it is not installed` | same error | +| A required operation has no entrypoint, but the package is installed (its pacman record says so) | exit 1: `Error: on needs , which does not provide; update ` | same error | | An optional operation has no entrypoint | no-op, exit 0 | prints nothing, exit 0 | | The entrypoint fails the trust rules | exit 1: `Error: refusing : ...` (optional operations too) | same error | | `omarchy-hw-platform` can't settle the platform | exit 1 | exit 1 | @@ -33,9 +34,9 @@ The set is fixed in the dispatcher; adding one is an upstream change. The operat | `reset-prepare` | Factory reset, before switching to the factory root | Stages the platform's boot state (unlock, command line, rebuilt boot files) for the factory root | required | ticket 34 | | `reset-verify` | Factory reset, before committing the switch | Proves the factory root boots on this boot chain (kernel, firmware and DTB coherence, loader hashes) | required | ticket 34 | | `reset-rollback` | Factory reset, when anything fails after `reset-prepare` | Restores the previous boot state | required | ticket 34 | -| `update-preflight` | Update, before the package transaction | Refuses an update the platform can't boot afterwards | optional | ticket 35 | -| `update-verify` | Update, after the package transaction | Verifies the boot chain boots the updated system. A failure blocks completion. | required | ticket 35 | -| `boot-rebuild` | Whenever upstream rebuilds boot files: owner provisioning after a factory reset left entries for another machine identity, later kernel and initramfs hooks, snapshots and command-line changes | Rebuilds the platform's boot files, after upstream has started the Limine menu over where there is one | optional until tickets 35 and 36, then required | `omarchy-provision-owner`; tickets 35, 36 | +| `update-preflight` | Update, before the keyring and package transaction | Refuses an update the platform can't boot afterwards. A failure stops the update. | optional | `omarchy-update-boot preflight` (`omarchy update`) | +| `update-verify` | Update, after the last package step: the transaction, migrations, the post-update hook, AUR, mise and orphans | Read-only. Verifies the boot chain boots the updated system, whose new kernel may still wait for its reboot. A failure leaves the update unfinished: it exits non-zero and offers no reboot. | required | `omarchy-update-boot verify` (`omarchy update`) | +| `boot-rebuild` | Whenever upstream rebuilds boot files: owner provisioning after a factory reset left entries for another machine identity, later kernel and initramfs hooks, snapshots and command-line changes | Rebuilds the platform's boot files, after upstream has started the Limine menu over where there is one | optional until ticket 36, then required | `omarchy-provision-owner`; ticket 36 | ## Platform registration @@ -48,7 +49,7 @@ Registration is code in `bin/omarchy-lifecycle-dispatch`, not configuration. No The entrypoint for an operation is `/`. A registered platform's required operations must be shipped. Its optional operations may be left out, and then they are no-ops. -`omarchy-mac-boot` ships the provisioning entrypoints from 20260925-2 (ticket 32), and owner provisioning has no other Apple path, so they are required: a Mac whose `omarchy-mac-boot` is older stops before the owner form with the dispatcher's error naming the package, where the generic Limine path would leave the boot-partition key and `rd.luks.key=` behind. `boot-rebuild` stays optional until tickets 35 and 36 ship it. The reset and update operations are required now because nothing calls them yet. +`omarchy-mac-boot` ships the provisioning entrypoints from 20260925-2 (ticket 32), and owner provisioning has no other Apple path, so they are required: a Mac whose `omarchy-mac-boot` is older stops before the owner form with the dispatcher's error naming the package, where the generic Limine path would leave the boot-partition key and `rd.luks.key=` behind. `boot-rebuild` stays optional until ticket 36 ships it. The reset operations are required now because nothing calls them yet; `update-verify` is required, and `omarchy update` calls it (ticket 35). ## Trust rules @@ -72,6 +73,13 @@ A dispatch point takes one of two shapes: - After a factory reset left Limine entries for another machine identity, `refresh_boot_entries` starts the menu over from the template (core), then runs `boot-rebuild` if the platform implements it, and `limine-update` otherwise. - Everything else stays upstream: the wizard, account and login, the journal, slot retirement, the proof that the staged key opens nothing, and cleanup. +### Update (`bin/omarchy-update`) + +- `omarchy-update-boot preflight` runs after the dev checkout update and before the keyring and system packages change. A refusal stops the update like any failed step. +- `omarchy-update-boot verify` runs after the last package step. When it fails, the update still checks its log, refreshes the update indicator and releases Stay Awake, then says the update is not finished and exits 1 without `omarchy-update-restart`, so no reboot is offered. +- `omarchy-update-boot` resolves the operation as the user first and runs it with `sudo` only when it resolves to an entrypoint, so an update with nothing to run never asks for root. A failed resolution fails the step with the dispatcher's message, except one: `update-verify` on a machine without its platform's boot package at all (exit 3) warns that the boot files were not verified and lets the update finish. Such a machine predates the package and boots a chain it does not manage; its migration installs the package, and from then on a failed verification blocks. A package too old to ship `update-verify` blocks, since the fix is one package update away. +- The update path rebuilds no boot file itself: package hooks do, and `update-verify` catches what they missed. + ## Apple implementation `omarchy-mac-boot` implements the Apple operations. #503, landed as #527, moved the Apple boot code into `packages/omarchy-mac/boot/`, with sourced modules in `/usr/lib/omarchy-mac/boot` and commands in `/usr/bin`. Its modules become the implementation with small entrypoints around them (tickets 32, 34 and 35): @@ -84,8 +92,8 @@ A dispatch point takes one of two shapes: | `stage_luks_rekey_apple` in `lib/factory-reset.sh` | `reset-prepare` | Ticket 34 | | `rebuild_next_boot_apple` (factory-kernel coherence refusal, rebuild in the factory root, `verify_limine_hashes`) | `reset-prepare`, `reset-verify` | Ticket 34 | | mx-mac's reset rollback, not yet in #527 | `reset-rollback` | Ticket 34 | -| `omarchy-mac-boot-update` | `boot-rebuild` | Thin entrypoint around the existing command. Provisioning calls it once shipped; until tickets 35 and 36 ship it, Apple refreshes stale entries with `limine-update`, as #527 did. | -| `omarchy-apple-silicon-boot-check` | `update-verify` | Ticket 35 | +| `omarchy-mac-boot-update` | `boot-rebuild` | Thin entrypoint around the existing command. Provisioning calls it once shipped; until ticket 36 ships it, Apple refreshes stale entries with `limine-update`, as #527 did. The update path does not call it. | +| `omarchy-apple-silicon-boot-check` | `update-verify` | `entrypoints/update-verify` (ticket 35) runs the check limited to the boot chain (`--boot-chain`), with the new kernel's reboot allowed to be pending: the kernel and initramfs in `/boot`, the device-tree set, m1n1 stage 2 and U-Boot on the system ESP, and Limine's loader, menu and UKI on that same ESP. It holds only the kernel image, device trees and m1n1 against their packages, checks the kernel the boot menu starts first when both kernels are installed, and leaves out LUKS keyslots, provisioning leftovers and an m1n1 image its owner took over with `M1N1_UPDATE_DISABLED`. On failure it says not to reboot and how to rebuild the boot files. | - **Packaging:** `packages/omarchy-mac/boot/install` gains one loop that installs `entrypoints/*` as `/usr/lib/omarchy/mac-boot/`, mode 755. The modules stay where #527 put them and are sourced by absolute path. - **Owner and recovery slots:** #527's `rekey_luks_apple` sequence is folded into the shared journal. Its owner and recovery slot steps are core (`luks-rekey.sh`, `luks-recovery.sh`): the journal keeps a recovery slot once the owner acknowledged its key and retires every other one. Only its boot step is `provision-commit`. @@ -109,6 +117,7 @@ Snapdragon laptops boot Limine with unified kernel images, like x86, and `qualco - untrusted entrypoints - usage errors, and an undetermined platform - root ignoring fixture roots, `BASH_ENV` and exported functions +- `test/shell.d/update-boot-verify-test.sh` runs `omarchy update` through the real dispatcher: no-ops and no root on x86, generic aarch64 and Qualcomm; on Apple, preflight before the packages, and `omarchy-mac-boot`'s real `update-verify` and boot check on a fixture Mac, where a wrong device tree, a stale m1n1 or a missing UKI fails the update without offering the reboot. - `test/shell.d/luks-rekey-journal-test.sh` runs owner provisioning through the real dispatcher: - the crash-and-resume matrix on x86 (Limine UKI path unchanged, no Mac entrypoint runs) and on Apple with a fake boot package - setup stopping before the owner form when the boot package is not ready, missing, or too old to ship the provisioning entrypoints diff --git a/docs/update-process.md b/docs/update-process.md index efecb94c0ede..57339822898d 100644 --- a/docs/update-process.md +++ b/docs/update-process.md @@ -130,12 +130,17 @@ omarchy-update │ installed but unconfigured fails the snapshot loudly, pointing at │ install/config/snapper.sh, and the update continues without one) ├─ omarchy-update-stay-awake start - ├─ run package updates, migrations, hooks, and log analysis + ├─ omarchy-update-boot preflight + │ └─ the platform's boot package can refuse the update before packages change + ├─ run package updates, migrations and hooks + ├─ omarchy-update-boot verify + │ └─ the platform's boot package proves the boot files boot the updated system + ├─ log analysis ├─ omarchy-update-status │ └─ refresh or clear the shell update indicator ├─ omarchy-update-stay-awake stop │ └─ release the sleep inhibitor and restore shell idle state, if changed - └─ omarchy-update-restart + └─ omarchy-update-restart, only when the boot files were verified ``` Important behavior: @@ -152,6 +157,7 @@ Important behavior: `omarchy-migrate` after pacman finishes. - A failure should leave enough output in `/tmp/omarchy-update.log` and the terminal transcript to debug. +- Both boot checks are [lifecycle dispatch](lifecycle-dispatch.md) operations (`update-preflight`, `update-verify`), no-ops on platforms whose boot chain needs no handling of its own, x86 included. A refused preflight stops the update like any failed step. A failed verification lets the update finish its remaining reporting steps, then it exits non-zero without `omarchy-update-restart`: the update is not finished and offers no reboot. On Apple Silicon, `omarchy-mac-boot` verifies what the next boot reads: the kernel, initramfs and unlock settings, m1n1 stage 2 with the kernel's device trees and U-Boot on the system ESP, and Limine's loader, menu and UKI on that ESP. A Mac without `omarchy-mac-boot` at all predates it: the update warns that its boot files were not verified and finishes. ## Path 2: direct `sudo pacman -Syu` attempt @@ -291,6 +297,7 @@ scripts. | `omarchy-update-mise` | Runs `MISE_MINIMUM_RELEASE_AGE=0 mise up` for mise-managed tools — the override of mise's release-age cooldown is the point. | **Keep.** Mise-managed tools are intentionally part of the blessed update path. | | `omarchy-update-orphan-pkgs` | Lists orphans and prompts before removal; noninteractive mode never removes. | **Keep for now.** Safe because it is prompt-only. | | `omarchy-update-analyze-logs` | Scans `/tmp/omarchy-update.log` for known failure patterns, currently initramfs generation. | **Keep/expand.** Useful safety net; should grow only for high-signal checks. | +| `omarchy-update-boot` | Hidden helper that runs the platform's `update-preflight` and `update-verify` lifecycle operations through `omarchy-lifecycle-dispatch`. | **Keep internal/hidden.** Keeps platform boot checks out of the pipeline and stubbable in tests. | | `omarchy-update-restart` | Prompts for reboot after kernel/Hyprland updates, restarts components with `restart-*-required` markers, and always restarts the shell. | **Keep.** Important final step; may eventually include service-restart checks. | | `omarchy-update-firmware` | Manual firmware update command using fwupd. Not part of the normal update pipeline. | **Keep separate.** Firmware is not a routine system update step. | | `omarchy-update-time` | Restarts `systemd-timesyncd`. | **Question.** Not really an update command. Consider renaming/moving under system/time maintenance. | diff --git a/packages/omarchy-mac/boot/README.md b/packages/omarchy-mac/boot/README.md index 5dae04b979ff..4174cec1cf7c 100644 --- a/packages/omarchy-mac/boot/README.md +++ b/packages/omarchy-mac/boot/README.md @@ -2,7 +2,7 @@ This subtree is built into `omarchy-mac-boot`, separately from the kernel-neutral `omarchy-mac` hardware package. `../install` intentionally does not stage this directory. The boot recipe pins a runtime revision, the same one as the desktop candidate, and stages this subtree from it; the recipe keeps only packaging metadata and the pacman scriptlet. -`install DESTDIR` stages commands in `/usr/bin`, sourced modules/setup leaves in `/usr/lib/omarchy-mac/boot`, and the initramfs, in-place encryption and first-boot payload in `files/` at its installed paths (mkinitcpio drop-ins, initcpio hooks, units, presets, the ALPM hook and `/etc/default/update-m1n1`, which pins update-m1n1's device-tree order to the C locale). It performs no live setup. The recipe's `backup=` covers every `files/etc` path and `files/usr/lib/omarchy/initcpio`. `test/all` runs command fixtures and the payload's offline checks; `OMARCHY_DISPOSABLE_BOOT_TESTS=1` also builds real initramfs images and converts loop-device disks in privileged containers. Shared provisioning/reset integration remains covered by the runtime suite. +`install DESTDIR` stages commands in `/usr/bin`, sourced modules/setup leaves in `/usr/lib/omarchy-mac/boot`, the lifecycle dispatch entrypoints in `entrypoints/` in `/usr/lib/omarchy/mac-boot`, and the initramfs, in-place encryption and first-boot payload in `files/` at its installed paths (mkinitcpio drop-ins, initcpio hooks, units, presets, the ALPM hook and `/etc/default/update-m1n1`, which pins update-m1n1's device-tree order to the C locale). It performs no live setup. The recipe's `backup=` covers every `files/etc` path and `files/usr/lib/omarchy/initcpio`. `test/all` runs command fixtures and the payload's offline checks; `OMARCHY_DISPOSABLE_BOOT_TESTS=1` also builds real initramfs images and converts loop-device disks in privileged containers. Shared provisioning/reset integration remains covered by the runtime suite. 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. Owner provisioning reaches 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; factory reset still refuses to proceed when its module is unavailable. diff --git a/packages/omarchy-mac/boot/bin/omarchy-apple-silicon-boot-check b/packages/omarchy-mac/boot/bin/omarchy-apple-silicon-boot-check index 5ddb7cd56a6a..c4eed101f2b6 100755 --- a/packages/omarchy-mac/boot/bin/omarchy-apple-silicon-boot-check +++ b/packages/omarchy-mac/boot/bin/omarchy-apple-silicon-boot-check @@ -1,7 +1,7 @@ #!/bin/bash # omarchy:summary=Check that the boot files match the installed Apple Silicon kernel and m1n1 -# omarchy:args=[linux-aurora|linux-asahi] +# omarchy:args=[--boot-chain] [linux-aurora|linux-asahi] # omarchy:hidden=true # omarchy:requires-sudo=true @@ -9,6 +9,14 @@ # m1n1 image with the installed package files. Read the ESP through a private # read-only mount; never regenerate boot files or mutate a release channel. # An explicit pending-reboot override checks installed boot files only. +# +# --boot-chain checks only what the next boot reads, for omarchy update's +# update-verify: the kernel, initramfs, unlock settings, device trees, m1n1 +# stage 2, U-Boot and Limine. It holds only the kernel image, device trees and +# m1n1 against their package mtree, checks the kernel the boot menu starts +# first when both kernels are installed, and leaves out LUKS keyslots and +# provisioning leftovers and an m1n1 image its owner took over with +# M1N1_UPDATE_DISABLED. set -euo pipefail @@ -26,10 +34,15 @@ path() { case "${1:-}" in -h | --help) - echo "Usage: omarchy-apple-silicon-boot-check [linux-aurora|linux-asahi]" + echo "Usage: omarchy-apple-silicon-boot-check [--boot-chain] [linux-aurora|linux-asahi]" exit 0 ;; esac +boot_chain=0 +if [[ ${1:-} == "--boot-chain" ]]; then + boot_chain=1 + shift +fi (( $# <= 1 )) || fail "takes at most one kernel" workdir=$(mktemp -d) @@ -48,15 +61,40 @@ installed=$(pacman -Qq) || fail "cannot list the installed packages" is_installed() { grep -Fxq -- "$1" <<<"$installed" } +# The ESP Limine's tooling writes to: ESP_PATH, /boot/efi or on older +# installs /boot. +limine_esp_path() { + sudo sed -n -E 's/^[[:space:]]*ESP_PATH=("([^"]*)"|'\''([^'\'']*)'\''|([^[:space:]#"'\'']*)).*/\2\3\4/p' "$(path /etc/default/limine)" | tail -n 1 +} + +# The kernel the boot menu starts: the first kernel entry in Limine's menu, +# where the tool writes the Omarchy block first and Omarchy's default_entry +# points, else GRUB's first entry. A default_entry or GRUB_DEFAULT pointed +# elsewhere is not followed. +menu_kernel() { + if [[ -e $(path /var/lib/omarchy/limine.enabled) && -f $(path /etc/default/limine) ]]; then + sudo awk '{ sub(/^[[:space:]]+/, "") } /^\/\/linux-(aurora|asahi)$/ { print substr($0, 3); exit }' \ + "$(path "$(limine_esp_path)/limine.conf")" 2>/dev/null + else + sudo grep -Eo 'vmlinuz-linux-(aurora|asahi)' "$(path /boot/grub/grub.cfg)" 2>/dev/null | sed -n '1s/^vmlinuz-//p' + fi +} + kernel=${1:-} if [[ -z $kernel ]]; then kernels=() for candidate in linux-aurora linux-asahi; do ! is_installed "$candidate" || kernels+=("$candidate") done - (( ${#kernels[@]} == 1 )) || - fail "cannot tell which kernel boots: ${kernels[*]:-neither linux-aurora nor linux-asahi} installed" - kernel=${kernels[0]} + if (( boot_chain && ${#kernels[@]} == 2 )); then + kernel=$(menu_kernel || true) + [[ -n $kernel ]] || + fail "cannot tell which kernel boots: linux-aurora and linux-asahi are installed, and the boot menu starts neither" + else + (( ${#kernels[@]} == 1 )) || + fail "cannot tell which kernel boots: ${kernels[*]:-neither linux-aurora nor linux-asahi} installed" + kernel=${kernels[0]} + fi fi [[ -n ${bootloaders[$kernel]:-} ]] || fail "$kernel is not a kernel this check knows; it checks linux-aurora with m1n1-aurora and linux-asahi with m1n1" @@ -64,7 +102,9 @@ bootloader=${bootloaders[$kernel]} for package in "$kernel" "$bootloader"; do is_installed "$package" || fail "$kernel boots with $bootloader, but $package is not installed" done -for package in linux-aurora m1n1-aurora linux-asahi m1n1; do +rivals=(linux-aurora m1n1-aurora linux-asahi m1n1) +(( ! boot_chain )) || rivals=() +for package in "${rivals[@]}"; do [[ $package == "$kernel" || $package == "$bootloader" ]] || ! is_installed "$package" || fail "$kernel boots with $bootloader, but $package is installed too" done @@ -80,9 +120,17 @@ for package in "$kernel" "$bootloader"; do altered=$(grep -Ev ' altered files$' <<<"$mtree_output" | grep -Ev "^warning: database file for '[^']+' does not exist" | grep -Ev '^warning: [^:]+: /usr/lib/modules/[^/]+/modules\.[A-Za-z.]+ \(Modification time mismatch\)$' || true) + # --boot-chain holds only the files the boot files are built from against + # the mtree: the kernel image, its device trees and m1n1. Drift in any other + # file of the package is left out; everything else pacman reports counts. + if (( boot_chain )); then + altered=$(awk '!/^warning: [^:]+: \// || /^warning: [^:]+: \/usr\/lib\/(modules\/[^\/]+\/(vmlinuz|dtbs\/)|asahi-boot\/)/' <<<"$altered") + fi [[ -z $altered ]] || fail "installed $package files do not match the package mtree: $(head -n 1 <<<"$altered")" - # pacman exits 1 for the depmod lines alone; any other failure is one. + # pacman exits 1 for the depmod lines alone, and with --boot-chain for the + # file drift it leaves out; any other failure is one. (( mtree_status == 0 )) || grep -Fq '(Modification time mismatch)' <<<"$mtree_output" || + { (( boot_chain )) && grep -Eq '^warning: [^:]+: /' <<<"$mtree_output"; } || fail "pacman -Qkk $package failed" done @@ -199,7 +247,7 @@ if (( has_crypttab_root )); then # First-boot window: throwaway keyfile and rd.luks.key= are allowed until # owner provisioning finishes (v3 item 1e). After that both must be gone, # the throwaway keyslot retired, and encrypt.state phase=finished. - if [[ ! -f $(path /var/lib/omarchy/provisioning/luks-key) && ! -f $(path /var/lib/omarchy/mac-first-boot/pending) ]]; then + if (( ! boot_chain )) && [[ ! -f $(path /var/lib/omarchy/provisioning/luks-key) && ! -f $(path /var/lib/omarchy/mac-first-boot/pending) ]]; then (( limine_mac )) || ! sudo grep -q 'rd.luks.key=' "$grub_cfg" || fail "/boot/grub/grub.cfg still has rd.luks.key= after provisioning" [[ ! -e $(path /boot/omarchy/luks-key) ]] || @@ -245,9 +293,7 @@ fi # the LUKS mapping) the system needs, and the U-Boot slot must hold the # installed Limine. if (( limine_mac )); then - # The ESP Limine's tooling writes to: ESP_PATH, /boot/efi or on older - # installs /boot. - limine_esp=$(sudo sed -n -E 's/^[[:space:]]*ESP_PATH=("([^"]*)"|'\''([^'\'']*)'\''|([^[:space:]#"'\'']*)).*/\2\3\4/p' "$(path /etc/default/limine)" | tail -n 1) + limine_esp=$(limine_esp_path) [[ $limine_esp == /* ]] || fail "/etc/default/limine names no ESP_PATH" limine_cfg=$(path "$limine_esp/limine.conf") limine_uki=$(path "$limine_esp/EFI/Linux/omarchy_$kernel.efi") @@ -326,7 +372,7 @@ if (( limine_mac )); then mapper_uuid=$(sudo blkid -o value -s UUID /dev/mapper/root 2>/dev/null || true) [[ -z $mapper_uuid || ${limine_root#root=UUID=} == "$mapper_uuid" ]] || fail "the Limine $kernel entry root=UUID= does not name the filesystem on /dev/mapper/root" - if [[ ! -f $(path /var/lib/omarchy/provisioning/luks-key) && ! -f $(path /var/lib/omarchy/mac-first-boot/pending) ]]; then + if (( ! boot_chain )) && [[ ! -f $(path /var/lib/omarchy/provisioning/luks-key) && ! -f $(path /var/lib/omarchy/mac-first-boot/pending) ]]; then grep -q 'rd.luks.key=' <<<"$limine_cmdline" && fail "the Limine $kernel entry still has rd.luks.key= after provisioning" fi @@ -389,7 +435,7 @@ if [[ -e $config_file ]]; then esac done <"$workdir/config" fi -[[ -z $disabled ]] || +[[ -z $disabled ]] || (( boot_chain )) || fail "M1N1_UPDATE_DISABLED is set in /etc/default/update-m1n1, so m1n1 does not follow the kernel and its device trees cannot be vouched for; remove it, run sudo update-m1n1, then omarchy update" # ls -d prints what matches, and nothing at all when nothing does. @@ -570,6 +616,14 @@ else fi sudo test -f "$mountpoint/m1n1/boot.bin" || fail "the system ESP ($esp) has no m1n1/boot.bin" +# U-Boot starts the loader on the system ESP, so the Limine, menu and UKI +# checked above must be the ones there. +if (( limine_mac )); then + for file in EFI/BOOT/BOOTAA64.EFI limine.conf "EFI/Linux/omarchy_$kernel.efi"; do + sudo cmp -s "$(path "$limine_esp/$file")" "$mountpoint/$file" || + fail "$limine_esp/$file is not the one on the system ESP ($esp), which U-Boot boots; point ESP_PATH in /etc/default/limine at that ESP's mountpoint, then run sudo omarchy-mac-boot-update and omarchy update" + done +fi report_running_release() { if (( pending_reboot )); then echo "Apple Silicon boot check: installed $kernel $kver boot files match; running $running_kver, reboot pending" @@ -577,6 +631,11 @@ report_running_release() { echo "Apple Silicon boot check: running $kernel $kver; installed boot files match" fi } +if [[ -n $disabled ]]; then + echo "Apple Silicon boot check: M1N1_UPDATE_DISABLED is set in /etc/default/update-m1n1, so m1n1/boot.bin is its owner's and is not checked" + report_running_release + exit 0 +fi if sudo cmp -s "$workdir/boot.bin" "$mountpoint/m1n1/boot.bin"; then report_running_release exit 0 diff --git a/packages/omarchy-mac/boot/entrypoints/update-verify b/packages/omarchy-mac/boot/entrypoints/update-verify new file mode 100755 index 000000000000..2832e55e5daa --- /dev/null +++ b/packages/omarchy-mac/boot/entrypoints/update-verify @@ -0,0 +1,24 @@ +#!/bin/bash + +# omarchy-lifecycle-dispatch update-verify. omarchy update runs this after its +# package transaction, migrations and hooks, and neither finishes nor offers a +# reboot until it passes. The boot check, limited to the boot chain, proves the +# next boot reads what they installed: the kernel, initramfs and unlock +# settings, m1n1 stage 2 with that kernel's device trees and U-Boot on the +# system ESP, and on a Limine Mac the loader, menu and UKI on that same ESP. +# The installed kernel may be newer than the running one until that reboot. +# Nothing here rebuilds a boot file. + +set -uo pipefail + +echo -e "\e[32m\nVerify the Apple Silicon boot files\e[0m" +if ! OMARCHY_BOOT_CHECK_ALLOW_PENDING_REBOOT=1 omarchy-apple-silicon-boot-check --boot-chain; then + cat >&2 <<'MESSAGE' + +This Mac might not boot what the update installed, so do not reboot yet. +Fix what the boot check reported above. To rebuild the initramfs, m1n1 and the boot menu: + sudo mkinitcpio -P && sudo update-m1n1 && sudo omarchy-mac-boot-update +Then run omarchy update again: it checks the boot files before it offers the reboot. +MESSAGE + exit 1 +fi diff --git a/packages/omarchy-mac/boot/test/apple-silicon-boot-check-test.sh b/packages/omarchy-mac/boot/test/apple-silicon-boot-check-test.sh index f0061ff3ff9f..1c948053f114 100644 --- a/packages/omarchy-mac/boot/test/apple-silicon-boot-check-test.sh +++ b/packages/omarchy-mac/boot/test/apple-silicon-boot-check-test.sh @@ -626,6 +626,8 @@ limine_system() { local limine_esp=$1 fstab_row=$2 cmdline=$3 uki system linux-asahi mkdir -p "$root/var/lib/omarchy" "$root/etc" "$root/usr/share/limine" "$root$limine_esp/EFI/Linux" "$root$limine_esp/EFI/BOOT" + # m1n1 sits on the system ESP, which on these Macs is the one Limine uses. + [[ $limine_esp == /boot/efi ]] || mv "$esp/m1n1" "$root$limine_esp/m1n1" : >"$root/var/lib/omarchy/limine.enabled" printf 'ESP_PATH="%s"\nENABLE_UKI=yes\n' "$limine_esp" >"$root/etc/default/limine" [[ -z $fstab_row ]] || printf '%s\n' "$fstab_row" >"$root/etc/fstab" @@ -694,3 +696,37 @@ limine_system /boot/efi '' 'root=UUID=r rw quiet' run_check expect_fail "no fstab row (Omarchy's btrfs @) and no subvolume flag" "does not select rootflags=subvol=@" pass "the Limine entry's rootflags follow the root filesystem" + +# U-Boot boots the loader on the system ESP the device tree names, so the +# Limine files checked on ESP_PATH must be the ones there. +limine_on_system_esp() { + limine_system /boot/efi 'UUID=r / btrfs rw,subvol=/@ 0 0' 'root=UUID=r rw rootflags=subvol=@ quiet' + mkdir -p "$root/proc/device-tree/chosen" "$existing" + printf '%s\0' "$partuuid" >"$root/proc/device-tree/chosen/asahi,efi-system-partition" + cp -a "$esp/." "$existing/" +} +limine_on_system_esp +TEST_EXISTING_MOUNT="$existing" run_check +expect_pass "a Limine Mac whose system ESP holds the Limine files ESP_PATH names" +limine_on_system_esp +rm -rf "$existing/EFI" "$existing/limine.conf" +TEST_EXISTING_MOUNT="$existing" run_check +expect_fail "a Limine Mac whose ESP_PATH is another ESP than the system one" "/boot/efi/EFI/BOOT/BOOTAA64.EFI is not the one on the system ESP (PARTUUID=$partuuid), which U-Boot boots" +limine_on_system_esp +printf 'GRUB\n' >"$existing/EFI/BOOT/BOOTAA64.EFI" +TEST_EXISTING_MOUNT="$existing" run_check +expect_fail "a system ESP whose loader slot is not the checked Limine" "/boot/efi/EFI/BOOT/BOOTAA64.EFI is not the one on the system ESP" +limine_on_system_esp +printf 'older\n' >>"$existing/EFI/Linux/omarchy_linux-asahi.efi" +TEST_EXISTING_MOUNT="$existing" run_check +expect_fail "a system ESP with another UKI" "/boot/efi/EFI/Linux/omarchy_linux-asahi.efi is not the one on the system ESP" +limine_on_system_esp +sed -i 's/quiet$/quiet splash/' "$existing/limine.conf" +TEST_EXISTING_MOUNT="$existing" run_check +expect_fail "a system ESP with another menu" "/boot/efi/limine.conf is not the one on the system ESP" +limine_on_system_esp +printf 'M1N1_UPDATE_DISABLED=1\n' >"$root/etc/default/update-m1n1" +printf 'GRUB\n' >"$existing/EFI/BOOT/BOOTAA64.EFI" +TEST_EXISTING_MOUNT="$existing" run_check --boot-chain +expect_fail "an m1n1 left to its owner beside another loader on the system ESP" "/boot/efi/EFI/BOOT/BOOTAA64.EFI is not the one on the system ESP" +pass "a Limine Mac boots the Limine, menu and UKI on the system ESP" diff --git a/packages/omarchy-mac/boot/test/fixtures/limine-mac.sh b/packages/omarchy-mac/boot/test/fixtures/limine-mac.sh new file mode 100644 index 000000000000..469c7d84d972 --- /dev/null +++ b/packages/omarchy-mac/boot/test/fixtures/limine-mac.sh @@ -0,0 +1,225 @@ +# A Limine Mac for omarchy-apple-silicon-boot-check, as a fixture root plus the +# stubs and environment the check reads it through. Sourced by tests; +# limine_mac_init sets it up, limine_mac lays out a healthy Mac on +# linux-aurora and m1n1-aurora, and limine_mac_env prints the environment. + +limine_mac_init() { + mac_dir=$1 + mac_root=$mac_dir/root + mac_stubs=$mac_dir/stubs + mac_state=$mac_dir/state + mac_kver=6.17.0-aurora1-ARCH + mac_esp=$mac_root/boot/efi + mkdir -p "$mac_stubs" + + cat >"$mac_stubs/sudo" <<'SH' +#!/bin/bash +exec "$@" +SH + cat >"$mac_stubs/pacman" <<'SH' +#!/bin/bash +case "$*" in + -Qq) cat "$MAC_STATE/installed" ;; + "-Qlq "*) [[ -f $MAC_STATE/files-$2 ]] && cat "$MAC_STATE/files-$2" ;; + "-Qkk "*) + # A fresh image has no sync databases; pacman warns about each. + [[ ! -e $MAC_STATE/fresh-image ]] || printf "warning: database file for 'core' does not exist (use '-Sy' to download)\n" >&2 + # report- is a diagnostic that is not about one file. + if [[ -e $MAC_STATE/report-$2 ]]; then + cat "$MAC_STATE/report-$2" >&2 + exit 1 + fi + # drift- names the file that drifted. + if [[ -e $MAC_STATE/drift-$2 ]]; then + printf 'warning: %s: %s (Size mismatch)\n' "$2" "$(cat "$MAC_STATE/drift-$2")" >&2 + printf '%s: 2 total files, 1 altered files\n' "$2" + exit 1 + fi + printf '%s: 2 total files, 0 altered files\n' "$2" + ;; + *) exit 1 ;; +esac +SH + cat >"$mac_stubs/lsinitcpio" <<'SH' +#!/bin/bash +[[ -f ${@: -1} ]] || exit 1 +case $1 in + -l) cat "$MAC_STATE/initramfs" ;; + -a) printf '==> Image: initramfs\n' ;; + *) exit 1 ;; +esac +SH + # Only read-only binds, of a directory standing in for the mounted ESP. + cat >"$mac_stubs/mount" <<'SH' +#!/bin/bash +[[ $1 == "--bind" && $2 == "-o" && $3 == "ro" && -d $4 ]] || exit 32 +cp -a "$4/." "$5/" +echo "$5" >>"$MAC_STATE/mounts" +SH + cat >"$mac_stubs/umount" <<'SH' +#!/bin/bash +find "$1" -mindepth 1 -delete +sed -i "\|^$1\$|d" "$MAC_STATE/mounts" +SH + cat >"$mac_stubs/findmnt" <<'SH' +#!/bin/bash +[[ $* == "-n -o VFS-OPTIONS --mountpoint "* ]] && grep -Fxq -- "${@: -1}" "$MAC_STATE/mounts" || exit 1 +echo ro,relatime +SH + cat >"$mac_stubs/lsblk" <<'SH' +#!/bin/bash +exit 0 +SH + cat >"$mac_stubs/blkid" <<'SH' +#!/bin/bash +exit 2 +SH + cat >"$mac_stubs/cryptsetup" <<'SH' +#!/bin/bash +[[ $1 == luksDump && -f $MAC_STATE/luks-dump ]] || exit 1 +cat "$MAC_STATE/luks-dump" +SH + # A fixture UKI is the kernel followed by a marker: .linux is the whole file. + cat >"$mac_stubs/objcopy" <<'SH' +#!/bin/bash +[[ $* == "-O binary --only-section=.linux "* ]] || exit 1 +cp "$4" "$5" +SH + chmod +x "$mac_stubs"/* +} + +# A device tree as update-m1n1 and the boot check see one: the flattened device +# tree magic and big-endian total size, then a body naming it. +limine_mac_dtb() { + local path=$1 body size + body="device tree ${path##*/} ${2:-}"$'\n' + size=$(( 8 + ${#body} )) + mkdir -p "$(dirname "$path")" + { + printf '\xd0\x0d\xfe\xed' + printf "$(printf '\\x%02x' $(( size >> 24 & 255 )) $(( size >> 16 & 255 )) $(( size >> 8 & 255 )) $(( size & 255 )))" + printf '%s' "$body" + } >"$path" +} + +# m1n1/boot.bin on the ESP as update-m1n1 writes it: m1n1, the given device +# trees (root-relative), gzipped U-Boot and the m1n1.conf options. +limine_mac_boot_bin() { + local m1n1=$1 dtb paths=() + shift + for dtb; do + paths+=("$mac_root$dtb") + done + { + cat "$m1n1" "${paths[@]}" + gzip -c "$mac_root/usr/lib/asahi-boot/u-boot-nodtb.bin" + printf 'display=2560x1600\n' + } >"$mac_esp/m1n1/boot.bin" +} + +# The Limine menu entry for the UKI, with the hash Limine verifies. +limine_mac_menu() { + local uki=$mac_esp/EFI/Linux/omarchy_linux-aurora.efi + printf '/+Omarchy\n //linux-aurora\n protocol: efi\n path: boot():/EFI/Linux/omarchy_linux-aurora.efi#%s\n cmdline: %s\n' \ + "$(b2sum "$uki" | cut -d' ' -f1)" "$mac_cmdline" >"$mac_esp/limine.conf" +} + +limine_mac() { + local modules=$mac_root/usr/lib/modules/$mac_kver dtb + mac_dtbs=(/usr/lib/modules/$mac_kver/dtbs/t6000-j314s.dtb /usr/lib/modules/$mac_kver/dtbs/t6020-j414s.dtb /usr/lib/modules/$mac_kver/dtbs/t8103-j274.dtb) + mac_cmdline="root=UUID=r rw rootflags=subvol=@ quiet" + rm -rf "$mac_root" "$mac_state" + mkdir -p "$modules/dtbs" "$mac_root/usr/lib/asahi-boot" "$mac_root/usr/bin" "$mac_root/usr/share/limine" \ + "$mac_root/etc/default" "$mac_root/var/lib/omarchy" "$mac_root/run" \ + "$mac_esp/m1n1" "$mac_esp/EFI/BOOT" "$mac_esp/EFI/Linux" "$mac_state" + : >"$mac_state/mounts" + ln -s usr/lib "$mac_root/lib" + + printf 'linux-aurora kernel %s\n' "$mac_kver" >"$modules/vmlinuz" + cp "$modules/vmlinuz" "$mac_root/boot/vmlinuz-linux-aurora" + printf 'initramfs\n' >"$mac_root/boot/initramfs-linux-aurora.img" + printf 'usr/lib/modules/%s/kernel/drivers/gpu/drm/apple/appledrm.ko.zst\nusr/bin/init\n' "$mac_kver" >"$mac_state/initramfs" + for dtb in "${mac_dtbs[@]}"; do + limine_mac_dtb "$mac_root$dtb" + done + printf 'm1n1 stage 2 from m1n1-aurora\n' >"$mac_root/usr/lib/asahi-boot/m1n1.bin" + printf 'u-boot\n' >"$mac_root/usr/lib/asahi-boot/u-boot-nodtb.bin" + printf 'display=2560x1600\n' >"$mac_root/etc/m1n1.conf" + printf 'export LC_ALL=C\n' >"$mac_root/etc/default/update-m1n1" + # update-m1n1 as asahi-scripts ships it, with the DTBS default ALARM adds. + cat >"$mac_root/usr/bin/update-m1n1" <<'SH' +#!/bin/sh +set -e +[ -e /etc/default/update-m1n1 ] && . /etc/default/update-m1n1 +[ -n "$M1N1_UPDATE_DISABLED" ] && exit 0 +: ${SOURCE:="/usr/lib/asahi-boot/"} +: ${M1N1:="$SOURCE/m1n1.bin"} +: ${U_BOOT:="$SOURCE/u-boot-nodtb.bin"} +: ${TARGET:="$1"} +: ${DTBS:=$(/bin/ls -d /lib/modules/*-ARCH | sort -rV | head -1)/dtbs/*.dtb} +: ${CONFIG:=/etc/m1n1.conf} +m1n1config=/run/m1n1.conf +if [ -e "$CONFIG" ]; then + while read line; do + case "$line" in + "") ;; + \#*) ;; + chosen.*=*|display=*|mitigations=*) + echo "$line" >> "$m1n1config" + ;; + esac + done <$CONFIG +fi +cat "$M1N1" $DTBS >"${TARGET}.new" +gzip -c "$U_BOOT" >>"${TARGET}.new" +cat "$m1n1config" >>"${TARGET}.new" +SH + limine_mac_boot_bin "$mac_root/usr/lib/asahi-boot/m1n1.bin" "${mac_dtbs[@]}" + + : >"$mac_root/var/lib/omarchy/limine.enabled" + printf 'ESP_PATH="/boot/efi"\nENABLE_UKI=yes\n' >"$mac_root/etc/default/limine" + printf 'UUID=r / btrfs rw,subvol=/@ 0 0\n' >"$mac_root/etc/fstab" + printf 'LIMINE\n' >"$mac_root/usr/share/limine/BOOTAA64.EFI" + cp "$mac_root/usr/share/limine/BOOTAA64.EFI" "$mac_esp/EFI/BOOT/BOOTAA64.EFI" + { cat "$modules/vmlinuz"; printf 'initrd\n'; } >"$mac_esp/EFI/Linux/omarchy_linux-aurora.efi" + limine_mac_menu + + printf '%s\n' linux-aurora m1n1-aurora uboot-asahi limine >"$mac_state/installed" + { + printf '/usr/\n/usr/lib/\n/usr/lib/modules/\n/usr/lib/modules/%s/\n/usr/lib/modules/%s/vmlinuz\n/usr/lib/modules/%s/dtbs/\n' "$mac_kver" "$mac_kver" "$mac_kver" + printf '%s\n' "${mac_dtbs[@]}" + } >"$mac_state/files-linux-aurora" + printf '/usr/lib/asahi-boot/\n/usr/lib/asahi-boot/m1n1.bin\n' >"$mac_state/files-m1n1-aurora" +} + +# Makes the fixture an encrypted Mac whose owner setup finished: crypttab, the +# Limine entry's rd.luks.name=, a systemd initramfs with the cryptsetup +# generator, and the owner and recovery keyslots. $1 adds keyslots beyond those. +limine_mac_luks() { + local uuid=0422663f-9969-4953-900f-b342703b7e84 slot + printf '/dev/mapper/root / btrfs rw,subvol=/@ 0 0\n' >"$mac_root/etc/fstab" + printf 'root UUID=%s none luks\n' "$uuid" >"$mac_root/etc/crypttab" + printf 'usr/lib/modules/%s/kernel/drivers/gpu/drm/apple/appledrm.ko.zst\nusr/bin/init\nusr/bin/systemd-cryptsetup\nusr/lib/systemd/system-generators/systemd-cryptsetup-generator\n' \ + "$mac_kver" >"$mac_state/initramfs" + mkdir -p "$mac_root/boot/omarchy" + printf 'format=1\nphase=finished\npartition=p\nluks_uuid=%s\nowner_slot=0\nrecovery_slot=1\n' "$uuid" >"$mac_root/boot/omarchy/encrypt.state" + { + printf 'LUKS header information\nKeyslots:\n' + for (( slot = 0; slot < 2 + ${1:-0}; slot++ )); do + printf ' %s: luks2\n' "$slot" + done + } >"$mac_state/luks-dump" + mac_cmdline="root=UUID=r rw rootflags=subvol=@ rd.luks.name=$uuid=root quiet" + limine_mac_menu +} + +# The environment the check reads the fixture through, one export per line: +# $1 is where the boot check is, $2 the running kernel release (by default the +# installed one). +limine_mac_env() { + printf 'export %s\n' \ + "$(printf 'MAC_STATE=%q' "$mac_state")" \ + "$(printf 'OMARCHY_BOOT_CHECK_ROOT=%q' "$mac_root")" \ + "$(printf 'OMARCHY_BOOT_CHECK_UNAME=%q' "${2:-$mac_kver}")" \ + "$(printf 'PATH=%q' "$mac_stubs:$1:$PATH")" +} diff --git a/packages/omarchy-mac/boot/test/update-verify-test.sh b/packages/omarchy-mac/boot/test/update-verify-test.sh new file mode 100644 index 000000000000..7fcc68d3162b --- /dev/null +++ b/packages/omarchy-mac/boot/test/update-verify-test.sh @@ -0,0 +1,201 @@ +#!/bin/bash + +set -euo pipefail +source "$(dirname "$0")/base-test.sh" +source "$ROOT/test/fixtures/limine-mac.sh" + +require_command gzip +require_command b2sum + +# omarchy update runs update-verify through omarchy-lifecycle-dispatch once its +# packages, migrations and hooks are done. It is the boot check on the whole +# boot chain, read-only, with the reboot the update offers next still to come. +entrypoint=$ROOT/entrypoints/update-verify +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT + +bash "$ROOT/install" "$tmp/stage" +staged=$tmp/stage/usr/lib/omarchy/mac-boot/update-verify +cmp -s "$entrypoint" "$staged" && [[ $(stat -c %a "$staged") == 755 ]] || + fail "update-verify is staged as the lifecycle dispatch entrypoint /usr/lib/omarchy/mac-boot/update-verify" +pass "the package ships update-verify where omarchy-lifecycle-dispatch runs it" + +limine_mac_init "$tmp/mac" + +tree_state() { + find "$mac_root" -path "$mac_root/run" -prune -o -print0 | sort -z | xargs -0 stat -c '%n %s %Y %a' 2>/dev/null + find "$mac_root" -path "$mac_root/run" -prune -o -type f -print0 | sort -z | xargs -0 sha256sum +} + +# Runs update-verify on the fixture Mac; $1 is the running kernel release. +verify() { + tree_state >"$tmp/before" + set +e + ( + eval "$(limine_mac_env "$ROOT/bin" "${1:-}")" + bash "$entrypoint" + ) >"$tmp/out" 2>"$tmp/err" + status=$? + set -e + tree_state >"$tmp/after" + diff -q "$tmp/before" "$tmp/after" >/dev/null || fail "update-verify changes no boot file" "$(diff "$tmp/before" "$tmp/after")" + [[ ! -s $mac_state/mounts && -z $(ls -A "$mac_root/run") ]] || fail "update-verify leaves nothing mounted" +} + +expect_verified() { + (( status == 0 )) || fail "$1 passes update-verify" "status $status: $(cat "$tmp/err")" +} + +expect_refused() { + local description=$1 reason=$2 + (( status == 1 )) || fail "$description fails update-verify" "status $status: $(cat "$tmp/out" "$tmp/err")" + grep -Fq "$reason" "$tmp/err" || fail "$description is named" "$(cat "$tmp/err")" + grep -Fq "do not reboot yet" "$tmp/err" && grep -Fq "sudo mkinitcpio -P && sudo update-m1n1 && sudo omarchy-mac-boot-update" "$tmp/err" || + fail "$description says not to reboot and how to rebuild the boot files" "$(cat "$tmp/err")" +} + +limine_mac +verify +expect_verified "a Limine Mac running the installed kernel" +grep -Fq "running linux-aurora $mac_kver; installed boot files match" "$tmp/out" || fail "update-verify reports what it verified" "$(cat "$tmp/out")" +verify 6.16.0-aurora9-ARCH +expect_verified "a Limine Mac whose update installed a new kernel" +grep -Fq "running 6.16.0-aurora9-ARCH, reboot pending" "$tmp/out" || fail "update-verify says the reboot is still to come" "$(cat "$tmp/out")" +limine_mac_boot_bin "$mac_root/usr/lib/asahi-boot/m1n1.bin" "${mac_dtbs[2]}" "${mac_dtbs[0]}" "${mac_dtbs[1]}" +verify +expect_verified "an m1n1 image holding the kernel's device trees in another order" +pass "update-verify passes a coherent boot chain, before and after the reboot, whatever order the device trees are in" + +boot_bin_reason="m1n1/boot.bin on the system ESP (/boot/efi) is not m1n1, linux-aurora $mac_kver's device trees, U-Boot and /etc/m1n1.conf as installed" + +limine_mac +limine_mac_dtb "$mac_root/opt/t8103-j274.dtb" "from another kernel" +limine_mac_boot_bin "$mac_root/usr/lib/asahi-boot/m1n1.bin" "${mac_dtbs[@]:0:2}" /opt/t8103-j274.dtb +verify +expect_refused "an m1n1 image with a device tree the installed kernel does not ship" "$boot_bin_reason" + +limine_mac +printf 'm1n1 stage 2 from the previous m1n1-aurora\n' >"$tmp/m1n1.bin" +limine_mac_boot_bin "$tmp/m1n1.bin" "${mac_dtbs[@]}" +verify +expect_refused "an m1n1 image with a stale m1n1" "$boot_bin_reason" + +limine_mac +rm "$mac_esp/EFI/Linux/omarchy_linux-aurora.efi" +verify +expect_refused "a Limine Mac without its UKI" "/boot/efi/EFI/Linux/omarchy_linux-aurora.efi (the Limine UKI) is missing" + +limine_mac +printf 'the previous kernel\n' >"$mac_esp/EFI/Linux/omarchy_linux-aurora.efi" +limine_mac_menu +verify +expect_refused "a UKI carrying another kernel" "does not carry the installed $mac_kver kernel" + +limine_mac +printf 'LIMINE, previous release\n' >"$mac_esp/EFI/BOOT/BOOTAA64.EFI" +verify +expect_refused "a loader slot with another Limine" "/boot/efi/EFI/BOOT/BOOTAA64.EFI is not the installed Limine" + +limine_mac +printf 'usr/lib/modules/6.16.0-aurora9-ARCH/kernel/x.ko\n' >"$mac_state/initramfs" +verify 6.16.0-aurora9-ARCH +expect_refused "an initramfs built for the previous kernel" "does not hold the $mac_kver modules" +pass "update-verify refuses a wrong device tree, a stale m1n1, a missing or stale UKI, another Limine or a stale initramfs, and says not to reboot" + +# update-verify checks only what the next boot reads. What the full boot check +# also holds against a Mac, the next boot does not read, so it never fails an +# update: the full check still refuses it. +full_check() { + set +e + ( + eval "$(limine_mac_env "$ROOT/bin")" + bash "$ROOT/bin/omarchy-apple-silicon-boot-check" + ) >"$tmp/full-out" 2>"$tmp/full-err" + full_status=$? + set -e +} + +beyond_boot_chain() { + local description=$1 reason=$2 + full_check + (( full_status == 1 )) && grep -Fq "$reason" "$tmp/full-err" || + fail "the full boot check refuses $description" "status $full_status: $(cat "$tmp/full-err")" + verify + expect_verified "$description" +} + +limine_mac +limine_mac_luks +full_check +(( full_status == 0 )) || fail "the full boot check passes an encrypted Limine Mac" "$(cat "$tmp/full-err")" +verify +expect_verified "an encrypted Limine Mac" +limine_mac_luks 1 +beyond_boot_chain "an encrypted Mac with a third LUKS keyslot" "throwaway LUKS keyslot still present" +limine_mac +printf 'M1N1_UPDATE_DISABLED=1\n' >>"$mac_root/etc/default/update-m1n1" +printf 'built by its owner\n' >>"$mac_esp/m1n1/boot.bin" +beyond_boot_chain "an m1n1 image its owner took over" "M1N1_UPDATE_DISABLED is set" +grep -Fq "m1n1/boot.bin is its owner's and is not checked" "$tmp/out" || fail "update-verify says it left m1n1 to its owner" "$(cat "$tmp/out")" +# A second kernel, older, with its own entry after the one the menu starts. +second_kernel() { + local asahi=6.14.8-asahi1-1-ARCH + mkdir -p "$mac_root/usr/lib/modules/$asahi/dtbs" + printf 'linux-asahi kernel\n' >"$mac_root/usr/lib/modules/$asahi/vmlinuz" + printf 'linux-asahi\n' >>"$mac_state/installed" + printf '/usr/lib/modules/%s/vmlinuz\n' "$asahi" >"$mac_state/files-linux-asahi" +} +limine_mac +second_kernel +printf ' //linux-asahi\n protocol: efi\n path: boot():/EFI/Linux/omarchy_linux-asahi.efi#0\n cmdline: quiet\n' >>"$mac_esp/limine.conf" +beyond_boot_chain "a Mac with a second kernel installed" "cannot tell which kernel boots" +grep -Fq "running linux-aurora $mac_kver" "$tmp/out" || fail "update-verify checks the kernel the menu starts" "$(cat "$tmp/out")" +limine_mac +printf '/usr/lib/modules/%s/kernel/drivers/gpu/drm/apple/appledrm.ko.zst\n' "$mac_kver" >"$mac_state/drift-linux-aurora" +beyond_boot_chain "a kernel module that drifted from its mtree" "linux-aurora files do not match the package mtree" +pass "update-verify passes a healthy Mac with an extra keyslot, an owner-built m1n1, a second kernel or a drifted module" + +# What the boot files are built from still has to match its package. +for drifted in "/usr/lib/modules/$mac_kver/vmlinuz" "${mac_dtbs[0]}"; do + limine_mac + printf '%s\n' "$drifted" >"$mac_state/drift-linux-aurora" + verify + expect_refused "a drifted ${drifted##*/}" "installed linux-aurora files do not match the package mtree: warning: linux-aurora: $drifted" +done +limine_mac +printf '/usr/lib/asahi-boot/m1n1.bin\n' >"$mac_state/drift-m1n1-aurora" +verify +expect_refused "a drifted m1n1" "installed m1n1-aurora files do not match the package mtree" +# With two kernels, the one the menu starts is checked, and it must boot. +limine_mac +second_kernel +{ + printf '/+Omarchy\n //linux-asahi\n protocol: efi\n path: boot():/EFI/Linux/omarchy_linux-asahi.efi#0\n cmdline: quiet\n' + sed 1d "$mac_esp/limine.conf" +} >"$tmp/limine.conf" +cp "$tmp/limine.conf" "$mac_esp/limine.conf" +verify +expect_refused "a Mac whose menu starts the second kernel first" "linux-asahi boots with m1n1, but m1n1 is not installed" +# A fresh image's database warnings explain nothing else pacman reports. +limine_mac +: >"$mac_state/fresh-image" +printf '/usr/lib/modules/%s/kernel/drivers/gpu/drm/apple/appledrm.ko.zst\n' "$mac_kver" >"$mac_state/drift-linux-aurora" +verify +expect_verified "a fresh image with a drifted module" +printf 'error: linux-aurora: could not read the mtree\n' >"$mac_state/report-linux-aurora" +verify +expect_refused "a package pacman cannot check, on a fresh image" "installed linux-aurora files do not match the package mtree: error: linux-aurora: could not read the mtree" +pass "update-verify still refuses a drifted kernel image, device tree or m1n1, or a package pacman cannot check, and checks the kernel the menu starts" + +limine_mac +limine_mac_luks +printf 'usr/lib/modules/%s/kernel/x.ko\nusr/bin/init\n' "$mac_kver" >"$mac_state/initramfs" +verify +expect_refused "an encrypted Mac whose initramfs cannot unlock the root" "does not contain sd-encrypt" +limine_mac +limine_mac_luks +mac_cmdline="root=UUID=r rw rootflags=subvol=@ quiet" +limine_mac_menu +verify +expect_refused "an encrypted Mac whose Limine entry does not unlock the root" "does not set rd.luks.name= for the encrypted root" +pass "update-verify still refuses an encrypted Mac whose next boot cannot unlock its root" diff --git a/test/shell.d/lifecycle-dispatch-test.sh b/test/shell.d/lifecycle-dispatch-test.sh index e1a9ac0296a5..b08691b503f2 100755 --- a/test/shell.d/lifecycle-dispatch-test.sh +++ b/test/shell.d/lifecycle-dispatch-test.sh @@ -97,16 +97,29 @@ for operation in "${operations[@]}"; do output=$(on apple-silicon "$empty" --resolve "$operation" 2>&1) && [[ -z $output ]] || fail "apple: optional $operation resolves to nothing without the boot package" "$output" else - (( status == 1 )) || fail "apple: required $operation fails without the boot package" "status: $status" + (( status == 3 )) || fail "apple: required $operation fails with status 3 without the boot package" "status: $status" [[ $output == "Error: $operation on apple-silicon needs omarchy-mac-boot, which provides /usr/lib/omarchy/mac-boot/$operation; it is not installed" ]] || fail "apple: required $operation names the missing package and entrypoint" "$output" - if on apple-silicon "$empty" --resolve "$operation" >/dev/null 2>&1; then - fail "apple: required $operation does not resolve without the boot package" - fi + status=0 + on apple-silicon "$empty" --resolve "$operation" >/dev/null 2>&1 || status=$? + (( status == 3 )) || fail "apple: required $operation does not resolve without the boot package" "status: $status" fi done pass "apple: without omarchy-mac-boot required operations fail with a clear message and optional ones are no-ops" +# An installed omarchy-mac-boot that predates an operation is named with its +# version, as an update away rather than missing. +older=$tmp/older +mkdir -p "$older/usr/lib/omarchy/mac-boot" "$older/var/lib/pacman/local/omarchy-mac-boot-20260921-10" +for operation in "${operations[@]}"; do + [[ " ${apple_optional[*]} " == *" $operation "* ]] && continue + status=0 + output=$(on apple-silicon "$older" "$operation" 2>&1) || status=$? + (( status == 1 )) && [[ $output == "Error: $operation on apple-silicon needs /usr/lib/omarchy/mac-boot/$operation, which omarchy-mac-boot 20260921-10 does not provide; update omarchy-mac-boot" ]] || + fail "apple: an omarchy-mac-boot without $operation is named with its version" "status $status: $output" +done +pass "apple: an installed omarchy-mac-boot that lacks a required operation fails asking for its update" + # An entrypoint anyone but root could have changed never runs, optional or not. untrusted() { local description=$1 operation=$2 diff --git a/test/shell.d/mac-boot-update-verify-test.sh b/test/shell.d/mac-boot-update-verify-test.sh new file mode 100755 index 000000000000..85b8da626a35 --- /dev/null +++ b/test/shell.d/mac-boot-update-verify-test.sh @@ -0,0 +1,4 @@ +#!/bin/bash +set -euo pipefail +source "$(dirname -- "${BASH_SOURCE[0]}")/base-test.sh" +exec bash "$ROOT/packages/omarchy-mac/boot/test/update-verify-test.sh" diff --git a/test/shell.d/update-boot-verify-test.sh b/test/shell.d/update-boot-verify-test.sh new file mode 100755 index 000000000000..6ece8ed9edca --- /dev/null +++ b/test/shell.d/update-boot-verify-test.sh @@ -0,0 +1,213 @@ +#!/bin/bash + +set -euo pipefail + +source "$(dirname "$0")/base-test.sh" +source "$ROOT/packages/omarchy-mac/boot/test/fixtures/limine-mac.sh" + +require_platform_fixtures "omarchy update's boot checks on platform fixtures" +require_command gzip +require_command b2sum + +tmp=$(mktemp -d) +trap 'rm -rf "$tmp"' EXIT + +# Every step of omarchy update but its boot checks is a stub that records +# itself. The boot checks run the real omarchy-update-boot, dispatcher and +# platform detector; sudo passes the fixtures through. +steps=( + omarchy-update-lock + omarchy-update-requires-free-space + omarchy-update-confirm + omarchy-update-pkg-prune + omarchy-snapshot + omarchy-update-stay-awake + omarchy-update-dev + omarchy-update-keyring + omarchy-update-system-pkgs + omarchy-migrate + omarchy-hook + omarchy-update-aur-pkgs + omarchy-update-mise + omarchy-update-orphan-pkgs + omarchy-update-analyze-logs + omarchy-update-status + omarchy-update-restart +) +stub_bin=$tmp/bin +mkdir -p "$stub_bin" +for step in "${steps[@]}"; do + cat >"$stub_bin/$step" <<'SH' +#!/bin/bash +echo "${0##*/}" >>"$STEP_LOG" +SH +done +cat >"$stub_bin/sudo" <<'SH' +#!/bin/bash +echo "$*" >>"$SUDO_LOG" +exec "$@" +SH +chmod +x "$stub_bin"/* + +for platform in apple-silicon qualcomm generic-aarch64 generic; do + fake_platform "$tmp/$platform" "$platform" +done + +# The whole update, as the stubs record it, before this change and with it on +# a platform whose boot checks are no-ops. +all_steps() { + printf '%s\n' omarchy-update-lock omarchy-update-requires-free-space omarchy-update-pkg-prune omarchy-snapshot \ + omarchy-update-stay-awake omarchy-update-dev omarchy-update-keyring omarchy-update-system-pkgs omarchy-migrate \ + omarchy-hook omarchy-update-aur-pkgs omarchy-update-mise omarchy-update-orphan-pkgs omarchy-update-analyze-logs \ + omarchy-update-status omarchy-update-stay-awake omarchy-update-restart +} + +# omarchy update -y on platform $1, with the boot package's entrypoints in the +# lifecycle root $2. +run_update() { + local platform=$1 lifecycle=$2 + : >"$tmp/steps" + : >"$tmp/sudo" + set +e + STEP_LOG="$tmp/steps" \ + SUDO_LOG="$tmp/sudo" \ + OMARCHY_UPDATE_LOGGED=1 \ + OMARCHY_PROC_ROOT="$tmp/$platform/proc" \ + OMARCHY_LIFECYCLE_ROOT="$lifecycle" \ + PATH="$tmp/$platform/bin:$stub_bin:$ROOT/bin:$PATH" \ + bash "$ROOT/bin/omarchy-update" -y >"$tmp/out" 2>"$tmp/err" + status=$? + set -e +} + +ran() { + grep -Fxq "$1" "$tmp/steps" +} + +# A lifecycle root holding entrypoints that record themselves and exit with $2. +recording_package() { + local lifecycle=$1 code=$2 operation + rm -rf "$lifecycle" + mkdir -p "$lifecycle/usr/lib/omarchy/mac-boot" + for operation in update-preflight update-verify; do + printf '#!/bin/bash\necho %s >>%q\nexit %s\n' "$operation" "$tmp/boot-ran" "$code" >"$lifecycle/usr/lib/omarchy/mac-boot/$operation" + done + chmod -R go-w "$lifecycle" + chmod 755 "$lifecycle"/usr/lib/omarchy/mac-boot/* +} + +# omarchy-mac-boot's own update-verify, on the fixture Mac. The dispatcher runs +# entrypoints with an empty environment, so this one puts the fixture's back +# before it runs the real entrypoint and boot check. $1 is the running kernel. +mac_boot_package() { + local lifecycle=$tmp/mac-boot entrypoint=$tmp/mac-boot/usr/lib/omarchy/mac-boot/update-verify + rm -rf "$lifecycle" + mkdir -p "${entrypoint%/*}" + { + printf '#!/bin/bash\n' + limine_mac_env "$ROOT/packages/omarchy-mac/boot/bin" "${1:-}" + printf 'exec bash %q\n' "$ROOT/packages/omarchy-mac/boot/entrypoints/update-verify" + } >"$entrypoint" + chmod -R go-w "$lifecycle" + chmod 755 "$entrypoint" +} + +# x86, generic aarch64 and Qualcomm: both boot checks are no-ops, even with +# failing Mac entrypoints on disk, and the update runs and says exactly what +# it did before. +recording_package "$tmp/failing" 9 +for platform in generic generic-aarch64 qualcomm; do + rm -f "$tmp/boot-ran" + run_update "$platform" "$tmp/failing" + (( status == 0 )) || fail "$platform: an update reports success" "status $status: $(cat "$tmp/err")" + diff <(all_steps) "$tmp/steps" >"$tmp/order" || fail "$platform: the update runs the same steps as before" "$(cat "$tmp/order")" + [[ ! -s $tmp/out && ! -s $tmp/err ]] || fail "$platform: the boot checks print nothing" "$(cat "$tmp/out" "$tmp/err")" + [[ ! -e $tmp/boot-ran ]] || fail "$platform: no Mac entrypoint runs" "$(cat "$tmp/boot-ran")" + [[ ! -s $tmp/sudo ]] || fail "$platform: the boot checks ask for no root" "$(cat "$tmp/sudo")" +done +# Warnings on stderr, such as bash's for a locale it cannot load, are not an +# entrypoint to run as root. +LC_ALL=xx_XX.UTF-8 run_update generic "$tmp/failing" +(( status == 0 )) && [[ ! -s $tmp/sudo ]] || fail "generic: stderr noise asks for no root" "status $status: $(cat "$tmp/sudo" "$tmp/err")" +pass "x86, generic aarch64 and Qualcomm updates are unchanged: no boot check runs, nothing asks for root and the reboot is offered" + +# Apple: preflight runs before the keyring and packages change, and verify +# after the last package step, before the reboot is offered. +recording_package "$tmp/passing" 0 +rm -f "$tmp/boot-ran" +run_update apple-silicon "$tmp/passing" +(( status == 0 )) || fail "apple: an update whose boot checks pass reports success" "status $status: $(cat "$tmp/err")" +diff <(all_steps) "$tmp/steps" >"$tmp/order" || fail "apple: a verified update runs every step" "$(cat "$tmp/order")" +[[ $(cat "$tmp/boot-ran") == $'update-preflight\nupdate-verify' ]] || fail "apple: preflight and verify each run once" "$(cat "$tmp/boot-ran")" +[[ $(cat "$tmp/sudo") == $'omarchy-lifecycle-dispatch update-preflight\nomarchy-lifecycle-dispatch update-verify' ]] || + fail "apple: preflight and verify run as root" "$(cat "$tmp/sudo")" +pass "apple: preflight and verify run through the boot package and a verified update offers the reboot" + +recording_package "$tmp/refusing" 1 +rm "$tmp/refusing/usr/lib/omarchy/mac-boot/update-verify" +run_update apple-silicon "$tmp/refusing" +(( status != 0 )) || fail "apple: a refused preflight fails the update" +for step in omarchy-update-keyring omarchy-update-system-pkgs omarchy-migrate omarchy-update-restart; do + ! ran "$step" || fail "apple: a refused preflight stops the update before $step" +done +pass "apple: a refused preflight stops the update before any package changes" + +# omarchy-mac-boot's update-verify on a Limine Mac, end to end. +limine_mac_init "$tmp/mac" +limine_mac +mac_boot_package +run_update apple-silicon "$tmp/mac-boot" +(( status == 0 )) || fail "apple: an update that leaves a coherent boot chain succeeds" "status $status: $(cat "$tmp/out" "$tmp/err")" +ran omarchy-update-restart || fail "apple: a verified update offers the reboot" +grep -Fq "running linux-aurora $mac_kver; installed boot files match" "$tmp/out" || fail "apple: the update shows what it verified" "$(cat "$tmp/out")" +mac_boot_package 6.16.0-aurora9-ARCH +run_update apple-silicon "$tmp/mac-boot" +(( status == 0 )) && ran omarchy-update-restart || + fail "apple: an update that installed a new kernel is verified before its reboot" "status $status: $(cat "$tmp/out" "$tmp/err")" +pass "apple: an update that leaves a coherent boot chain passes verification and offers the reboot" + +# Injected incoherence: the update fails, says why and what to do, and does not +# offer the reboot. Everything else still runs. +blocked() { + local description=$1 reason=$2 + run_update apple-silicon "$tmp/mac-boot" + (( status == 1 )) || fail "apple: $description fails the update" "status $status: $(cat "$tmp/err")" + ! ran omarchy-update-restart || fail "apple: $description offers no reboot" + ran omarchy-update-analyze-logs && ran omarchy-update-status && (( $(grep -c '^omarchy-update-stay-awake$' "$tmp/steps") == 2 )) || + fail "apple: $description still checks the logs, refreshes the status and releases Stay Awake" "$(cat "$tmp/steps")" + grep -Fq "$reason" "$tmp/err" || fail "apple: $description is explained" "$(cat "$tmp/err")" + grep -Fq "do not reboot yet" "$tmp/err" && grep -Fq "The update is not finished" "$tmp/err" || + fail "apple: $description says the update is not finished and not to reboot" "$(cat "$tmp/err")" +} +mac_boot_package +limine_mac +limine_mac_dtb "$mac_root/opt/t8103-j274.dtb" "from another kernel" +limine_mac_boot_bin "$mac_root/usr/lib/asahi-boot/m1n1.bin" "${mac_dtbs[@]:0:2}" /opt/t8103-j274.dtb +blocked "a wrong device tree in m1n1/boot.bin" "m1n1/boot.bin on the system ESP (/boot/efi) is not m1n1, linux-aurora $mac_kver's device trees" +limine_mac +printf 'm1n1 stage 2 from the previous m1n1-aurora\n' >"$tmp/m1n1.bin" +limine_mac_boot_bin "$tmp/m1n1.bin" "${mac_dtbs[@]}" +blocked "a stale m1n1" "m1n1/boot.bin on the system ESP (/boot/efi) is not m1n1" +limine_mac +rm "$mac_esp/EFI/Linux/omarchy_linux-aurora.efi" +blocked "a missing UKI" "/boot/efi/EFI/Linux/omarchy_linux-aurora.efi (the Limine UKI) is missing" +pass "apple: a wrong device tree, a stale m1n1 or a missing UKI fails the update, explained, with no reboot offered" + +# A Mac without omarchy-mac-boot at all predates it and boots a chain it does +# not manage: preflight is optional, and verify warns instead of blocking. +mkdir -p "$tmp/no-package" +run_update apple-silicon "$tmp/no-package" +(( status == 0 )) && ran omarchy-update-system-pkgs && ran omarchy-update-restart || + fail "apple: without omarchy-mac-boot the update finishes and offers the reboot" "status $status: $(cat "$tmp/err")" +grep -Fq "update-verify on apple-silicon needs omarchy-mac-boot" "$tmp/err" && grep -Fq "The boot files were not verified" "$tmp/err" || + fail "apple: without omarchy-mac-boot the update says the boot files were not verified" "$(cat "$tmp/err")" +[[ ! -s $tmp/sudo ]] || fail "apple: without omarchy-mac-boot nothing asks for root" "$(cat "$tmp/sudo")" +pass "apple: without omarchy-mac-boot the update warns that the boot files were not verified" + +# An omarchy-mac-boot from before update-verify is one package update away. +mkdir -p "$tmp/older/usr/lib/omarchy/mac-boot" "$tmp/older/var/lib/pacman/local/omarchy-mac-boot-20260921-10" +run_update apple-silicon "$tmp/older" +(( status == 1 )) && ! ran omarchy-update-restart || fail "apple: an omarchy-mac-boot without update-verify fails the update and offers no reboot" "status $status" +grep -Fq "update-verify on apple-silicon needs /usr/lib/omarchy/mac-boot/update-verify, which omarchy-mac-boot 20260921-10 does not provide; update omarchy-mac-boot" "$tmp/err" && + grep -Fq "The update is not finished" "$tmp/err" || fail "apple: an omarchy-mac-boot without update-verify is named with its version" "$(cat "$tmp/err")" +pass "apple: an omarchy-mac-boot without update-verify fails the update and asks for its update" diff --git a/test/shell.d/update-disk-space-test.sh b/test/shell.d/update-disk-space-test.sh index 2c7368ea6305..f818acd0e850 100644 --- a/test/shell.d/update-disk-space-test.sh +++ b/test/shell.d/update-disk-space-test.sh @@ -75,6 +75,7 @@ for command in \ omarchy-update-aur-pkgs \ omarchy-update-mise \ omarchy-update-orphan-pkgs \ + omarchy-update-boot \ omarchy-hook \ omarchy-update-analyze-logs \ omarchy-shell \ diff --git a/test/shell.d/update-lock-test.sh b/test/shell.d/update-lock-test.sh index 65a673c6ddde..cc6d8bf1bf37 100644 --- a/test/shell.d/update-lock-test.sh +++ b/test/shell.d/update-lock-test.sh @@ -44,6 +44,7 @@ for command in \ omarchy-update-aur-pkgs \ omarchy-update-mise \ omarchy-update-orphan-pkgs \ + omarchy-update-boot \ omarchy-hook \ omarchy-update-analyze-logs \ omarchy-shell \ diff --git a/test/shell.d/update-sequence-test.sh b/test/shell.d/update-sequence-test.sh index 2dd62b6e43fb..f2c25329ae32 100755 --- a/test/shell.d/update-sequence-test.sh +++ b/test/shell.d/update-sequence-test.sh @@ -20,6 +20,7 @@ steps=( omarchy-snapshot omarchy-update-stay-awake omarchy-update-dev + omarchy-update-boot omarchy-update-keyring omarchy-update-system-pkgs omarchy-migrate @@ -67,6 +68,7 @@ expected_steps() { omarchy-snapshot \ omarchy-update-stay-awake \ omarchy-update-dev \ + omarchy-update-boot \ omarchy-update-keyring \ omarchy-update-system-pkgs \ omarchy-migrate \ @@ -74,6 +76,7 @@ expected_steps() { omarchy-update-aur-pkgs \ omarchy-update-mise \ omarchy-update-orphan-pkgs \ + omarchy-update-boot \ omarchy-update-analyze-logs \ omarchy-update-status \ omarchy-update-stay-awake \