Blame doc/post-transaction-actions.rst

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