Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44dc555c18
|
||
|
|
5c0995a23f
|
||
|
|
f9ee58b098
|
||
|
|
633c48431b
|
||
|
|
aee4e886fd
|
||
|
|
2aee0b62bc
|
||
|
|
5894d7b889
|
||
|
|
2449ee109e
|
||
|
|
bb9012599c
|
||
|
|
77a83f1642
|
||
|
|
ba79773baa
|
@@ -3,19 +3,19 @@
|
|||||||
# Maintainer: Daniele Fucini <dfucini [at] gmail [dot] com>
|
# Maintainer: Daniele Fucini <dfucini [at] gmail [dot] com>
|
||||||
|
|
||||||
pkgname=update-notify
|
pkgname=update-notify
|
||||||
pkgdesc='Notify when updates are available'
|
pkgver=2.0
|
||||||
pkgver=1.0
|
|
||||||
pkgrel=1
|
pkgrel=1
|
||||||
url="https://github.com/Fuxino/${pkgname}"
|
pkgdesc='Notify when updates are available'
|
||||||
arch=('any')
|
arch=('any')
|
||||||
|
url="https://git.shouldnt.work/fuxino/${pkgname}"
|
||||||
license=('GPL-3.0-or-later')
|
license=('GPL-3.0-or-later')
|
||||||
makedepends=('git')
|
|
||||||
depends=('pacman-contrib'
|
depends=('pacman-contrib'
|
||||||
'aurutils')
|
'aurutils')
|
||||||
conflicts=('update-notify-git')
|
makedepends=('git')
|
||||||
|
optdepends=('git-monitor: to check git repos for updates')
|
||||||
source=(git+${url}?signed#tag=${pkgver})
|
source=(git+${url}?signed#tag=${pkgver})
|
||||||
validpgpkeys=('7E12BC1FF3B6EDB2CD8053EB981A2B2A3BBF5514')
|
validpgpkeys=('7E12BC1FF3B6EDB2CD8053EB981A2B2A3BBF5514')
|
||||||
sha256sums=('207cd889985b541cfa5f486c90856c8ac4780cfb53fb871328654cab141d962b')
|
sha256sums=('907b2f1ad229096dc520a65e8e4319dba575a759d2e23248aff810e01d0c4a02')
|
||||||
|
|
||||||
package()
|
package()
|
||||||
{
|
{
|
||||||
|
|||||||
+62
-20
@@ -1,27 +1,69 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
if [ "$#" -eq 1 ]; then
|
# Default threshold or user argument
|
||||||
threshold=$1
|
threshold=${1:-30}
|
||||||
else
|
|
||||||
threshold=30
|
# Fetch checkupdates once to prevent multiple network/disk calls
|
||||||
|
mapfile -t arch_list < <(checkupdates 2>/dev/null)
|
||||||
|
arch_updates=${#arch_list[@]}
|
||||||
|
|
||||||
|
# Count AUR updates safely
|
||||||
|
aur_updates=$(aur repo -u -d aur-local 2>/dev/null | wc -l)
|
||||||
|
updates=$((arch_updates + aur_updates))
|
||||||
|
|
||||||
|
# Check kernel running environment
|
||||||
|
running_kernel=$(uname -r)
|
||||||
|
is_lts=0; [[ $running_kernel == *lts* ]] && is_lts=1
|
||||||
|
|
||||||
|
# Convert the array to a single string for quick regex matching
|
||||||
|
arch_str="${arch_list[*]}"
|
||||||
|
|
||||||
|
# Check for custom package updates in the list
|
||||||
|
has_custom=0; [[ $arch_str == *linux-custom* ]] && has_custom=1
|
||||||
|
has_custom_lts=0; [[ $arch_str == *linux-lts-custom* ]] && has_custom_lts=1
|
||||||
|
|
||||||
|
# Define localized logic for kernel checking
|
||||||
|
check_kernel_update() {
|
||||||
|
local pkg=$1
|
||||||
|
local item
|
||||||
|
|
||||||
|
# Precise array element matching (avoids false-positive substring matches)
|
||||||
|
for item in "${arch_list[@]}"; do
|
||||||
|
if [[ "$item" == "$pkg "* ]]; then
|
||||||
|
return 0 # Package found in the updates array, update is definitely available
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Fallback to vercmp if running kernel doesn't match the sync repo
|
||||||
|
local repo_ver
|
||||||
|
repo_ver=$(pacman -Si "$pkg" 2>/dev/null | awk -F': ' '/Version/ {print $2}')
|
||||||
|
|
||||||
|
# Crucial Fix: vercmp returns > 0 ONLY if repo_ver is strictly newer than running_kernel
|
||||||
|
if [[ -n $repo_ver ]] && (( $(vercmp "$repo_ver" "$running_kernel") > 0 )); then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
# Evaluate Kernel notifications based on environment
|
||||||
|
if (( is_lts == 0 && has_custom == 0 )); then
|
||||||
|
check_kernel_update "linux" && notify-send "Kernel update available" "Rebuild custom kernel"
|
||||||
|
elif (( is_lts == 1 && has_custom_lts == 0 )); then
|
||||||
|
check_kernel_update "linux-lts" && notify-send "LTS Kernel update available" "Rebuild custom kernel"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
arch_updates=$(checkupdates | wc -l)
|
|
||||||
aur_updates=$(aur repo -u -d aur-local | wc -l)
|
|
||||||
#kernel_update=$(checkupdates | grep linux | grep -v custom | grep -v archlinux | grep -v api | grep -v firmware | wc -l)
|
|
||||||
|
|
||||||
#if [ "$kernel_update" -eq 0 ]; then
|
# Main updates notification threshold logic
|
||||||
# kernel_update=$(vercmp `pacman -Si linux | grep Version | cut -d':' -f2` `uname -r`)
|
if (( updates >= threshold )); then
|
||||||
#fi
|
|
||||||
|
|
||||||
#built_kernel=$(checkupdates | grep linux-custom | wc -l)
|
|
||||||
|
|
||||||
updates=$(($arch_updates + $aur_updates))
|
|
||||||
|
|
||||||
#if [ "$kernel_update" -ge 1 ] && [ "$built_kernel" -eq 0 ]; then
|
|
||||||
# notify-send "Kernel update available" "Rebuild custom kernel"
|
|
||||||
#fi
|
|
||||||
|
|
||||||
if [ "$updates" -ge "$threshold" ]; then
|
|
||||||
notify-send "Updates available" "Arch: $arch_updates, AUR: $aur_updates"
|
notify-send "Updates available" "Arch: $arch_updates, AUR: $aur_updates"
|
||||||
|
|
||||||
|
# Directly check command availability inline (no function needed)
|
||||||
|
if command -v git-monitor >/dev/null 2>&1; then
|
||||||
|
notify-send "Check git packages" "Use git-monitor for git packages updates"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if command -v fwupdmgr >/dev/null 2>&1; then
|
||||||
|
notify-send "Check firmware" "Use fwupdmgr to check for firmware updates"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@ Description=Run update-notify every 6 hours
|
|||||||
|
|
||||||
[Timer]
|
[Timer]
|
||||||
OnBootSec=5min
|
OnBootSec=5min
|
||||||
OnUnitActiveSec=6h
|
OnUnitActiveSec=12h
|
||||||
Persistent=true
|
Persistent=true
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
|||||||
Reference in New Issue
Block a user