[pacman-dev] [PATCH] Add events ALPM_EVENT_HOOK_{START,DONE}

Allan McRae allan at archlinux.org
Sun Dec 13 12:38:05 UTC 2015


On 07/12/15 03:35, Olivier Brunel wrote:
> Add events to let frontends know when hooks are being processed (and when it's
> done), as that might be useful to update the UI.
> 
> It can also be useful to know when ALPM_EVENT_SCRIPTLET_INFO might be happening
> in that regard (There's no specific event for running scriptlets, but they do
> happen at specific times after/before ALPM_EVENT_PACKAGE_OPERATION_{START,DONE}).
> 
> Signed-off-by: Olivier Brunel <jjk at jjacky.com>
> ---
> On a not-quite-related topic, I wonder whether a flag should be added to skip
> hook processing, much like ALPM_TRANS_FLAG_NOSCRIPTLET ?
> I guess it might not be necessary, since frontends can simply set the hookdirs
> to NULL to disable them. Thoughts?
> 
> I also wondered about the same in the POV of pacman, i.e. an option --nohooks,
> because it seems currently one can only add hookdirs, and therefore only replace
> the pacman default (/etc/pacman.d/hooks) (I assume setting it to /dev/null might
> work to disable things?) but not the system/ALPM one (/usr/share/libalpm/hooks)?
> 
> Also unless I missed it, the documentation doesn't mention that last directory
> anywhere?
> 

Agreed - we need:
 - document --hookdir in pacman.8.  It should be mentioned that this is
what HookDir is overriding in pacman-conf.8 too.
 - add a --nohooks option


And now, onto patch review.

I think _alpm_hook_run needs to exit after reading the hooks directories
if there is no hooks. Only if there are hooks should
ALPM_EVENT_HOOK_START be called.  It would be even better if it was
called if there were hooks for pre or post transaction.

That would require _alpm_hook_run to first loop over the hooks doing:
  if(hook && hook->when == when && _alpm_hook_triggered(handle, hook)) {
then if any hooks matched, do ALPM_EVENT_HOOK_START and run the hooks.
I think that check is fast enough that we do no need a callback until we
know some hooks will be run.  Andrew: would you agree?

Here goes my imaginary output when coreutils triggers an info-page
update (before and after) and firefox requires a desktop file database
after installation:

(2/2) checking keys in keyring        [######################] 100%
(2/2) checking package integrity      [######################] 100%
(2/2) loading package files           [######################] 100%
(2/2) checking for file conflicts     [######################] 100%
:: Running pre-transaction hooks
(1/1) info-pages-remove
:: Installing
(1/2) installing coreutils            [######################] 100%
(2/2) installing firefox              [######################] 100%
:: Running post-transaction hooks
(1/2) info-pages-install
(2/2) desktop-database

What is printed is the hook name (I would like to enable this to be
configured in the hook later).

Allan


More information about the pacman-dev mailing list