From Fedora Project Wiki

Trigger Scripts

Triggers are rpm scriptlets that are created by one package but will be invoked when other packages are added or removed from the system. They can have unwanted side effects if not done properly and should be a last resort of the packager. That said, there are certain times when using them is the only option for fixing a problem.

This page attempts to record and document some common packaging triggers that have been proven to work without ill effect for some time.


bash-completion is an optional package which aids bash in knowing about commandline options to various programs. This allows bash to tab-complete commandline parameters. The bash-completion package allows other packages to drop short scripts into /etc/bash_completion.d that extend the functionality to other programs.

Rather than require each package supplying a bash_completion script to either Require bash_completion or own the /etc/bash_completion.d directory, a trigger script can be used to add the functionality if bash_completion is installed::

%triggerin -- bash-completion
ln -sf %{_datadir}/%{name}/%{name}-bashrc %{_sysconfdir}/bash_completion.d/%{name}

%triggerun -- bash-completion
[ $2 -gt 0 ]  || rm -f %{_sysconfdir}/bash_completion.d/%{name}

[ $1 = 0 ]  && rm -f %{_sysconfdir}/bash_completion.d/%{name}

In this setup, the package installs the bash_completion script in its own data directory (%{_datadir}/%{name}) If bash_completion is installed, the script gets symlinked into the bash_completion.d directory. If bash_completion is uninstalled, the link gets removed.