Blame doc/post-transaction-actions.rst

Packit Service 27f74b
..
Packit Service 27f74b
  Copyright (C) 2019 Red Hat, Inc.
Packit Service 27f74b
Packit Service 27f74b
  This copyrighted material is made available to anyone wishing to use,
Packit Service 27f74b
  modify, copy, or redistribute it subject to the terms and conditions of
Packit Service 27f74b
  the GNU General Public License v.2, or (at your option) any later version.
Packit Service 27f74b
  This program is distributed in the hope that it will be useful, but WITHOUT
Packit Service 27f74b
  ANY WARRANTY expressed or implied, including the implied warranties of
Packit Service 27f74b
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
Packit Service 27f74b
  Public License for more details.  You should have received a copy of the
Packit Service 27f74b
  GNU General Public License along with this program; if not, write to the
Packit Service 27f74b
  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
Packit Service 27f74b
  02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
Packit Service 27f74b
  source code or documentation are not subject to the GNU General Public
Packit Service 27f74b
  License and may only be used or replicated with the express permission of
Packit Service 27f74b
  Red Hat, Inc.
Packit Service 27f74b
Packit Service 27f74b
===================================
Packit Service 27f74b
DNF post-transaction-actions Plugin
Packit Service 27f74b
===================================
Packit Service 27f74b
Packit Service 27f74b
-----------
Packit Service 27f74b
Description
Packit Service 27f74b
-----------
Packit Service 27f74b
Packit Service 27f74b
The plugin allows to define actions to be executed upon completing an RPM transaction. Each action
Packit Service 27f74b
may define a (glob-like) filtering rule on the package NEVRA or package files, as well as whether
Packit Service 27f74b
the package was installed or removed. Actions are defined in action files.
Packit Service 27f74b
Packit Service 27f74b
-------------
Packit Service 27f74b
Configuration
Packit Service 27f74b
-------------
Packit Service 27f74b
Packit Service 27f74b
The plugin configuration is in ``/etc/dnf/plugins/post-transaction-actions.conf``. All configuration
Packit Service 27f74b
options are in the ``[main]`` section.
Packit Service 27f74b
Packit Service 27f74b
``enabled``
Packit Service 27f74b
    Whether the plugin is enabled. Default value is ``True``.
Packit Service 27f74b
Packit Service 27f74b
``actiondir``
Packit Service 27f74b
    Path to the directory with action files. Action files must have the ".action" extension.
Packit Service 27f74b
    Default value is "/etc/dnf/plugins/post-transaction-actions.d/".
Packit Service 27f74b
Packit Service 27f74b
------------------
Packit Service 27f74b
Action file format
Packit Service 27f74b
------------------
Packit Service 27f74b
Packit Service 27f74b
Empty lines and lines that start with a '#' character are ignored.
Packit Service 27f74b
Each non-comment line defines an action and consists of three items separated by colons:
Packit Service 27f74b
``package_filter:transaction_state:command``.
Packit Service 27f74b
Packit Service 27f74b
``package_filter``
Packit Service 27f74b
   A (glob-like) filtering rule aplied on the package NEVRA (also in the shortened forms) or
Packit Service 27f74b
   package files.
Packit Service 27f74b
Packit Service 27f74b
``transaction_state``
Packit Service 27f74b
   Filters packages according to their state in the transaction.
Packit Service 27f74b
Packit Service 27f74b
   * ``in`` - packages that appeared on the system (downgrade, install, obsolete, reinstall, upgrade)
Packit Service 27f74b
   * ``out`` - packages that disappeared from the system (downgraded, obsoleted, remove, upgraded)
Packit Service 27f74b
   * ``any`` - all packages
Packit Service 27f74b
Packit Service 27f74b
``command``
Packit Service 27f74b
   Any shell command.
Packit Service 27f74b
   The following variables in the command will be substituted:
Packit Service 27f74b
      * ``${name}``, ``$name`` - package name
Packit Service 27f74b
      * ``${arch}``, ``$arch`` - package arch
Packit Service 27f74b
      * ``${ver}``, ``$ver`` - package version
Packit Service 27f74b
      * ``${rel}``, ``$rel`` - package release
Packit Service 27f74b
      * ``${epoch}``, ``$epoch`` - package epoch
Packit Service 27f74b
      * ``${repoid}``, ``$repoid`` - package repository id
Packit Service 27f74b
      * ``${state}``, ``$state`` - the change of package state in the transaction:
Packit Service 27f74b
         "downgrade", "downgraded", "install", "obsolete", "obsoleted", "reinstall",
Packit Service 27f74b
         "reinstalled", "remove", "upgrade", "upgraded"
Packit Service 27f74b
Packit Service 27f74b
   The shell command will be evaluated for each package that matched the ``package_filter`` and
Packit Service 27f74b
   the ``transaction_state``. However, after variable substitution, any duplicate commands will be
Packit Service 27f74b
   removed and each command will only be executed once per transaction. The order of execution
Packit Service 27f74b
   of the commands may differ from the order of packages in the transaction.
Packit Service 27f74b
Packit Service 27f74b
An example action file:
Packit Service 27f74b
^^^^^^^^^^^^^^^^^^^^^^^
Packit Service 27f74b
.. code-block:: none
Packit Service 27f74b
Packit Service 27f74b
   # log all packages (state, nevra, repo) in transaction into a file.
Packit Service 27f74b
   *:any:echo '${state} ${name}-${epoch}:${ver}-${rel}.${arch} repo ${repoid}' >>/tmp/post-trans-actions-trans.log
Packit Service 27f74b
Packit Service 27f74b
   # The same shell command (after variables substitution) is executed only once per transaction.
Packit Service 27f74b
   *:any:echo '${repoid}' >>/tmp/post-trans-actions-repos
Packit Service 27f74b
   # will write each repo only once to /tmp/post-trans-actions-repos, even if multiple packages from
Packit Service 27f74b
   # the same repo were matched