Difference between revisions of "User:Allan/Pacman Hooks - Version 1"

From ArchWiki
Jump to: navigation, search
(Example Config File)
(Proposed Directory Layout)
Line 29: Line 29:
(Dan: why bother with 'hooks.d/' and not just 'hooks/'?)
(Dan: why bother with 'hooks.d/' and not just 'hooks/'?)

Revision as of 22:48, 1 February 2009

The Idea

Short Version: Pacman should have hooks to perform common tasks.

Long Version: Many packages have install files that perform a common task; e.g. adding/removing info files the info directory file, installing/uninstalling gconf schemas, updating the font/desktop/icon cache. It would be good if pacman was extendible through a hooks mechanism so that these could be handled automatically.


A hook would need

  • Information on when the hooks should be run (see "Types of Hooks" below)
  • A list of files or globs that trigger the running of the hook, alternative a package name that trigger the hook
  • The actual hook script

Types of Hook

Hooks need to be able to cover a variety of tasks. The following types of hooks are a minimum necessary:

  • Hooks run once per transaction (e.g. updating font cache). These would be run whenever a transaction touches a trigger file (both install and uninstall).
  • Hooks that run for every matching file (e.g. updating the info directory). Separate versions would be needed for install and removal of the files.
  • Hooks that run for every matching package. As with files a there would be separate versions would be needed for install and removal of the files.

Proposed Directory Layout


(Dan: why bother with 'hooks.d/' and not just 'hooks/'?)

(Allan: can't really comment given I actually have no idea what the .d is for with folders in /etc)

Example Config File

This is presented for comments. Many improvements are likely...

Files = /usr/share/info/*
Run = Install

Files = /usr/share/info/*
Run = PreRemove

Files = /usr/share/fonts/TTF/*
Run = Transaction
Package = kernel26
Run = PostInstall

Allan: We should allow for the possibility of multiple files lines.

Options that will be needed to cover the general range of tasks to be performed by hooks (may need to be more general...):

  • Install - run on installation of a matching file
  • PreRemove - run prior to removal of a matching file
  • PostRemove - run after to removal of a matching file
  • Transaction - run at end of transaction involving at least one matching file

We should probably lean on the side of generality here and add options to cover all functions in the install files. Who knows what uses people could find for this...

Dan: so to make it clear: The first three hooks run on a per-package basis, and the Transaction hook would only run once for our entire pacman operation, correct?

Allan: The frist three run on a per matching file basis but otherwise correct. I'm not sure if the by-file hooks should run after each package or at the end of the transaction.

Hook Script Notes

Hooks that are run once per transaction do not need to know what file triggered them (Dan: do we want to rule out the possibility of providing this information?) but hooks that are run once per file will need to be passed the file name.

Allan: By the nature of the per-transaction hooks, they should not need file names. Otherwise they should be per-file hooks. This would also mean parsing and passing a list.