How to run a custom script whenever a specific package is updated by `dnf`?


I want to run a custom script every time the NVIDIA driver package is updated by dnf on my system. Is there any recommended approach to automate this step in Fedora?


You could try, DNF post-transaction-actions Plugin — dnf-plugins-core 4.4.1-1 documentation


If your script would be helpful to other NVIDIA users, you could suggest to NVIDIA that they provide equivalent functionality in their packages.

And / or a similar suggestion to rpmfusion who packages those drivers for use on fedora.

I know an rpm can run a post install script, but doesn’t this need a post transaction script?

For example if the transaction contains nvdia and kernel then you need to wait for akmod to complete before a reboot.

I am not sure you can have that in an rpm spec file.

I have python code to wait for akmod to finish, actually all systemd jobs active after a dnf update. I use that code to delay rebooting.

Innovative and potentially helpful to others if we could see the content of the script.

The script is part of my update-linux command.

Project page

That assumes i am updating from another computer. But i could design a version for use on the fedora system being updated.

For most users the script on the system being updated would be needed. For data centers or other larger installations your current design would be useful since there would be multiple systems to be kept in sync. The home user (which is where most problems seem to occur) would not normally have multiple systems to maintain.

I’ll look to add update-linux --self option.
No promisies on time scales…

I’m that home user with lots of Fedora systems, hence the need for the script.
I run 8 Fedora’s at the moment.

I am impressed.
Don’t have the funds to support that many systems myself.