Fix kernel update check

This commit is contained in:
Daniele Fucini
2026-10-04 16:05:43 +02:00
parent 154fd39b20
commit 0416d3e615
+26 -8
View File
@@ -54,6 +54,19 @@ pending_version() {
return 1 return 1
} }
# Newest known version of $1: the pending version if an update is queued,
# otherwise the installed version. Returns 1 if the package isn't installed.
latest_version() {
local pkg=$1 ver
if ver=$(pending_version "$pkg"); then
printf '%s\n' "$ver"
elif ver=$(pacman -Q "$pkg" 2>/dev/null); then
printf '%s\n' "${ver#* }"
else
return 1
fi
}
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
# Gather updates # Gather updates
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------
@@ -83,15 +96,20 @@ updates=$((arch_updates + aur_updates))
for stock_pkg in "${!KERNELS[@]}"; do for stock_pkg in "${!KERNELS[@]}"; do
custom_pkg=${KERNELS[$stock_pkg]} custom_pkg=${KERNELS[$stock_pkg]}
# Only relevant if the custom kernel is installed and has no pending update itself # Skip kernels where either package isn't installed
if pacman -Q "$custom_pkg" >/dev/null 2>&1 && ! pending_version "$custom_pkg" >/dev/null; then if ! stock_ver=$(latest_version "$stock_pkg") || ! custom_ver=$(latest_version "$custom_pkg"); then
if stock_ver=$(pending_version "$stock_pkg"); then clear_state "kernel-$stock_pkg"
notify_once "kernel-$stock_pkg" "Kernel update available: $stock_pkg" \ continue
"Rebuild $custom_pkg ($stock_pkg $stock_ver)" fi
continue
fi # Notify while the stock kernel is newer than the newest custom build
# (installed, or already built into your repo but not yet installed)
if (( $(vercmp "$stock_ver" "$custom_ver") > 0 )); then
notify_once "kernel-$stock_pkg" "Kernel update available: $stock_pkg" \
"Rebuild $custom_pkg ($stock_pkg $stock_ver)"
else
clear_state "kernel-$stock_pkg"
fi fi
clear_state "kernel-$stock_pkg"
done done
# --------------------------------------------------------------------------- # ---------------------------------------------------------------------------