|
| 1 | +.Dd December 22, 2025 |
| 2 | +.Dt XBPS.HOOK 5 |
| 3 | +.Os |
| 4 | +.Sh NAME |
| 5 | +.Nm xbps.hook |
| 6 | +.Nd XBPS hook configuration |
| 7 | +.Sh SYNOPSIS |
| 8 | +.Bl -item -compact |
| 9 | +.It |
| 10 | +/etc/xbps.d/hooks/*.hook |
| 11 | +.It |
| 12 | +/usr/share/xbps.d/hooks/*.hook |
| 13 | +.El |
| 14 | +.Sh DESCRIPTION |
| 15 | +The |
| 16 | +.Nm |
| 17 | +files are |
| 18 | +.So .ini Sc Ns -style |
| 19 | +configuration files to define hooks that execute commands at certain points of |
| 20 | +the xbps transactions |
| 21 | +.Po |
| 22 | +package updates, |
| 23 | +installs, |
| 24 | +and removals . |
| 25 | +.Pc |
| 26 | +.Pp |
| 27 | +Comments can be put anywhere in the file |
| 28 | +and using hashmarks |
| 29 | +.Pq Sq # , |
| 30 | +or |
| 31 | +semi-colons |
| 32 | +.Pq Sq \&; , |
| 33 | +and are continue to the end of the line. |
| 34 | +.Sh [HOOK] SECTION OPTIONS |
| 35 | +.Bl -tag -width -x |
| 36 | +.It Sy Name= |
| 37 | +Set the hook name used used for logging. |
| 38 | +.It Sy Exec= Ar command Op Ar args ... |
| 39 | +The command executed by the hook. |
| 40 | +The value is split into words, |
| 41 | +and passed to |
| 42 | +.Xr execv 3 , |
| 43 | +spaces and tabs can be escaped using a |
| 44 | +backslash |
| 45 | +.Pq Sq \e . |
| 46 | +.It Ic When Ns = Ar option ... |
| 47 | +Defines when the hook is executed. |
| 48 | +The following values are supported |
| 49 | +and multiple values can be set by |
| 50 | +separating them with a space or defining |
| 51 | +the |
| 52 | +.Sy When |
| 53 | +option multiple times. |
| 54 | +Valid options are: |
| 55 | +.Bl -tag -width -x |
| 56 | +.It Ic PreTransaction |
| 57 | +Before all packages are installed, |
| 58 | +updated, |
| 59 | +or removed. |
| 60 | +.It Ic PostTransaction |
| 61 | +After all package are installed, |
| 62 | +updated, |
| 63 | +or removed. |
| 64 | +.El |
| 65 | +.El |
| 66 | +.Sh [MATCH] SECTION OPTIONS |
| 67 | +The |
| 68 | +.Sy Match |
| 69 | +section can be defined multiple times. |
| 70 | +.Bl -tag -width -x |
| 71 | +.It Ic Action Ns = Ar option ... |
| 72 | +One or more actions to match the target |
| 73 | +.Po |
| 74 | +.Ic Path |
| 75 | +or |
| 76 | +.Ic Package |
| 77 | +.Pc |
| 78 | + against. |
| 79 | +Valid options are: |
| 80 | +.Bl -tag -width -x |
| 81 | +.It Ic Install |
| 82 | +If the file or package is being installed. |
| 83 | +.It Ic Remove |
| 84 | +If the file or package is being removed. |
| 85 | +.It Ic Update |
| 86 | +If the file or package is being updated. |
| 87 | +.It Ic Configure |
| 88 | +If the package is being updated. |
| 89 | +.El |
| 90 | +.It Ic Path Ns = Oo Ar path ... | Ar pattern ... Oc |
| 91 | +Match |
| 92 | +.Ar file |
| 93 | +or |
| 94 | +.Ar pattern . |
| 95 | +The value will be split into multiple words. |
| 96 | +For further details, |
| 97 | +see |
| 98 | +.Sx WORD SPLITTING . |
| 99 | +against files in the transaction. |
| 100 | +.It Ic Package Ns = Oo Ar pkgname ... | Ar pkgpattern ... Oc |
| 101 | +Match |
| 102 | +.Ar pkgname |
| 103 | +or |
| 104 | +.Ar pkgpattern |
| 105 | +against packages in the transaction. |
| 106 | +The value will be split into multiple words. |
| 107 | +For further details, |
| 108 | +see |
| 109 | +.Sx WORD SPLITTING . |
| 110 | +.El |
| 111 | +.Sh WORD SPLITTING |
| 112 | +Options which support multiple free text values will be split into separate |
| 113 | +words. |
| 114 | +The word boundaries are spaces |
| 115 | +.Pq Sq \~ |
| 116 | +and tabs |
| 117 | +.Pq Sq \et . |
| 118 | +.Pp |
| 119 | +If a word contains a literal space |
| 120 | +.Pq Sq \~ |
| 121 | +or tab |
| 122 | +.Pq Sq \et , |
| 123 | +use a backslash |
| 124 | +.Pq Sq \e |
| 125 | +to escape the character. |
| 126 | +.Sh EXAMPLES |
| 127 | +The following example restarts the |
| 128 | +.Ic sshd |
| 129 | +service after the |
| 130 | +.Ic ssh |
| 131 | +package was updated. |
| 132 | +.Bd -literal -offset indent |
| 133 | +[Hook] |
| 134 | +Name = Restart sshd. |
| 135 | +When = PostTransaction |
| 136 | +Exec = sv restart /var/service/sshd |
| 137 | + |
| 138 | +[Match] |
| 139 | +Action = Update |
| 140 | +Package = ssh |
| 141 | +.Ed |
| 142 | +.Pp |
| 143 | +This example hook will sign the |
| 144 | +.Pa systemd-bootx64.efi |
| 145 | +file whenever it is being updated or installed. |
| 146 | +.Bd -literal -offset indent |
| 147 | +[Hook] |
| 148 | +Name = Sign the bootloader file. |
| 149 | +When = PostTransaction |
| 150 | +Exec = sbsign --key /etc/kernel/secure-boot.key.pem \e |
| 151 | + --cert /etc/kernel/secure-boot.cert.pem \e |
| 152 | + --output /usr/lib/systemd/boot/efi/systemd-bootx64.efi.signed \e |
| 153 | + /usr/lib/systemd/boot/efi/systemd-bootx64.efi |
| 154 | + |
| 155 | +[Match] |
| 156 | +Action = Install Update |
| 157 | +Path = /usr/lib/systemd/boot/efi/systemd-bootx64.efi |
| 158 | +.Ed |
0 commit comments