[pacman-dev] Hooks for pacman
allan at archlinux.org
Thu Jan 22 19:29:52 EST 2009
Aaron Griffin wrote:
> 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:
>> PerFile = infopage /usr/share/info/
>> PerTrans = fontcache /usr/share/fonts/
>> 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:
>> 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.
All good suggestions. I went for the function idea so I could reused
code for running install scripts. I have never look at that code so I
don't know whether that would be a good or bad idea.
Thinking about this some more, per transaction hooks really only need
ran per transaction... I.e. there is probably no need for the
distinction within [AddHooks] of PerFile and PerTrans. All the examples
I used for run once hook will look the same for both add and remove.
Instead, we could have [AddHooks], [RemoveHooks] and [TransHooks].
> 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.
Can you provide an example of what you think the config would look
like. I have a fair guess at what you mean but clarification would be
I will make a wiki page with config mock-ups and a few example hooks
given this is probably the most important part to get right of the whole
More information about the pacman-dev