How to See Processing Triggers on a Per-Package Basis


As I've understood, the usual "Processing triggers for < packagename >" does some package- and system-specific tasks such as add items to a launch menu or update a configuration file. Is there an actual way to see what exactly is being done or altered during this step? Where can one find the exact behaviour of the step?

Best Answer

There is, but it requires digging through some bash scripts for the packages being triggered.

  • Suppose the dpkg output looks like:

    Preparing to replace zim 0.52-1 (using .../archives/zim_0.52-1_all.deb) ...
    Unpacking replacement zim ...
    Processing triggers for shared-mime-info ...
    Processing triggers for menu ...
  • Internally, what dpkg does is call the postinst script for each of these packages with the triggered command-line option, and zero or more trigger options.

  • So, you simply open /var/lib/dpkg/info/PACKAGE.postinst (it's a bash script), and simply look for what happens when $1 is triggered

Example: man-db triggers

One of the most common "Processing triggers" you'll see is for man-db, whenever the package being installed has a man page.

If you open /var/lib/dpkg/info/man-db.postinst, you'll find this section:

if [ "$1" = triggered ]; then
    # We don't print a status message here, as dpkg already said
    # "Processing triggers for man-db ...".
    run_mandb -pq
    exit 0

So you can see that Processing triggers for man-db ... simply results in the run_mandb function (also found in the postinst script) being run with the -pq option.

Helpful Resources:

  1. Trying to make dpkg triggers more useful and less painful
  2. dpkg triggers, the lost how-to document
Related Question