Raphaël Hertzog: Trying to make dpkg triggers more useful and less painful
Lately I have been working on the triggers feature of dpkg. I would like to share my plan and what I have done so far. I ll first explain what triggers are, the current problems, and the work I did to try to improve the situation.
Introduction
Dpkg triggers are a neat feature of dpkg that package can use to send/receive notifications to/from other installed packages. Those notifications take the form a simple string.
This feature is heavily used to track changes of packaged files in a list of predefined directories, and to update other files based on this. For instance, man-db is watching the directories containing manual pages so that it can update its cache (in /var/cache/man/). install-info is updating the index of info pages when there have been changes in /usr/share/info. gnome-menus is updating its own copy of the menu hierarchy (with entries from /etc/gnome/menus.blacklist blacklisted) every time that a .desktop file is installed/updated/removed.
From a user s perspective
You see triggers in action very often during upgrades (in fact too often as we ll see it later):
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 ... Processing triggers for desktop-file-utils ... Processing triggers for man-db ... Processing triggers for hicolor-icon-theme ... Processing triggers for python-support ... Processing triggers for gnome-menus ... Setting up zim (0.52-1) ... Processing triggers for python-support ... Processing triggers for menu ...As you guessed it, those Processing triggers lines correspond to the packages which received (one or more) trigger notifications and which are doing the corresponding task. By default the triggers are processed at the end of the
dpkg --unpack invocation which is often too soon because APT will often call dpkg --unpack repeatedly during important upgrades. There are some options to ask APT to use dpkg s --no-triggers option in order to defer the trigger processing at the end of the APT run. You can put this in /etc/apt/apt.conf.d/triggers:
// Trigger deferred DPkg::NoTriggers "true"; PackageManager::Configure "smart"; DPkg::ConfigurePending "true"; DPkg::TriggersPending "true";I have now asked APT maintainers to use those options by default, I filed bug #626599 to track this. At the same time I fixed bug #526774 reported by APT maintainers. This bug forced them to put a work-around in APT which resulted in running triggers sooner than expected. (And while writing this article I filed bug #628564 and #628574 because it was clearly not normal that the menu triggers was executed twice for the installation of a single package)
From a packager s perspective
The implementation of triggers has several consequences on the status that packages can have.
Let s assume that the package A installs a file in a directory that is watched by package B (and that B is currently in the installed state). When A is unpacked, dpkg adds B to its Triggers-Awaited field and lists the activated trigger in B s Triggers-Pending field. Package A is in unpacked state, but B has been changed to triggers-pending .
When A is configured, instead of going to the installed state, it will go to the triggers-awaited state. In that state the package is assumed to NOT fulfill dependencies. However, B which is still in triggers-pending state does fulfill dependencies.
A and B will switch to installed at the same time when the trigger has been processed.
The fact that the triggers-awaited status does not fulfill dependencies means that some common triggers like man-db have to be processed regularly just to be able to ensure dependencies are satisfied before running the postinst of other installed packages.
But a package which ships a manual page can certainly be considered as configured when its postinst has been run even if man-db has not yet updated its cache to know about the new/updated manual page.
When you activate a trigger with the dpkg-trigger command you have an option --no-await to avoid awaiting the trigger processing (and thus to go directly to installed state after the postinst has been run). But with file triggers or activate trigger directives, you do not have this option.
My proposal to improve the situation
This is the problem that I tried to solve during my last vacation. But before changing the inner working of triggers, I wrote a non-regression test suite for that feature (commit here) so I could hack with some confidence that I did not break everything.
The result has been presented on the debian-dpkg mailling list: see the discussion here. I added new directives that can be used in triggers files that work exactly like the current triggers except that they do not put triggering packages in trigger-awaited status.
I believe the code to be mostly ready, but in its current form the patch brings zero benefits until all packages have been converted to use the trigger variants that do not require awaiting trigger processing (and the change requires a pre-dependency on dpkg to ensure we have the required dpkg that understands the new kind of trigger directives).
Remaining question
Thus I wonder if I should not change the default semantic of triggers. The packages which really provide crucial functionality to awaiting packages through triggers would then have to be updated to switch to the new directives.
If you re a packager using triggers, you can thus help me by answering this question: do you know some triggers where it s important that the awaiting packages are not considered as configured before the trigger processing? In most of the cases I checked, it s important for the triggered package rather than for the triggering package.
In truth, a package in triggers-awaited status is usually in a good enough shape to be able to satisfy dependencies (i.e. requirements that other packages can have), but it would still be worth to record the fact that it s not entirely configured yet because it might be true from the user s point of view: for example if the menu trigger has not yet been processed, the software might not yet be visible in the application menu.
If you appreciate this kind of groundwork that benefits to the whole Debian ecosystem, please consider supporting my work. Click here and give it a look, there are many ways to contribute and to make a difference for me.
3 comments Liked this article? Click here. My blog is Flattr-enabled.
I m proud to be able to announce a new stable release of

