Repository navigation
Retire a kernel downgrade's saved modules before m1n1 is rebuilt - #577
Merged
Merged
Conversation
After a downgrade, kernel-modules-hook puts the running kernel's modules back in /usr/lib/modules until the next boot, where they are the newest -ARCH tree: update-m1n1's default then builds m1n1 with the running kernel's device trees and update-verify refuses the reboot, with no way out on the Mac. A pacman hook that runs right after kernel-modules-hook's restore now moves that copy to /usr/lib/modules/.old, as linux-modules-cleanup would at boot, only when it is the running kernel's unowned tree directly above the kernel the transaction installed and m1n1 takes its device trees from that default.
…wngrade-module-cleanup # Conflicts: # packages/omarchy-mac/boot/README.md
A package that still owns the running kernel's tree (its headers) or another tree between it and the installed kernel leaves m1n1 on the running kernel's device trees; the hook now names the cause instead of exiting silently.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Ticket 68 (gap audit row B15): a kernel downgrade no longer leaves m1n1 with the running kernel's device trees.
The problem: after a downgrade (a channel move, a reinstall from the cache, a migration to an older Aurora), kernel-modules-hook puts the running kernel's modules back in
/usr/lib/modules, owned by no package, untillinux-modules-cleanupmoves them at the next boot. Until then, that copy is the newest-ARCHtree. update-m1n1's ALARM default (95-m1n1-install.hook) builds m1n1 stage 2 from its device trees.update-verifythen refuses the reboot, and nothing on the Mac clears it.The fix: omarchy-mac-boot ships
11-omarchy-mac-saved-modules.hook. It runs right after kernel-modules-hook's10-linux-modules-post.hookrestores the copy, and before depmod, mkinitcpio, Limine and the m1n1 hook. It moves the copy to/usr/lib/modules/.old, as the cleanup service would at boot. It only acts when all of these hold, the same rules as mx'somarchy-apple-silicon-retire-saved-modules:-ARCHdefault, with no DTBS or M1N1_UPDATE_DISABLED set.It runs inside the transaction, so pacman's lock already covers it. It takes no lock of its own and does not rerun update-m1n1: the m1n1 hook runs after it. Every pacman path is covered:
omarchy update,omarchy-reinstall-pkgs, apacman -Ufrom the cache, and the migration engine's transaction. mx could only cover its own update script. The cost matches mx: the running kernel cannot load new modules until the reboot, and the hook says so. Limine's install hook skips module trees no package owns, so no stale menu entry arises.Tests:
test/mac-saved-modules-test.shcovers hook order and trigger, and the downgrade fixture through the realupdate-verify. Without the hook, update-verify refuses the running kernel's device trees. With it, update-verify passes with the reboot pending, and the copy is in.old. Cases that must be left alone are covered too, with the reason printed where a downgrade stays broken: an upgrade, a reinstall of the running kernel, an owned or intervening tree, no kernel-modules-hook, DTBS configured or m1n1 disabled, a symlink. So is a failed copy..old.Second review: no blockers. Applied: after a downgrade, the hook now says why it left the saved tree in place. That happens when the running kernel's headers still own it, or when another tree sits in between. It was silent before. Dropped a test assertion about the Limine menu that the fixture could not falsify. Limine's filter for trees no package owns is from
limine-mkinitcpio-install(limine-mkinitcpio-hook 1.39.0-2).Merged current quattro-upstream (README conflict with #535's speakersafetyd note, both kept). Independent of #576 (ticket 67); the two merge cleanly in either order.