I have created the snapper.actions files with the template provided in the documentation:
# Creates pre snapshot before the transaction and stores the snapshot number in the "tmp.snapper_pre_number" variable.
pre_transaction::::/usr/bin/sh -c echo\ "tmp.snapper_pre_number=$(snapper\ create\ -t\ pre\ -p)"
# If the variable "tmp.snapper_pre_number" exists, it creates post snapshot after the transaction and removes the variable "tmp.snapper_pre_number".
post_transaction::::/usr/bin/sh -c [\ -n\ "\${tmp.snapper_pre_number}"\ ]\ &&\ snapper\ create\ -t\ post\ --pre-number\ "\${tmp.snapper_pre_number}"\ ;\ echo\ tmp.snapper_pre_number
It works correctly except that it does not describe which package is updated and that sort of makes it useless.
Thank you for answering. Adding pkg.nevra did not solve it. Regarding your questions, it only creates one pre and post regardless of the number of packages installed at a time.
Each non-comment line defines an action and consists of five items separated by colons: callback_name:package_filter:direction:options:command .
If package_filter from that has nothing, you get you value for ${pkg.*} which makes it pretty useless really. It’d be nice to be able to get the dnf command called itself or something in this, because if you set package_filter to * it runs it MULTIPLE times, once per package, and we certainly don’t want multiple snapshots here.
dalto was right though, -d\ '${pkg.nevra}' or even just pkg.name would get you enough to at least provide something, but this actions seems extremely more limited than the python alternative that dnf has already had…
Yep, i gave up and went back to dnf4. That extra speed offered by dnf5 isn’t really that important to me since i only update my system once or twice per month.
i’ve tested with the ${pkg.xxxx}parameters… none of them work… but ${pid} works for example… so looks like somethings broken with the pkg.xxx arguments
modified the action config to include a description
# Get snapshot description
pre_transaction::::/usr/bin/sh -c echo\ "tmp.cmd=$(ps\ -o\ command\ --no-headers\ -p\ '${pid}')"
# Creates pre snapshot before the transaction and stores the snapshot number in the "tmp.snapper_pre_number" variable.
pre_transaction::::/usr/bin/sh -c echo\ "tmp.snapper_pre_number=$(snapper\ create\ -t\ pre\ -p\ -d\ '${tmp.cmd}')"
# If the variable "tmp.snapper_pre_number" exists, it creates post snapshot after the transaction and removes the variable "tmp.snapper_pre_number".
post_transaction::::/usr/bin/sh -c [\ -n\ "${tmp.snapper_pre_number}"\ ]\ &&\ snapper\ create\ -t\ post\ --pre-number\ "${tmp.snapper_pre_number}"\ -d\ "${tmp.cmd}"\ ;\ echo\ tmp.snapper_pre_number\ ;\ echo\ tmp.cmd
updated this to include a cleanup algorithm due to a suggestion on the github issue
# /etc/dnf/libdnf5-plugins/actions.d/snapper.actions
# Get snapshot description
pre_transaction::::/usr/bin/sh -c echo\ "tmp.cmd=$(ps\ -o\ command\ --no-headers\ -p\ '${pid}')"
# Creates pre snapshot before the transaction and stores the snapshot number in the "tmp.snapper_pre_number" variable.
pre_transaction::::/usr/bin/sh -c echo\ "tmp.snapper_pre_number=$(snapper\ create\ -c\ number\ -t\ pre\ -p\ -d\ '${tmp.cmd}')"
# If the variable "tmp.snapper_pre_number" exists, it creates post snapshot after the transaction and removes the variable "tmp.snapper_pre_number".
post_transaction::::/usr/bin/sh -c [\ -n\ "${tmp.snapper_pre_number}"\ ]\ &&\ snapper\ create\ -c\ number\ -t\ post\ --pre-number\ "${tmp.snapper_pre_number}"\ -d\ "${tmp.cmd}"\ ;\ echo\ tmp.snapper_pre_number\ ;\ echo\ tmp.cmd