User:Dunsmoreb/Pacman Hooks

From ArchWiki
Jump to: navigation, search

This is my proposal/design document for adding hooks to pacman. This is based off of Allan's proposal.

Terminology

The following is a list of terminology used in this document.

Trigger
A trigger is a file where hooks are configured.
Hook
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.

Goal

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

Trigger files are similar to Systemd's service files. They are stored in /usr/lib/pacman/hooks/triggers or /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 /etc/pacman.d/hooks/enabled-triggers.

[Trigger] Section

The [trigger] section is used for describing the trigger itself. It includes two simple fields, name and description.

Name
The name of the trigger. Used for starting/stopping and enabling/disabling the trigger.
Description
The description of the trigger's functionality. Used to inform the user.

[Hook] Section

The [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.

Hook
The type of hook to listen to. Whenever this hook is called the command specified by Exec will be ran.
Exec
The path to the program to execute. Information about the hook can be passed through arguments in the format %x where x is the name of the information to pass.

Hooks

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.

%t
The hook type. Such as install, sync, remove, etc.
%p
The name of packages passed to pacman.
%f
The flags passed to pacman.