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

Allan McRae allan at archlinux.org
Tue Apr 22 01:25:07 EDT 2014


On 11/04/14 09:59, Andrew Gregory wrote:
> 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.


I have finally had a decent look at your patches.  As I said in an
earlier email, hooks needs to be handled by the backend.  Despite what I
said in the previous email, that does not necessarily mean moving the
ini parsing code to the backend, although common hook parsing code there
would be useful for frontend developers.

Allowing pretransaction hooks to stop the transaction seems fine to me.
 Although in your example, it is clear that you are relying on return
value.  Given post-package hooks could return non-zero, could we do this
another way for consistency.

BTW, the proposal on the wiki also allowed multiple targets to trigger a
hook.

> 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
> 

This is yet another format!   It would make me joyously happy (I'm bad
at superlatives) to have the format of the hooks completely defined on
the wiki page before we go forward.  We (you...) can still implement
post transaction hooks first as these are my main concern (updating
desktop and font cache), but we need the full spec fleshed out so that
we do not end in a mess.

> 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
> 





More information about the pacman-dev mailing list