[pacman-dev] Potential bug in alpm-hooks; fix provided
git at stefan-klinger.de
Mon Jan 2 16:10:28 UTC 2017
I'm providing a fix  for the following issue.
I've noticed that exactly one `Exec` directive is allowed in
alpm-hooks(5). This is not explicitly stated in the manual (the word
"required" does not usually imply "non-repeatable", as seems to be
intended by the manual), nor does it rise an error. Instead, multiple
occurrences are silently ignored.
# When installed as a pacman hook , this will call the
# `my-update-pacman-mirrorlist` script every time the file
# `/etc/pacman.d/mirrorlist` should be updated.
Operation = Upgrade
Operation = Install
Type = File
Target = etc/pacman.d/mirrorlist
When = PostTransaction
Exec = /usr/bin/my-update-pacman-mirrorlist
Exec = /usr/bin/rm -f /etc/pacman.d/mirrorlist.pacnew
Only the last `Exec` is used. I think it is semantically correct
since the syntax looks like an assignment that overwrites the previous
one. But it is inconsistent with the use of `Operation` in the
`Trigger` section. I would expect the commands to be evaluated in
order, or to see an error due to reusing `Exec`.
I think raising an error would be best, otherwise pacman would have to
provide means to decide how to handle individually failing commands, a
situation that is more flexibly handled by an external script, which
should be called instead of using multiple `Exec`s.
I have implemented this in  and added a test. If you like that, I
would update the documentation, and also look for other values that
are silently overwritten when parsing a hook. Also, I'd like to make
`Operation` accept things like
Operation = Upgrade Install
and in future versions deprecate the current use of multiple
assignments which I consider rather unfortunate.
Send plain text messages only, not exceeding 32kB. /\/
More information about the pacman-dev