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
21 changes: 20 additions & 1 deletion bin/omarchy-lifecycle-dispatch
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion bin/omarchy-update
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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
43 changes: 43 additions & 0 deletions bin/omarchy-update-boot
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

# omarchy:summary=Run the platform's boot checks around the update's package changes
# omarchy:args=<preflight|verify>
# 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 <preflight|verify>" >&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
23 changes: 16 additions & 7 deletions docs/lifecycle-dispatch.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: <operation> on <platform> needs <package>, which provides <path>; 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: <operation> on <platform> needs <package>, which provides <path>; 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: <operation> on <platform> needs <path>, which <package> <version> does not provide; update <package>` | 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 <path>: ...` (optional operations too) | same error |
| `omarchy-hw-platform` can't settle the platform | exit 1 | exit 1 |
Expand All @@ -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

Expand All @@ -48,7 +49,7 @@ Registration is code in `bin/omarchy-lifecycle-dispatch`, not configuration. No

The entrypoint for an operation is `<implementation directory>/<operation>`. 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

Expand All @@ -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):
Expand All @@ -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/<operation>`, 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`.
Expand All @@ -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
Expand Down
11 changes: 9 additions & 2 deletions docs/update-process.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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. |
Expand Down
Loading
Loading