This is my proposal/design document for adding hooks to pacman. This is based off of Allan's proposal.
The following is a list of terminology used in this document.
- A trigger is a file where hooks are configured.
- A hook is a description of what should be executed whenever a hook type is called.
- Hook Type
- A hook type is an action that different hooks can subscribe to.
The goal of adding hooks to pacman is to allow users and programs to do certain tasks automatically. For example a user could automatically rebuild a package when ever another package is upgraded. Or a program could keep track of all installed/upgraded packages.
Trigger files are similar to Systemd's service files. They are stored in
/etc/pacman.d/hooks/triggers and use the same
.ini-style format. By default all triggers are disabled. In order to enable them they should be symlinked to
[trigger] section is used for describing the trigger itself. It includes two simple fields, name and description.
- The name of the trigger. Used for starting/stopping and enabling/disabling the trigger.
- The description of the trigger's functionality. Used to inform the user.
[hook] section allows programs to subscribe to different hook types. There can be multiple hook sections in each trigger file and each type of hook can be repeated more than once.
- The type of hook to listen to. Whenever this hook is called the command specified by
Execwill be ran.
- The path to the program to execute. Information about the hook can be passed through arguments in the format
xis the name of the information to pass.
Hooks should be provided for every (or almost every) option that pacman provides to the end user. Such as install, sync, remove, etc. When a hook is called the
Exec command is ran with the following variables replaced.
- The hook type. Such as install, sync, remove, etc.
- The name of packages passed to pacman.
- The flags passed to pacman.