XBPS.HOOK(5) File Formats Manual XBPS.HOOK(5)

xbps.hookXBPS hook configuration

The xbps.hook files are ‘.ini’-style configuration files to define hooks that execute commands at certain points of the xbps transactions (package updates, installs, and removals.)

Comments can be put anywhere in the file and using hashmarks (‘#’), or semi-colons (‘;’), and are continued to the end of the line.

The Hook section is required and defines when the hook is executed and the command that is being executed as part of the hook.

name
Set the hook name used for logging.
option ...
Defines when the hook is executed. The following values are supported and multiple values can be set by separating them with a space or defining the When option multiple times. Valid options are:
Before all packages are installed, updated, or removed.
After all packages are installed, updated, or removed.
command [args ...]
Command that is executed. The command and args are split into words according to WORD SPLITTING.

A hook is executed if it's Match section matches the current transaction.

pkgname | pkgpattern
Matches if pkgname or packages matching pkgpattern are installed, updated, removed, reinstalled, or configured in the transaction.
pkgname | pkgpattern
Matches if pkgname or packages matching pkgpattern are installed in the transaction.
pkgname | pkgpattern
Matches if pkgname or packages matching pkgpattern are updated in the transaction.
pkgname | pkgpattern
Matches if pkgname or packages matching pkgpattern are removed in the transaction.
pkgname | pkgpattern
Matches if pkgname or packages matching pkgpattern are reinstalled in the transaction.
pkgname | pkgpattern
Matches if pkgname or packages matching pkgpattern are configured in the transaction.
path | pattern
Matches if path or paths matching pattern are created, modified, or deleted.
path | pattern
Matches if path or paths matching pattern are created in the transaction.
path | pattern
Matches if path or paths matching pattern are modified in the transaction.
path | pattern
Matches if path or paths matching pattern are deleted in the transaction.

Options which support multiple free text values will be split into separate words. The word boundaries are spaces (‘ ’) and tabs (‘\t’).

If a word contains a literal space (‘ ’) or tab (‘\t’), use a backslash (‘\’) to escape the character.

The following example restarts the sshd service after the ssh package was updated.

[Hook]
Name = Restart sshd.
When = PostTransaction
Exec = sv restart /var/service/sshd

[Match]
PackageUpdate = ssh

This example hook will sign the systemd-bootx64.efi file whenever it is updated or installed.

[Hook]
Name = Sign the bootloader file.
When = PostTransaction
Exec = sbsign --key /etc/kernel/secure-boot.key.pem \
	--cert /etc/kernel/secure-boot.cert.pem \
	--output /usr/lib/systemd/boot/efi/systemd-bootx64.efi.signed \
	/usr/lib/systemd/boot/efi/systemd-bootx64.efi

[Match]
PathModified = /usr/lib/systemd/boot/efi/systemd-bootx64.efi
December 22, 2025 Void Linux