Fix kernel update check
This commit is contained in:
+24
-6
@@ -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)"
|
||||
# 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
|
||||
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
|
||||
done
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user