[pacman-dev] [PATCH 0/2][WIP][RFC] hooks

Andrew Gregory andrew.gregory.8 at gmail.com
Thu Apr 10 19:59:51 EDT 2014


This is a lazy conversion of a work-in-progress hook implementation from my
pacutils library [1] (hence all the pu_* prefixes).  I have left out several
previously outlined features that I do not see as essential to an initial
implementation and can be easily added later if they are actually needed:
 * mid-transaction hooks (PreInstall, PostRemove, etc..)
 * passing triggering packages/files to the hook
 * system vs user hook directories with overriding (use backup=() instead)
 * specifying hook order

Some included features not previously discussed that I know of:
 * pre-transaction hooks can cancel the transaction
 * multiple triggers per-hook

Major TODO's:
 * documentation
 * error handling
 * use _alpm_run_chroot or similar to run the hook instead of system()

I have chosen to implement hooks entirely in the front-end as the only
alternatives I came up with were having alpm do the file parsing itself or
having pacman repeatedly reset the list of hooks as packages are added/removed.

Because this is a rather minimal implementation, my primary concern at this
point is making sure that no essential features are missing and that I don't
commit us to anything that would make implementing the remaining features more
difficult later.

Some example hooks:

 # basic hook
 [Trigger]
 Operation = Install
 Object = File
 Target = usr/bin/foo # note no / prefix

 [Action]
 When = PostTransaction
 Exec = /usr/bin/echo "I'm in a hook"

 # don't uninstall linux* packages
 [Trigger]
 Operation = Remove
 Object = Package
 Target = linux*

 [Action]
 When = PreTransaction
 Exec = /usr/bin/false

Previous discussion:
https://mailman.archlinux.org/pipermail/pacman-dev/2013-July/017508.html

Wiki:
https://wiki.archlinux.org/index.php/User:Allan/Pacman_Hooks

[1] https://github.com/andrewgregory/pacutils

Andrew Gregory (2):
  add TRANS_COMMIT_{START,END} events
  add basic hook support

 lib/libalpm/alpm.h     |   5 +-
 lib/libalpm/sync.c     |   6 ++
 lib/libalpm/trans.c    |   7 +++
 src/pacman/Makefile.am |   1 +
 src/pacman/callback.c  |  42 +++++++++++++
 src/pacman/hook.c      | 156 +++++++++++++++++++++++++++++++++++++++++++++++++
 src/pacman/hook.h      |  52 +++++++++++++++++
 7 files changed, 268 insertions(+), 1 deletion(-)
 create mode 100644 src/pacman/hook.c
 create mode 100644 src/pacman/hook.h

-- 
1.9.1



More information about the pacman-dev mailing list