To make things louder, I will go to Wacken from 02.08.2011 until 07.08.2011, wonder to see some Debian people there :)
It's 2011. Computers are here for a couple of decades now, but they still don't help me with the most simple problems. I've been asked once again about a recommendation for a GroupWare and still don't know what to say. This are the simple requirements:
The lab features four web servers that will be merged into a single
web service with the help of keepalived. Since, keepalived now
supports full IPv6 support, we will also use IPv6 in our lab.
Here is the
This summer, I ll be taking a bit of time off, moving back to San Francisco and starting 


(this is a copy of an mail sent to ruby-core@ and ruby-talk@)
Since the beginning of 2011, the Debian Ruby team has been working on several big changes. Those changes all are available in Debian unstable, some of them are also available in Debian testing, and they should all be available in the next Debian and Ubuntu releases.
I think that it addresses most of the reasonable concerns about Ruby in Debian.
Using alternatives to switch between Ruby implementations
The alternatives system is now used to manage the ruby symlink and the other related symlinks, making it easy to switch between Ruby implementations (only Ruby 1.8 and 1.9.X at the moment) (see
I just sent the text below to the
Well hello there.
A couple of days ago my
Or how to get rid of Evolution without removing your whole system
There is a complain I have heard several times from people after they
installed Debian: I use Icedove/Thunderbird so I do not need Evolution: I
tried to remove it but this would remove my whole system, that sucks! Explanation
The reason behind this situation is that GNOME is installed by a
meta-package, which is a dummy package that depends on each component of the
official GNOME desktop, including Evolution. So it got installed as a
dependency of that dummy package. This means that you, or rather, the Debian
installer, never asked explicitly to install either Evolution or any other
specific software: it came automatically.
Now, you want to remove Evolution: very well, but this implies removing the
meta-package, as you are removing one of its dependencies. But if you are
removing this meta-package, there is no reason to keep all this software you
did not asked for, so, as they got installed automatically, they are now
removed automatically as well
The solution
So, do you still want to remove Evolution but keep the remaining of your
GNOME desktop? Of course you will not keep GNOME , because GNOME includes
Evolution, so strictly speaking GNOME without Evolution is not GNOME
any more.
Well, there is a solution: marking all the dependencies of the meta-package
as manually installed, that is, faking that you installed them explicitly
Aptitude is able to do that with its powerful search functions:
long time no post about my RC bug fixing activities. & indeed, I haven't
been very active during the last weeks. here's a quick update; it includes
two NMUs done for the perl 5.12 transition, the rest is just
"normal" maintainance work (interesting to see how much stuff can
break behind our backs ...).
Here is the simplified IDL for these parts:
Particularly around local government, but also some not-for-profits and universities, I m trying to persuade people to stop using huge Blind Carbon Copy (BCC) lists that they keep in their address book and switch over to using mailing list manager software.
This year Debconf is a bit