Difference between revisions of "User:Allan/Pacman Hooks"

From ArchWiki
Jump to: navigation, search
(Additional Configuration)
(4 intermediate revisions by the same user not shown)
Line 8: Line 8:
 
Hook files are placed in /usr/lib/pacman/hooks or /etc/pacman.d/hooks. Those in /etc override those in /usr/lib.  An empty file in /etc disables the hook in /usr/lib.
 
Hook files are placed in /usr/lib/pacman/hooks or /etc/pacman.d/hooks. Those in /etc override those in /usr/lib.  An empty file in /etc disables the hook in /usr/lib.
  
All hooks filenames must end in .hook (to avoid issues with e.g. .pacsaves)
+
('''TODO''': Do hook files need a standard suffix?)
  
 
=Hook Format=
 
=Hook Format=
Line 39: Line 39:
  
 
===[Target] Section===
 
===[Target] Section===
File: File or list of files that trigger a hook.  Can be increase in specificity by using the prefixes Installed/Upgraded/Removed
+
File: File or list of files that trigger a hook.  Can be increase in specificity by using the suffixes Install/Upgrade/Removal.
  
 
or
 
or
  
Package: Package or list of packages that trigger the hook.  Installed/Upgraded/Removed prefixes
+
Package: Package or list of packages that trigger the hook.  Install/Upgrade/Removal suffixes
  
('''TODO''': other general targets - e.g. for all transactions, all installs?)
+
('''TODO''': is this enough targets?)
  
 
Exec: the command to be run during the upgrade.  Can use the following replacements (will be quoted):
 
Exec: the command to be run during the upgrade.  Can use the following replacements (will be quoted):
  %f: the triggering file - if more than one, the command is looped
+
  %f: the triggering file - if more than one triggers, the command is looped
 
  %F: the list of triggering files
 
  %F: the list of triggering files
  %p: the triggering package
+
  %p: the triggering package - if more than one triggers, the command is looped
 
  %P: the list of triggering packages
 
  %P: the list of triggering packages
  
Line 56: Line 56:
  
 
During ./configure the system hooks directory is specified with --with-hooksdir defaulting to EPREFIX/lib when unspecified.  The override directory is not configurable beyond using --sysconfdir.
 
During ./configure the system hooks directory is specified with --with-hooksdir defaulting to EPREFIX/lib when unspecified.  The override directory is not configurable beyond using --sysconfdir.
 +
 +
 +
=Decisions=
 +
* Should non-transaction File hooks be run after the file is installed or at the end of each package
 +
* How do we handing installation of new hooks during transaction.
 +
  
 
=Old Versions for Reference=
 
=Old Versions for Reference=

Revision as of 14:58, 5 July 2013

NOTE

This page is locked. All discussion to the pacman-dev mailing list. The discussion page will be ignored...

The Dream

We will one day live in a world where we no longer have to suffer the tedium of repeated tasks in pacman install files. The future will arrive bearing the stuff of legends... Things that have been talked about in quiet whispers for decades. Pacman hooks!

Hooks

Hook files are placed in /usr/lib/pacman/hooks or /etc/pacman.d/hooks. Those in /etc override those in /usr/lib. An empty file in /etc disables the hook in /usr/lib.

(TODO: Do hook files need a standard suffix?)

Hook Format

Example:

[Hook]
Description = Add info files to the info directory
Requires = install-info
Type = PostTransaction

[Target]
File = /usr/share/info/*
Exec = install-info %f usr/share/info/dir &>/dev/null

Detailed options

[Hook] section

Description: (Optional) Brief description of the hook

Requires: (Optional) Required software for hook to run

Type: PreRemove|PostRemove|PreInstall|PostInstall|Transaction

  • Before the installation/upgrade of the package (PreInstall)
  • After the installation/upgrade of the package (PostInstall)
  • Before the removal of the package (PreRemove)
  • After the removal of the package (PostRemove)
  • At the end of the transaction (PostTransaction)

(TODO: sort out definite list - leaning on side of generality)

Before/After: (Optional) Control the ordering of the hook

[Target] Section

File: File or list of files that trigger a hook. Can be increase in specificity by using the suffixes Install/Upgrade/Removal.

or

Package: Package or list of packages that trigger the hook. Install/Upgrade/Removal suffixes

(TODO: is this enough targets?)

Exec: the command to be run during the upgrade. Can use the following replacements (will be quoted):

%f: the triggering file - if more than one triggers, the command is looped
%F: the list of triggering files
%p: the triggering package - if more than one triggers, the command is looped
%P: the list of triggering packages

Additional Configuration

During ./configure the system hooks directory is specified with --with-hooksdir defaulting to EPREFIX/lib when unspecified. The override directory is not configurable beyond using --sysconfdir.


Decisions

  • Should non-transaction File hooks be run after the file is installed or at the end of each package
  • How do we handing installation of new hooks during transaction.


Old Versions for Reference

User:Allan/Pacman_Hooks_-_Version_1

User:Allan/Pacman_Hooks_-_Version_2