You are not logged in.

#1 2016-12-07 02:42:03

cubethethird
Member
Registered: 2016-01-25
Posts: 61
Website

Questions about pacman hooks

While the existing documentation on pacman/alpm-hooks is fairly detailed, there are some points that appear to be vague, or left out. In no particular order, these are my questions about them:

  • can the Exec command determine which Target triggered the hook?
    I've seen a reference suggesting %f and %p for files and packages, though I don't know if this is documented or valid.

  • can the Exec command determine a Target package version?
    This may either be through a variable, or e.g. running pacman %p to get the version.

  • which directories can be used for hooks, and which are preferable to use?
    The wiki references both /usr/share/libalpm/hooks/ and /etc/pacman.d/hooks, the latter defaulted by pacman.conf

  • does the HookDir option in pacman.conf need to exist only when adding additional hook directories?
    The wiki is not clear on this, however my current config file has no reference to hooks.

As always, any answers are most appreciated.

Offline

#2 2016-12-07 04:17:57

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,384
Website

Re: Questions about pacman hooks

man alpm-hooks

Offline

#3 2016-12-07 04:30:20

cubethethird
Member
Registered: 2016-01-25
Posts: 61
Website

Re: Questions about pacman hooks

The man page does not answer these questions, which is why I asked them here.

Offline

#4 2016-12-07 04:53:13

Allan
Pacman
From: Brisbane, AU
Registered: 2007-06-09
Posts: 11,384
Website

Re: Questions about pacman hooks

cubethethird wrote:

[*]can the Exec command determine which Target triggered the hook?
I've seen a reference suggesting %f and %p for files and packages, though I don't know if this is documented or valid.[/*]

man alpm-hooks.  Look at NeedsTarget

cubethethird wrote:

[*]can the Exec command determine a Target package version?
This may either be through a variable, or e.g. running pacman %p to get the version.[/*]

No version information passed to the hook.  You can use pacman -Qq in your hook

cubethethird wrote:

[*]which directories can be used for hooks, and which are preferable to use?
The wiki references both /usr/share/libalpm/hooks/ and /etc/pacman.d/hooks, the latter defaulted by pacman.conf[/*]

See HookDir in "man pacman.conf".  /usr/share/ is for system managed hooks.  /etc/ for user overrides.

cubethethird wrote:

[*]does the HookDir option in pacman.conf need to exist only when adding additional hook directories?
The wiki is not clear on this, however my current config file has no reference to hooks.[/*]

See HookDir in "man pacman.conf".

Offline

#5 2016-12-07 05:14:51

cubethethird
Member
Registered: 2016-01-25
Posts: 61
Website

Re: Questions about pacman hooks

Ah thank you. I misunderstood the purpose of NeedsTarget. I take it that would be used combined with read in order to obtain the target?
I'd also assume then that should a package add a hook as part of its installation, it would be added to /usr/share/libalpm/hooks/.

Offline

#6 2016-12-07 05:20:18

eschwartz
Fellow
Registered: 2014-08-08
Posts: 4,097

Re: Questions about pacman hooks

Yes and yes. Look at the existing hooks in /usr/share/libalpm/{hooks,scripts} to see how others have handled it. e.g. gtk-update-icon-cache


Managing AUR repos The Right Way -- aurpublish (now a standalone tool)

Offline

Board footer

Powered by FluxBB