On Sat, Jun 29, 2024 at 19:15:55 -0700, B wrote:
> My objective is to get an email notification when an update is available for
> a specific Debian package.

I already have questions.

Your Subject header includes the word "upstream".  This word appears
*nowhere* else in the entire email, and it completely moves the goalposts.

Are you looking for notifications that a new Debian *package* has become
available, or are you looking for notifications that the *upstream*
developer has released a new version, which may or may not have a
corresponding set of Debian packages?

My next question: is this a package that's *installed* on your system?

If you only care about new Debian packages, and if the package is one
that's installed on your system, then you should be able to slap
something together using "apt-get update" (or unattended-upgrades) and
"apt-cache policy pkgname".

Oh hey, good timing -- a new point release was apparently just dropped.
After an "apt-get update", I have:

hobbit:~$ apt-cache policy bash
bash:
  Installed: 5.2.15-2+b2
  Candidate: 5.2.15-2+b7
  Version table:
     5.2.15-2+b7 500
        500 http://deb.debian.org/debian bookworm/main amd64 Packages
 *** 5.2.15-2+b2 100
        100 /var/lib/dpkg/status

Note that the "Installed:" and "Candidate:" lines differ.  We can write
a simple shell script to compare them.


hobbit:~$ cat pkgcheck
#!/bin/bash

if (($# != 1)); then
    echo "usage: pkgcheck PKGNAME" >&2
    exit 2
fi

installed= candidate=
while read -r line; do
    case $line in
        Installed:*) installed=${line##* } ;;
        Candidate:*) candidate=${line##* } ;;
    esac
done < <(apt-cache policy "$1")

if [[ "$installed" != "$candidate" ]]; then
    printf '%s\n  Installed: %s\n  Candidate: %s\n' \
        "$1" "$installed" "$candidate"
    exit 1
fi

exit 0


hobbit:~$ ./pkgcheck bash
bash
  Installed: 5.2.15-2+b2
  Candidate: 5.2.15-2+b7
hobbit:~$ ./pkgcheck libc6
hobbit:~$ 

Will this do?  It isn't clever about handling packages that have multiple
candidates, so you might want to think about how to deal with those, if
you have that kind of situation.  You can also add some bells and whistles,
like a -q option or whatever you want.

Reply via email to