35 lines
1.2 KiB
Bash
Executable File
35 lines
1.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
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
|
|
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
|