ALPM-HOOKS(5) | Pacman Manual | ALPM-HOOKS(5) |
NAME
alpm-hooks - alpm hook file format
SYNOPSIS
[Trigger] (Required, Repeatable) Operation = Install|Upgrade|Remove (Required, Repeatable) Type = Path|Package (Required) Target = <Path|PkgName> (Required, Repeatable) [Action] (Required) Description = ... (Optional) When = PreTransaction|PostTransaction (Required) Exec = <Command> (Required) Depends = <PkgName> (Optional) AbortOnFail (Optional, PreTransaction only) NeedsTargets (Optional)
DESCRIPTION
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 [Action] section describing the action to be run and one or more [Trigger] section describing which transactions it should be run for.
Hooks are read from files located in the system hook directory /usr/share/libalpm/hooks, and additional custom directories specified in pacman.conf(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.
TRIGGERS
Hooks must contain at least one [Trigger] section that determines which transactions will cause the hook to run. If multiple trigger sections are defined the hook will run if the transaction matches any of the triggers.
Operation = Install|Upgrade|Remove
Type = Path|Package
Target = <path|package>
ACTIONS
Description = ...
Exec = <command>
When = PreTransaction|PostTransaction
Depends = <package>
AbortOnFail
NeedsTargets
OVERRIDING HOOKS
Hooks may be overridden by placing a file with the same name in a higher priority hook directory. Hooks may be disabled by overriding them with a symlink to /dev/null.
EXAMPLES
# Force disks to sync to reduce the risk of data corruption [Trigger] Operation = Install Operation = Upgrade Operation = Remove Type = Package Target = * [Action] Depends = coreutils When = PostTransaction Exec = /usr/bin/sync
CAVEATS
There are situations when path triggers may act in unexpected ways. Hooks are triggered using the file list of the installed, upgraded, or removed package. When installing or upgrading a file that is extracted with a .pacnew extension, the original file name is used in triggering the hook. When removing a package, all files owned by that package can trigger a hook whether or not they were actually present on the file system before package removal.
PostTransaction hooks will not run if the transaction fails to complete for any reason.
See the pacman website at https://archlinux.org/pacman/ for current information on pacman and its related tools.
BUGS
Bugs? You must be kidding; there are no bugs in this software. But if we happen to be wrong, please report them to the issue tracker at https://gitlab.archlinux.org/pacman/pacman/-/issues with specific information such as your command-line, the nature of the bug, and even the package database if it helps.
AUTHORS
Current maintainers:
Past major contributors:
For additional contributors, use git shortlog -s on the pacman.git repository.
2024-09-09 | Pacman 7.0.0 |