[pacman-dev] Hooks for pacman

Aaron Griffin aaronmgriffin at gmail.com
Thu Jan 22 11:18:59 EST 2009

On Thu, Jan 22, 2009 at 9:15 AM, Allan McRae <allan at archlinux.org> wrote:
> Hi all,
> A new feature I am ever so slightly obsessed about at the moment is the
> possibility of having hooks in pacman for doing common tasks in install
> files.  e.g.  adding info pages to directory, updating font/icon/.desktop
> cache, gconf stuff...
> So, how would this be implemented?   Here is my outline:
> Two types of hooks would be needed for both install and remove.  One type
> that is run for every matching file (e.g. info install) and one type that is
> run once per transaction (e.g. font cache update).  These could be stored in
> /etc/pacman.d/hooks/ with an index of hooks in /etc/pacman.d/hooks.conf.
>  The .conf file could look something like:
> [add]
> PerFile = infopage    /usr/share/info/
> PerTrans = fontcache    /usr/share/fonts/
> [remove]
> ...
> That needs improvement, but that covers the information that needs presented
> - whether the hook is run per file or per transaction, the name of the hook
> and the directory whose files set off this hook.  Maybe the conditions that
> set the hook off should be in the actual hook file.
> I guess the actual hook would look look just like:
> hook()
> {
> do stuff here...
> }
> I figure we must already generate a list of all the files being
> added/removed during conflict checks, so we would "just" need to scan that
> list for what hooks need to be run and actually run them.
> Anyway, I thought I would post this idea here so I could get more feedback
> on the implementation and maybe convince someone to code it...

This is much better than the ideas Dan and I fleshed out last time we
talked about this. One or two nitpicks, though:

a) [add] and [remove] seem to simple. How about [AddHooks] and [RemoveHooks]?
b) It'd be nice to use fnmatch patterns (globs) for the file paths.
c) Instead of a function, it makes more sense to just make a script
that takes the files as args, and only run it if it is executable
(assume -x is disable)
Other than that, I really like the PerFile and PerTrans distinction.

Where will these hooks reside? /etc/pacman.d/hooks/ ?
When modifying the config parsing, can you ensure 'Include' works
here? That would allow us to ship some stock hooks for info files and
the like, and users would simply include them.

More information about the pacman-dev mailing list