diff --git a/migrations/1791898365.sh b/migrations/1791898365.sh index 2eaec5d0b512..6b3c44966cc4 100644 --- a/migrations/1791898365.sh +++ b/migrations/1791898365.sh @@ -41,6 +41,23 @@ if ! sudo grep -Eqi '^[[:space:]]*quiet:' "$limine_conf"; then added_quiet=1 fi +# Secure Boot with config enrollment checks the menu against a checksum in +# the boot image, so the menu has to be rebuilt into it or the next boot +# panics. A run after a failed rebuild finds the menu already edited, so +# the rebuild does not wait for an edit in this run. +if omarchy-cmd-present limine-mkinitcpio; then + rebuild_log=$(mktemp) + trap 'rm -f "$rebuild_log"' EXIT + sudo limine-mkinitcpio 2>&1 | tee "$rebuild_log" + + # limine-mkinitcpio reports a kernel it could not rebuild and still exits 0. + # The menu no longer matches that image, so the migration stays pending. + if grep -q 'mkinitcpio failed for kernel' "$rebuild_log"; then + echo "A boot image was not rebuilt. Fix the error above, then run omarchy-migrate again before rebooting." >&2 + exit 1 + fi +fi + if [[ -n $set_timeout && -n $added_quiet ]]; then echo "The boot menu now waits 1 second and stays quiet until a key is pressed" elif [[ -n $set_timeout ]]; then