[pacman-dev] [PATCH 0/4] hooks

Andrew Gregory andrew.gregory.8 at gmail.com
Sat Jul 4 09:59:23 UTC 2015


= TODO =
 * documentation
 * run PreTransaction hooks *after* conflict checks
 * hook/trigger validation
 * masking hooks with an empty file or symlink to /dev/null
 * tests

= Hook Directories =

ALPM handles keep a list of hook directories to scan.  Initially, this list is
populated with a single directory: /usr/share/alpm/hooks/.  This directory is
intended for packages to be able to place hooks in a front-end agnostic manner.
Front-ends may specify any number of additional directories to search, with
later directories overriding earlier ones.  Front-ends can disable hooks
altogether by setting an empty list.

= Parsing Hooks =

Configured directories are scanned for files matching '*.hook'.  Hook files
must be in pacman-style INI format with the following available options:

 [Trigger] (multiple Trigger sections allowed)
 Operation = Sync|Remove (Required)
 Type = File|Package (Required)
 Target = <Path|PkgName> (Required, multiple allowed)
 
 [Action] (only one Action section allowed)
 When = PreTransaction|PostTransaction (Required)
 Exec = <Command> (Required)
 Depends = <PkgName> (Optional)
 AbortOnFail (Optional, PreTransaction only)

Unlike pacman.conf multiple values are *not* allowed on a single line.

Exec is currently limited to the path of the executable to run, arguments are
not allowed.  This is intended to be a temporary limitation until I decide the
best way to go about splitting the arguments, which depends in part on whether
we want to try to provide hooks with the packages/files that triggered them.

Targets are matched the same as IgnorePkg in pacman.conf, meaning multiple
targets can be specified and targets can be negated with a leading '!'.

If multiple Trigger sections are specified the hook will run if any of them
match the transaction.

= Running Hooks =

Hooks are not cached after running.  Directories are rescanned and hooks
reloaded each time.  This is to make sure that any hooks added/removed during
a transaction are appropriately accounted for.

Hooks are run exactly the same as install scriptlets (chroot, output passed to
the front-end, etc.).

They do *not* have access to which package/file triggered the hook.

For the time being, run order is officially undefined.

apg

Andrew Gregory (4):
  move strtim to util-common
  move ini parser into common
  wip add hooks
  add example hooks

 hooks/checkboot.hook     |  17 +++
 hooks/checkmount         |  13 ++
 hooks/checkmount.conf    |   1 +
 hooks/checkmount.hook    |  17 +++
 hooks/sync.hook          |  16 +++
 lib/libalpm/Makefile.am  |   2 +
 lib/libalpm/alpm.c       |   1 +
 lib/libalpm/alpm.h       |  10 ++
 lib/libalpm/handle.c     |  59 ++++++++
 lib/libalpm/handle.h     |   1 +
 lib/libalpm/hook.c       | 354 +++++++++++++++++++++++++++++++++++++++++++++++
 lib/libalpm/hook.h       |  34 +++++
 lib/libalpm/trans.c      |   6 +
 src/common/ini.c         | 116 ++++++++++++++++
 src/common/ini.h         |  30 ++++
 src/common/util-common.c |  39 ++++++
 src/common/util-common.h |   2 +
 src/pacman/ini.c         | 117 +---------------
 src/pacman/ini.h         |  31 +----
 src/pacman/util.c        |  39 ------
 src/pacman/util.h        |   1 -
 src/util/pactree.c       |  36 -----
 22 files changed, 720 insertions(+), 222 deletions(-)
 create mode 100644 hooks/checkboot.hook
 create mode 100644 hooks/checkmount
 create mode 100644 hooks/checkmount.conf
 create mode 100644 hooks/checkmount.hook
 create mode 100644 hooks/sync.hook
 create mode 100644 lib/libalpm/hook.c
 create mode 100644 lib/libalpm/hook.h
 create mode 100644 src/common/ini.c
 create mode 100644 src/common/ini.h
 mode change 100644 => 120000 src/pacman/ini.c
 mode change 100644 => 120000 src/pacman/ini.h

-- 
2.4.5


More information about the pacman-dev mailing list