From Mandriva Community Wiki

(Redirected from Rpm filetriggers)
Jump to: navigation, search



Things changed since Mandriva 2011.0, as we switched to rpm5 rather than rpm. The file triggers now handled differently in rpm5. More details to come.



Filetriggers allow to run some scripts when some file has been added or removed.

The typical use cases are:

  • updating /etc/ when some libraries have been added/removed in /usr/lib or /lib
  • running update-menus to update menus of non-XDG compliant desktops when some *.desktop have been added/removed in /usr/share/applications


Add the following to your macros to enable filetriggers:

%_filetriggers_dir /var/lib/rpm/filetriggers

Then install your watchers:

% cat /var/lib/rpm/filetriggers/ldconfig.filter
% cat /var/lib/rpm/filetriggers/ldconfig.script
ldconfig -X
% cat /var/lib/rpm/filetriggers/gtk-icon-cache-hicolor.filter
% cat /var/lib/rpm/filetriggers/gtk-icon-cache-hicolor.script
/usr/bin/gtk-update-icon-cache --force --quiet /usr/share/icons/hicolor

Note the "." in the regexp which matches both "+" and "-", and so matches both install and uninstall.


A simple patch on rpm. Description:


When a package is successfully installed (or removed), rpm will append the installed (resp. removed) files to /var/lib/rpm/files-awaiting-filetriggers.

The format is quite simple: <installed-or-removed> <filename>

where <installed-or-removed> ::= "+" | "-"

For example, after installing hexedit:



This function is called before running %posttrans scriptlets. It can be disabled using --noscripts or --notriggers (no special command line option introduced for now).

For each %_filetriggers_dir/*.filter, the regexp (POSIX Extended Regular Expression) on the first line is applied on files-awaiting-filetriggers. If some files match, the corresponding %_filetriggers_dir/<name>.script is called, with matching lines passed in stdin.

Note that this is done in parallel, so multiple <name>.script may be running at the same time.

When it's done, /var/lib/rpm/files-awaiting-filetriggers is removed.


Characteristics of this implementation :

  • if the transaction is aborted, the next successful transaction will run on every succesful package installation/removal. This is due to files-awaiting-filetriggers which allows to keep state of what is done or not.
  • it needs only a light patch in rpm
  • files-awaiting-filetriggers may be getting big (eg: 5MB on a big transaction of 1000 packages)
  • not fully integrated in rpm:
    • --nofiletriggers and RPMTRANS_FLAG_NOFILETRIGGERS should be added
    • a new command rpm --run-filetriggers would be useful to force running filetriggers, and only them.


Filetriggers has been merged with some improvements and additional in rpm5 [HEAD]:

  • Use miRE in stead of regex(3)
  • Pass filename as argument to filetrigger script so they can replace filetriggers requiring file arguments. (room for improval)
    • info-install proposal:
[root@localhost filetriggers]# cat install_info.filter
[root@localhost filetriggers]# cat install_info.script
/sbin/install-info $1 --dir=/usr/share/info/dir

[root@localhost filetriggers]# cat remove_install_info.filter
[root@localhost filetriggers]# cat remove_install_info.script
if [ ! -f $1 ]; then
        echo /sbin/install-info $1 --dir=/usr/share/info/dir --remove


  • emacs elisp
  • gtk-update-icon-cache
  • install-info [Proposed]
  • ldconfig [Support in place]
  • python .pyo
  • scrollkeeper-update
  • tetex
  • update-desktop-database
  • update-icon-caches
  • update-menus [Support in place]
  • update-mime-database
  • etckeeper [To be packaged]

External links

Some links about filetriggers:

Personal tools