Skip to content

Repair stale boot images before restart - #6840

Open
yashranaway wants to merge 9 commits into
omacom:quattrofrom
yashranaway:fix/verify-updated-boot-image
Open

yashranaway wants to merge 9 commits into
omacom:quattrofrom
yashranaway:fix/verify-updated-boot-image

Conversation

@yashranaway

@yashranaway yashranaway commented Aug 13, 2026 •

Copy link
Copy Markdown
Contributor

Keep a swallowed UKI build failure from turning a successful update into an unbootable restart.

Fixes #5706.

<<< AI wording below >>>

Problem

The current limine-mkinitcpio-install turns an individual UKI build failure back into success. Pacman completes, Omarchy continues, and can offer a reboot even though /usr/lib/modules contains a newer kernel than the UKI deployed on the ESP. The existing log analyzer warns about some initcpio failures but does not stop the update or prove which image Limine will boot.

Fix

Verify boot images only when UKIs are effectively enabled. Read ENABLE_UKI in limine-entry-tool's configuration order, including later drop-ins and /etc/default/limine, without executing configuration as shell. Empty and quoted values follow the upstream parser.

Verification

bash test/shell.d/update-boot-verification-test.sh passes. Changed Bash files pass syntax checks and git diff --check passes. Tests use boot-image and configuration fixtures; no real boot or UKI rebuild was performed.

Review follow-up, 1 October

Only active Limine path entries count. Boot images are checked again after AUR changes. The final check intentionally requires a separate uncached sudo prompt, with privileged Bash startup, because the earlier authorization is revoked before third-party builds. Failure blocks the reboot phase.

Focused regressions, Bash syntax, command metadata, and diff checks pass. Hardware and live Hyprland behavior were not exercised on this host.

The Limine mkinitcpio hook can return success after an individual UKI build fails, leaving pacman and omarchy update free to finish with an old boot image. Compare each package-owned kernel with its UKI metadata and Limine hash before offering a restart, rebuild once on mismatch, and stop the update when repair does not converge.
Copilot AI balanced review requested due to automatic review settings August 13, 2026 22:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds post-update boot-image verification and one repair attempt before restart.

Changes:

  • Verifies kernel versions and Limine hashes.
  • Repairs stale UKIs once, then blocks unsafe restarts.
  • Adds shell coverage for verification and failure propagation.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 1 out of 3 changed files in this pull request and generated no comments.

File Description
bin/omarchy-update-verify-boot Implements boot-image verification and repair.
bin/omarchy-update-analyze-logs Runs verification before update completion.
test/shell.d/update-boot-verification-test.sh Tests healthy, stale, repaired, and failed images.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@jdvmi00

jdvmi00 commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

