How to get notifications when a new version of a certain package is available via DNF?

I would like to receive (email) notifications when new stable versions of certain packages are available for download and install on my Fedora installation from the official Fedora RPM repository. Specifically, I would like to know when I can install the updated software via DNF (dnf upgrade package-name). Note that I am not interested in notifications about upstream releases, I just want to know when the software in question has been packaged by Fedora and is available from the official repo.

My first instinct was to head to the Fedora Notifications service. However, I haven’t been able to find anything like that among the options it provides. The closest I’ve come is to configure the following rule:

  • Tracking Rule: Artifacts
  • Artifact names: rpms/package-name-here
  • Destination:
    • Optional Filters:
      • Applications: bodhi
      • Severities: info

However, this gives me notifications for every comment and action in the bodhi threads, which I certainly do not want. Furthermore, even if I were able to filter only the “has been pushed to stable” events from bodhi, it seems that relying on that event is not reliable for my use case either, since it does not actually mean that the updated package is yet installable via DNF (I’ve tried).

Any suggestions?

See an example for firefox: How to get new Release Notes pushed to users with RSS or email? - #5 by ersen

grafik

2 Likes

Bodhi push to stable is not the end. The repo still has to be composed (daily?), then your regional mirror(s) have to update (within hours?). In the worst case, you could wait >1 day after push to stable.

So, the only way to truly know if something is available via dnf is to use dnf on the same machine.

dnf check-update returns 100 when updates are available.

dnf -q --refresh check-update $package &>/dev/null;
if (( $? == 100 )); then
	# email yourself
fi

Instead of constantly --refresh you may want to adjust your dnf-makecache.timer.

2 Likes

You could also use dnf-automatic and configure it to only notify you (dnf-automatic-notifyonly, no download, no install).

The issue could be that you get notified about any update, not just a specific package, but maybe there is a way to tweak dnf-automatic the way you want it.

for more information, see

2 Likes

Thanks both of you for the good suggestions! I’m going to look into them and report back if I end up with a fitting solution.

As it turned out, DNF Automatic was exactly what I needed for my use case! I was able to configure it to only notify me about specific packages, and send me an email notification to my Gmail using the Himalaya email CLI. To help others who may have the same question, here are the steps I took and the configuration files I created.

Steps

  1. Installed DNF Automatic: sudo dnf install dnf-automatic
  2. Created a configuration file for DNF Automatic
  3. Created a user-specific systemd service file
  4. Created a user-specific systemd timer file
  5. Enabled the notification timer: systemctl enable --user --now dnf-automatic-notify.timer

Configuration files

~/.config/dnf-automatic/notify-via-email.conf
[commands]
# only notify, do not download or apply
download_updates = no
apply_updates = no

[emitters]
emit_via = command

[command]
# append the body to the template and send via Himalaya
command_format = "cat $XDG_DATA_HOME/himalaya/templates/dnf-automatic-notify.txt - | himalaya template send"
stdin_format = "{body}"

[base]
# This section overrides dnf.conf

# for some reason, `color="never"` does not work here, so instead
# we just override the color for this specific case to be normal
color_update_remote = "normal"

# only notify for these packages
# separate items with either a comma or a space
includepkgs = kernel*

~/.local/share/systemd/user/dnf-automatic-notify.service
[Unit]
Description=Notifies for DNF updates
# See comment in dnf-makecache.service
ConditionPathExists=!/run/ostree-booted

[Service]
Type=oneshot
Nice=19
IOSchedulingClass=best-effort
IOSchedulingPriority=7
Environment="ABRT_IGNORE_PYTHON=1"
ExecStart=/usr/bin/dnf-automatic ~/.config/dnf-automatic/notify-via-email.conf --timer
~/.local/share/systemd/user/dnf-automatic-notify.timer
[Unit]
Description=Timer for dnf-automatic-notify
# See comment in dnf-makecache.service
ConditionPathExists=!/run/ostree-booted

[Timer]
# Every day at 12:00
OnCalendar=*-*-* 12:00
Persistent=true

[Install]
WantedBy=timers.target

If you want to use Himalaya for sending emails, refer to their documentation to configure it for your needs.


Important notes

The includepkgs option of DNF

If you run dnf-automatic directly (not via a service) and DNF fails to resolve a candidate for the listed package or there are conflicts with it, DNF Automatic will fail silently*, and your configured command won’t be run. This can happen if you have included packages that depend on other packages. For example, if you only include firefox , DNF will likely fail unless you also include firefox-langpacks. Alternatively, you can use a wildcard: firefox*.

* This is true even if you use debugmode=10!

DNF Automatic will be be obsoleted in Fedora 39

If you’re configuring DNF Automatic for Fedora 38, be aware that your setup may not be very long-lived. DNF Automatic is scheduled to be obsoleted in Fedora 39, and will be replaced by a new tool. Anyone using DNF Automatic will likely need to change their setup to use the new tool.

2 Likes

Great to learn that one can specify certain packages to be considered for dnf-automatic. Thanks for your write-up!

1 Like

A post was split to a new topic: Fedora Message Notifications