DNF-POST-TRANSACTION-ACTIONS(8)

πŸ“¦
version 4.3.1 Β· 3 versions
, in debian bookworm, ubuntu noble

πŸ’– DNF-POST-TRANSACTION-ACTIONS(8) πŸ’–

okay bestie, pull up a chair, we're talking about dnf-post-transaction-actions β€” a little plugin from the dnf-plugins-core crew that lets you make stuff happen after an RPM transaction finishes. literally the "and then what" of package management. πŸŽ€


✨ NAME ✨

dnf-post-transaction-actions β€” the DNF post transaction actions Plugin. that's it, that's the name, and honestly? iconic. πŸ‘‘


🌸 DESCRIPTION 🌸

so here's the vibe: this plugin lets you define actions that get executed once an RPM transaction is done. and each action can define a (glob-like) filtering rule, either on the package NEVRA or on package files, plus whether the package was installed or removed. all of that lives in something called action files. πŸ¦‹


πŸ’… CONFIGURATION πŸ’…

the plugin's config lives right here:

/etc/dnf/plugins/post-transaction-actions.conf

and every single config option chills in the [main] section. no cap.

  • enabled β€” whether the plugin is enabled. default value is True. (yes bestie, it's on by default, she's eager like that πŸ’–)
  • actiondir β€” the path to the directory holding your action files. heads up: action files must have the .action extension or they simply do not count. default value is /etc/dnf/plugins/post-transaction-actions.d/.

🫢 ACTION FILE FORMAT 🫢

empty lines? ignored. lines starting with a # character? also ignored. we love a comment that minds its own business. πŸ™ˆ

each non-comment line defines an action, and it's made of three items separated by colons:

package_filter:transaction_state:command

let's break it down, one by one, no skipping. ⭐

package_filter

a (glob-like) filtering rule applied on the package NEVRA β€” and yes, also in the shortened forms β€” or on package files.

transaction_state

this one filters packages according to their state in the transaction. three options, take your pick:

  • in β€” packages that appeared on the system (downgrade, install, obsolete, reinstall, upgrade)
  • out β€” packages that disappeared from the system (downgraded, obsoleted, remove, upgraded)
  • any β€” all packages. every single one. the whole friend group. πŸ’€

command

any shell command, bestie. ANY. and the following variables inside the command get substituted:

  • ${name}, $name β€” package name
  • ${arch}, $arch β€” package arch
  • ${ver}, $ver β€” package version
  • ${rel}, $rel β€” package release
  • ${epoch}, $epoch β€” package epoch
  • ${repoid}, $repoid β€” package repository id
  • ${state}, $state β€” the change of package state in the transaction: downgrade, downgraded, install, obsolete, obsoleted, reinstall, reinstalled, remove, upgrade, upgraded

the shell command gets evaluated for every package that matched the package_filter and the transaction_state. but here's the plot twist: after variable substitution, any duplicate commands get removed, and each command is only executed once per transaction. one and done, we don't do encores. πŸ’…

as for order? the order of execution of the commands follows the order in the action files, but it may differ from the order of packages in the transaction. so β€” when you define several action lines for the same package_filter, those lines will be executed in the order they were defined in the action file, when the package_filter matches a package during the transaction_state state. HOWEVER, the order of when a particular package_filter gets invoked depends on the position of the corresponding package in the transaction. yes it's a little unhinged. yes it's fine. πŸŒ€

🌈 An example action file 🌈

# log all packages (state, nevra, repo) in transaction into a file.
*:any:echo '${state} ${name}-${epoch}:${ver}-${rel}.${arch} repo ${repoid}' >>/tmp/post-trans-actions-trans.log

# The same shell command (after variables substitution) is executed only once per transaction.
*:any:echo '${repoid}' >>/tmp/post-trans-actions-repos
# will write each repo only once to /tmp/post-trans-actions-repos, even if multiple packages from
# the same repo were matched

look at her go. πŸ₯Ή


πŸ‘‘ AUTHOR πŸ‘‘

See AUTHORS in your Core DNF Plugins distribution.


2023, Red Hat, Licensed under GPLv2+


bestie this is version 4.3.1, dated Jan 22, 2023, and it's part of the dnf-plugins-core distribution. go forth and post-transaction-action responsibly. slay, periodt. πŸ’–βœ¨πŸŽ€πŸ¦‹πŸŒΈπŸ«Ά
πŸ“¦ where this page comes from