omarchy-update-verify-boot decides whether UKIs are in use from omarchy-uki.conf alone, but limine-entry-tool lets later files override it: /usr/share/limine-entry-tool.d/*.conf, then /etc/limine-entry-tool.conf, then /etc/limine-entry-tool.d/*.conf in glob order, then /etc/default/limine, with the last ENABLE_UKI winning. On a UEFI machine where a later file sets ENABLE_UKI=no, the check finds no UKI, rebuilds, still finds none, and ends the update with "Do not reboot". #13426 does that on the DGX Spark, and a user setting it in /etc/default/limine would hit the same thing.

Reading the effective value would avoid it:

uki=
for file in /usr/share/limine-entry-tool.d/*.conf /etc/limine-entry-tool.conf \
  /etc/limine-entry-tool.d/*.conf /etc/default/limine; do
  [[ -f $file ]] || continue
  value=$(sed -nE 's/^[[:space:]]*ENABLE_UKI[[:space:]]*=[[:space:]]*"?([^"]*)"?[[:space:]]*$/\1/p' "$file" | tail -n 1)
  [[ -z $value ]] || uki=$value
done
[[ $uki == "yes" ]] || exit 0

@greptile-apps

greptile-apps Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[High impact] The PR appears safe to merge; no outstanding boot-verification finding or new actionable issue was identified.

Summary

The PR adds a final boot check after AUR package updates. On generic UEFI systems, it checks active Limine entries and UKIs against installed kernels, attempts one repair when needed, and withholds the reboot prompt if verification fails. It retains platform-specific lifecycle verification and adds focused tests and documentation.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Package and AUR updates] --> B[Final boot check]
  B --> C{Platform boot verifier?}
  C -- Yes --> D[Run lifecycle update-verify]
  C -- No, generic UEFI --> E[Check Limine UKIs]
  E --> F{Images valid and no logged build failure?}
  F -- No --> G[Rebuild once and recheck]
  F -- Yes --> H[Offer reboot]
  G -- Pass --> H
  G -- Fail --> I[Stop without reboot prompt]
  D -- Pass --> H
  D -- Fail --> I
Loading

Reviews (4) · Last reviewed commit: "Merge current quattro and verify generic..." · Reviewed by Greptile

Comment thread bin/omarchy-update-verify-boot Resolved
Comment thread bin/omarchy-update-analyze-logs Resolved
@yashranaway

Copy link
Copy Markdown
Contributor Author

The verifier now follows the full Limine configuration order and upstream value parsing. Later, empty and literal-quoted overrides are covered, and the boot-verification regression passes.

Comment thread bin/omarchy-update Resolved
@omarchybot

Copy link
Copy Markdown
Collaborator

I reviewed this at 5d5825d and ran it on a disposable worker built from the current Omarchy ISO (x86, linux-omarchy 7.2.5-3, Limine with a UKI and ENABLE_VERIFICATION=yes). The problem it targets is still real on quattro, but the verifier has a defect that would stop every update on a healthy machine, and the branch no longer merges.

The verifier changes the UKI it checks. bin/omarchy-update-verify-boot:85 runs objcopy --dump-section .uname=/dev/stdout "$uki" with no output file, and objcopy then rewrites the input in place. On the worker, right after a clean limine-mkinitcpio, the UKI's BLAKE2b went from 868715ac… (the hash in limine.conf) to 0ee0498e… after that one command: same size, new mtime. The check then finds a hash mismatch it created, rebuilds, breaks the hash again the same way, and ends with "Do not reboot". The ESP is left with a UKI whose hash no longer matches limine.conf, so Limine's checksum verification rejects that entry. The tests miss it because their fixture is an ELF built from /bin/true, which objcopy writes back unchanged. A real UKI is PE.

Writing to a separate file instead, objcopy -O binary --only-section=.uname "$uki" "$tmp" (run as root, reading $tmp afterwards), leaves the UKI untouched. With only that line changed, the worker showed:

  • a healthy machine passes without a rebuild, and the hash stays intact
  • a UKI made stale (its .uname rewritten to an older kernel, with limine.conf hashed to match, as the hook leaves it) is caught, rebuilt once, reported repaired, and passes a second run
  • with the rebuild made to fail (a mkinitcpio drop-in naming a module that does not exist, standing in for a failed DKMS build), the hook prints mkinitcpio failed for kernel 7.2.5-3-omarchy, skipping. and exits 0, the UKI keeps the old kernel, and the verifier exits 1 with "Do not reboot".

On quattro itself, the same stale UKI goes through omarchy-update-boot (exit 0, since the update-verify dispatch is a no-op on x86) and through omarchy-update-analyze-logs without a word. That confirms the bug the pull request is fixing.

Two gaps, found by reading the code:

  • Only .uname and the Limine hash are compared. If a rebuild fails while the kernel version stays the same (an NVIDIA DKMS upgrade on its own), the old image still matches both checks and passes.
  • If no kernel tree is owned by a package, nothing is checked and the verifier passes.

It no longer merges with quattro. quattro now ends the update with its own post-AUR gate, omarchy-update-boot. That gate runs the update-verify lifecycle operation with a cold sudo through the no-update wrapper, and blocks the reboot prompt when the operation fails. On x86 it does nothing. This pull request's final check belongs behind that gate, as the generic x86 path. Placing it there is a design decision as well as a conflict to resolve. docs/lifecycle-dispatch.md on quattro says "the update path rebuilds no boot file itself", and this verifier rebuilds once. Whether the update should repair the image or only refuse the reboot is the maintainer's call. A smaller alternative also exists: refuse the reboot when the log shows mkinitcpio failed for kernel. #14062, which also changes omarchy-update-analyze-logs, does the warning half of that.

Tests: update-boot-verification-test.sh (11 passed) and update-sequence-test.sh (4 passed) on the worker. ./test/cli had one failure, vscode generated theme references current theme file, which is outside this diff. I pushed nothing: the objcopy fix is one line, but the shape this takes on quattro has to be settled first.

Second opinion from Codex Medium. It agreed on the objcopy defect, but my brief asked it whether any command modifies the files it checks, so that agreement is not independent. It contributed the two gaps above and the smaller log-based alternative, both of which I checked against the source. Waiting on the maintainer to decide how x86 boot verification should fit into quattro's update gate, and whether it may rebuild. After that, the author can port it with the objcopy fix.

@yashranaway

Copy link
Copy Markdown
Contributor Author

Fixed in d44d48e. The verifier now extracts .uname to a separate file, and a PE regression checks that a healthy UKI's hash stays unchanged. I merged current quattro and put the check behind its post-AUR boot gate. A missing package-owned kernel fails closed; a logged mkinitcpio failed for kernel forces one rebuild, and another silent build failure blocks reboot. The focused verifier, update-sequence, boot-gate, and bin-style tests pass.

@omarchybot omarchybot removed the bug Something isn't working label Oct 15, 2026
@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for the update. I looked at d44d48e by reading it. Nothing ran on a worker this time, because the classification is now unsettled. I took this as a bug fix. Codex Medium, asked separately without my answer, classed it as an enhancement. I've taken the bug label off until that is settled.

The split makes sense. The new head does more than fix a hook that hides a failed build. It changes what an x86 update deliberately does on quattro, in two ways:

  • Every UEFI update gets a root step. bin/omarchy-update-boot now runs sudo /bin/bash -p .../omarchy-update-verify-boot on any machine with /sys/firmware/efi. That includes machines with UKIs disabled, where the verifier exits straight away. On quattro that step does nothing on x86 and never asks for root. docs/update-process.md in this PR says it can now mean one more password prompt at the end of an update. test/shell.d/update-boot-verify-test.sh:78 still passes "x86 … nothing asks for root", but only because line 25 points the EFI check at a directory that doesn't exist.
  • The update may now rebuild boot files. docs/lifecycle-dispatch.md on quattro says "The update path rebuilds no boot file itself". This PR replaces that line with a generic check that runs limine-mkinitcpio once.

From reading, the earlier findings look addressed. .uname is extracted to a separate file instead of rewriting the UKI. A logged mkinitcpio failed for kernel forces a rebuild. Finding no package-owned kernel now fails closed. None of that has been run here yet.

This is waiting on the maintainer. They need to decide whether x86 updates should gain this root step and the rebuild. If they want it, it goes on to a worker, with the reproduction run against quattro and this head.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Login loop after update if nvidia DKMS fails to build for the new kernel

4 participants