You are not logged in.

#1 2020-06-26 21:17:10

regid
Member
Registered: 2016-06-06
Posts: 177

Comments in pacman (alpm) hook files

https://www.archlinux.org/pacman/alpm-hooks.5.html doesn't mention comments explicitly. Yet, https://www.archlinux.org/pacman/alpm-h … #_examples does show a comment. I think documentation is important. What is the status of comments in hook files? Is it documented? Should it get improved?


pantum-p1000-p2000-p3000-m5100-m5200-ppd-driver (AUR): PPDs, drivers, for Pantum P1000, P2000, P3000, M5100, M5200 printers.
powerofforreboot.efi (AUR): Utilities to be used from within a UEFI boot manager or shell.

Offline

#2 2020-06-27 06:05:00

apg
Developer
Registered: 2012-11-10
Posts: 197

Re: Comments in pacman (alpm) hook files

Patches welcome.

Offline

#3 2020-06-27 10:45:46

regid
Member
Registered: 2016-06-06
Posts: 177

Re: Comments in pacman (alpm) hook files

apg wrote:

Patches welcome.

Not the sort of work one is hopping for. The patch is only for the documentation. I have not examined the source to verify its correctness. It is based on the current https://www.archlinux.org/pacman/alpm-h … #_examples. And a single hook file I have, where I inserted some lines of comments. My file seems to work, though I have only tested it by a single digit couple of times. Hopefully, the real commenting capability of the syntax is much better. Such as comments marked by the hash, #, character at any position of a line. Either after white characters, or after tokens to keywords.
I do not have time, and knowledge, for better work.
On the other hand, having the current ability, if it exists, documented will hopefully makes it somewhat harder to change the source in a way that will break what is there.
The patch is for /usr/share/man/man5/alpm-hooks.5.gz.

--- alpm-hooks.5.orig   2020-06-27 10:04:11.483431584 +0000
+++ alpm-hooks.5        2020-06-27 10:13:44.200935851 +0000
@@ -40,6 +40,7 @@
 [Action] (Required)
 Description = \&.\&.\&. (Optional)
 When = PreTransaction|PostTransaction (Required)
+# A comment (Optional)
 Exec = <Command> (Required)
 Depends = <PkgName> (Optional)
 AbortOnFail (Optional, PreTransaction only)
@@ -49,6 +50,8 @@
 .sp
 libalpm provides the ability to specify hooks to run before or after transactions based on the packages and/or files being modified\&. Hooks consist of a single \fI[Action]\fR section describing the action to be run and one or more \fI[Trigger]\fR section describing which transactions it should be run for\&.
 .sp
+Comments are optional. They can appear at any line of the file. They should be marked by the hash, #, character at the very first character of a line. The whole line will be regarded as a comment.
+.sp
 Hooks are read from files located in the system hook directory /usr/share/libalpm/hooks, and additional custom directories specified in \fBpacman.conf\fR(5) (the default is /etc/pacman\&.d/hooks)\&. The file names are required to have the suffix "\&.hook"\&. Hooks are run in alphabetical order of their file name, where the ordering ignores the suffix\&.
 .SH "TRIGGERS"
 .sp

pantum-p1000-p2000-p3000-m5100-m5200-ppd-driver (AUR): PPDs, drivers, for Pantum P1000, P2000, P3000, M5100, M5200 printers.
powerofforreboot.efi (AUR): Utilities to be used from within a UEFI boot manager or shell.

Offline

#4 2020-06-28 03:41:09

eschwartz
Trusted User/Bug Wrangler
Registered: 2014-08-08
Posts: 3,622

Re: Comments in pacman (alpm) hook files

Hooks technically follow the same ini-like file format and in fact use the same parser as pacman.conf (with "[section]" headers and "key" or "key = value" settings), which does specify in its manpage:

Comments are only supported by beginning a line with the hash (#) symbol. Comments cannot begin in the middle of a line.

... so this is canonically true of hooks as well, even if it fails to be documented there.


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

Offline

Board footer

Powered by FluxBB