From 0416d3e61506ba72aa42517bec175914aa03e99a Mon Sep 17 00:00:00 2001 From: Daniele Fucini Date: Sun, 4 Oct 2026 16:05:43 +0200 Subject: [PATCH] Fix kernel update check --- update-notify | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/update-notify b/update-notify index f1b96e5..b3ba6be 100755 --- a/update-notify +++ b/update-notify @@ -54,6 +54,19 @@ pending_version() { 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 # --------------------------------------------------------------------------- @@ -83,15 +96,20 @@ updates=$((arch_updates + aur_updates)) for stock_pkg in "${!KERNELS[@]}"; do custom_pkg=${KERNELS[$stock_pkg]} - # Only relevant if the custom kernel is installed and has no pending update itself - if pacman -Q "$custom_pkg" >/dev/null 2>&1 && ! pending_version "$custom_pkg" >/dev/null; then - if stock_ver=$(pending_version "$stock_pkg"); then - notify_once "kernel-$stock_pkg" "Kernel update available: $stock_pkg" \ - "Rebuild $custom_pkg ($stock_pkg $stock_ver)" - continue - fi + # Skip kernels where either package isn't installed + if ! stock_ver=$(latest_version "$stock_pkg") || ! custom_ver=$(latest_version "$custom_pkg"); then + clear_state "kernel-$stock_pkg" + 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 - clear_state "kernel-$stock_pkg" done # ---------------------------------------------------------------------------