From 63d56da08947a03e366b28d879207c218331c07b Mon Sep 17 00:00:00 2001 From: David Young Date: Mon, 26 Oct 2026 14:10:47 -0600 Subject: [PATCH] reboot messages --- updates.d/99-reboot-check.sh | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/updates.d/99-reboot-check.sh b/updates.d/99-reboot-check.sh index c4ce7b9..c5872bb 100755 --- a/updates.d/99-reboot-check.sh +++ b/updates.d/99-reboot-check.sh @@ -2,9 +2,33 @@ source "$HOME/.local/share/coredesktop/utils.sh" +# Packages whose upgrade only fully takes effect after a reboot: the kernel and +# firmware, the NVIDIA driver (the loaded module must match the installed +# one), CPU microcode, and the core libraries every running program uses +REBOOT_PACKAGES='linux|linux-lts|linux-zen|linux-hardened|linux-firmware.*|nvidia.*|.*-ucode|systemd|glibc' + if initramfs_build_failed; then echo -e "\e[31mDon't reboot yet: the initramfs failed to rebuild (see $PACMAN_UPDATE_LOG).\e[0m" + exit 0 +fi + +reasons=() + # If the running kernel's modules are gone, a newer kernel was installed -elif [ ! -d "/usr/lib/modules/$(uname -r)" ]; then - echo "A newer kernel has been installed. Please reboot when convenient." +if [ ! -d "/usr/lib/modules/$(uname -r)" ]; then + reasons+=("a newer kernel was installed") +fi + +# Packages upgraded by this update's pacman -Su (see updates.d/10-pacman.sh) +if [ -f "$PACMAN_UPDATE_LOG" ]; then + mapfile -t upgraded < <(tr '\r' '\n' < "$PACMAN_UPDATE_LOG" \ + | grep -oP 'upgrading \K[^ ]+' | sort -u | grep -xE "$REBOOT_PACKAGES") + if (( ${#upgraded[@]} > 0 )); then + reasons+=("${upgraded[*]} upgraded") + fi +fi + +if (( ${#reasons[@]} > 0 )); then + reason="$(printf '%s; ' "${reasons[@]}")" + echo -e "\e[33mPlease reboot when convenient to finish this update (${reason%; }).\e[0m" fi