Difference between revisions of "Rpm filetriggers"

From Rosalab Wiki
Jump to: navigation, search
(General info about file triggers)
 
m (typo)
Line 3: Line 3:
 
* {{file|foo.script}} which specifies commands to run on those file(s) that match expression from {{file|foo.filter}}
 
* {{file|foo.script}} which specifies commands to run on those file(s) that match expression from {{file|foo.filter}}
  
Such file are normally installed into the {{file|/var/lib/rpm/filetriggers}} directory.
+
Such files are normally installed into the {{file|/var/lib/rpm/filetriggers}} directory.
  
 
Typical use cases of file triggers include:
 
Typical use cases of file triggers include:

Revision as of 15:04, 5 May 2012

The concept of Filetriggers allows to run arbitrary scripts if specific files have been added or removed to the system when rpm packages are (un)installed. Each foo trigger consists of two files:

  • foo.filter which contains a regular expression on which file(s) the trigger should be activated
  • foo.script which specifies commands to run on those file(s) that match expression from foo.filter

Such files are normally installed into the /var/lib/rpm/filetriggers directory.

Typical use cases of file triggers include:

  • updating /etc/ld.so.cache when some libraries have been added/removed in /usr/lib or /lib
  • updating icon caches when icons have been added or removed somewhere below /usr/share/icons

Usage

If you want your package to add some file triggers to the system, you should install filter and script files into the %_filetriggers_dir folder.

The filter file should contain a usual regular expression to match the file name. To distinguish file additions from file removal, an additional character is added to the beginning of every file name before passing it to regex: '+' means that the file is being added, '-' means that the file is being removed. So the trigger with \+/etc/gconf/schemas/[^/]*\.schemas$ expression will be activated only if some '.schema' file is added to the /etc/gconf/schemas/ subdirectories. To match both addition and removal of files, you can just use '.' (dot).

A common example is a trigger which launches ldconfig when a libtrary is added to /lib, /lib64, /usr/lib or /usr/lib64 folder:

$ cat /var/lib/rpm/filetriggers/ldconfig.filter
^.((/lib|/usr/lib)(64)?/[^/]*\.so\.|/etc/ld.so.conf.d/[^/]*\.conf)

$ cat /var/lib/rpm/filetriggers/ldconfig.script
#!/bin/sh
ldconfig -X