4 Status: recommendation, stable
9 A dpkg trigger is a facility that allows events caused by one package
10 but of interest to another package to be recorded and aggregated, and
11 processed later by the interested package. This feature simplifies
12 various registration and system-update tasks and reduces duplication
15 (NB: Triggers are intended for events that occur during package
16 installation, not events that occur in general operation.)
22 Each trigger is named, and at any time zero or more packages may be
25 We currently envisage three kinds of triggers:
26 * Explicit triggers. These can be activated by any program
27 by running dpkg-trigger (at any time, but ideally from a maintainer
29 * File triggers. These are activated automatically by dpkg
30 when a matching file is installed, upgraded or removed as part
31 of a package. They may also be explicitly activated by running
33 * Future kinds of special triggers, which are activated by magic code
34 in dpkg itself. Currently none are defined besides file triggers.
36 A trigger is always activated by a particular package.
38 Trigger names contain only printing 7-bit ASCII characters (no
39 whitespace). Each trigger kind has a distinct subset of the trigger
40 name space so that the kind can be determined from the name. After we
41 run out of straightforward syntaxes, we will use <kind>:<details>.
43 When a trigger is activated, it becomes pending for every package
44 which is interested in the trigger at that time. Each package has a
45 list of zero or more pending triggers. Repeated activation of the
46 same trigger has no additional effect. Note that in general a trigger
47 will not be processed immediately when it is activated; processing is
48 deferred until it is convenient (as described below).
50 At a trigger activation, the interested packages(s) are added to the
51 triggering package's list of triggers-awaited packages (unless the
52 trigger has been configured to not require it); the triggering
53 package is said to await the trigger processing.
55 A package which has pending triggers, or which awaits triggers, is not
56 considered properly installed. There are two new dpkg status values,
57 ‘triggers-pending’ and ‘triggers-awaited’, which lie between
58 ‘config-failed’ and ‘installed’.
61 Details - Overview table
62 ------------------------
64 Status Pending Awaited Satisfies Remedy
65 triggers triggers Depends
67 unpacked never maybe No postinst configure
68 c.-failed never maybe No postinst configure (when requested)
69 t.-awaited yes always No postinst triggered + fix awaited pkg(s)
70 t.-awaited no always No fix awaited package(s)
71 t.-pending always never Yes postinst triggered
72 installed never never Yes n/a
74 Packages in t-awaited and t-pending demand satisfaction of their
75 dependencies just like packages in installed.
78 Details - triggering package
79 ----------------------------
81 When a package <T> activates a trigger in which a package <I> is
82 interested, <I> is added to the list of packages whose trigger
83 processing is awaited by <T>. Zero or more packages <I> may be added as a
84 result of any particular trigger activation, depending on how many
85 packages were interested. (If <T> chooses, explicit trigger activation
86 using dpkg-trigger of <I> by <T> need not make <T> become triggers-awaited
89 A package which awaits trigger processing but would otherwise be
90 ‘installed’ or ‘triggers-pending’ is considered to be in state
91 ‘triggers-awaited’. Packages in ‘triggers-awaited’ do not satisfy
94 Every triggered package <I> in <T>'s list of awaited packages either has a
95 nonempty list of pending triggers, or is in ‘config-failed’ or worse.
96 When <I> enters ‘installed’ (or ‘config-files’ or ‘not-installed’), the
97 entry in <T>'s list of awaited packages is removed so that <T> may, if it
98 no longer awaits any packages, become ‘installed’ or ‘triggers-pending’.
100 Packages in ‘config-files’ or ‘not-installed’ do not await triggers.
103 Details - triggered package
104 ---------------------------
106 When one of the triggers in which a package is interested is
107 activated, the triggered package has the trigger added to its list of
108 pending triggers. Packages with a nonempty list of pending triggers
109 which would otherwise be in state ‘installed’ are in state
110 ‘triggers-pending’ instead, so if the package was previously
111 ‘installed’ it becomes ‘triggers-pending’.
113 If a package has nonempty lists both of pending and awaited triggers,
114 then it is in ‘triggers-awaited’. Nevertheless efforts will still be
115 made to process its triggers so as to make the list of pending
118 To restore a package in state ‘triggers-pending’ to ‘installed’, or to
119 process pending triggers of a package with both pending and awaited
120 triggers, dpkg will run the postinst script as:
122 postinst triggered "<trigger-name> <trigger-name> ..."
124 by passing a space-separated list of <trigger-name>s as the second argument.
126 This will be attempted for each relevant package at the end of each
127 dpkg run; so, normally, in the same dpkg run as the event which made
128 the package go to ‘triggers-pending’. This leaves packages in
129 reasonable states by default.
131 If the “postinst triggered” run fails the package goes to
132 ‘config-failed’, so that the trigger processing will not be attempted
133 again until explicitly requested.
143 (automatic)│ ┌───────────────┐
148 ├──────<─────┘ │ ┌──────────────────────────────────┐
149 │ (user request) │ │ triggers-pending │
151 "configure" │ │ │ triggers-awaited w/ some pending │
152 │ │ └────────────┬─────────────────────┘
154 ├────────>───────┤ postinst │ │
155 │ error │ "triggered" │ │
159 │ └────────<─────────┤ │
163 ┌──────────────────────────────────────────────┴────┐
164 │ installed or triggers-awaited w/ none pending │
165 └───────────────────────────────────────────────────┘
167 Packages in ‘config-failed’ or worse are never considered to have
168 lists of pending triggers. A package whose postinst is being run
169 can however acquire pending triggers during that run (ie, a package
172 This means that if a triggering package <T> awaits trigger processing by
173 an interested package <I>, and <I> goes to ‘config-failed’ or worse (eg,
174 during unpack for upgrade), then when <I> is reconfigured (goes to
175 ‘installed’) or removed, <T> will no longer await processing by <I>, so
176 that <T> may automatically go from ‘triggers-awaited’ to ‘installed’.
178 Or to put it another way, triggered actions are considered irrelevant
179 if the interested package <I> is not configured. When <I>'s postinst is
180 called with ‘configure’, it must do whatever actions are necessary to
181 deal with any trigger activations which might have occurred while it
182 was not configured, just as if the package was being configured for
185 Trigger processing should be idempotent. The list of triggers being
186 processed is provided to the postinst only so that it can optimize
187 away redundant processing.
189 In that case, where an interested package has more than one trigger
190 and wants to process them differently, the list of triggers can be can
191 be examined in a shell script like this:
193 *" trigger-name-a "*) process-trigger-a ;;
195 Generally each trigger name should be tested for separately, as the
196 postinst will often be called for several triggers at once.
198 Note that if a package both activates triggers in other packages, and
199 is interested in triggers of its own, its postinst may run for trigger
200 processing before the postinst(s) of the package(s) it has triggered.
203 Timing guarantees, races, etc.
204 ------------------------------
206 Activating a trigger will not have any immediate effect, although
207 putative resulting status changes will show up in dpkg --status etc.
208 (Putative because the actual status changes may depend on the state of
209 trigger interests when dpkg processes the trigger activation into
210 the status database, rather than that when dpkg --status is run.)
212 A package is only guaranteed to become notified of a trigger
213 activation if it is continuously interested in the trigger, and never
214 in ‘config-failed’ or worse, during the period from when the trigger
215 is activated until dpkg runs the package postinst (either due to
216 --configure --pending, or at the end of the relevant run, as described
217 above). Subsequent to activation and before notification, the
218 interested package will not be considered in state ‘installed’, so
219 long as the package remains interested, and the triggering package
220 will not be considered ‘installed’.
222 If the package is not in state ‘installed’, ‘triggers-pending’ or
223 ‘triggers-awaited’ then pending triggers are not accumulated.
224 However, if such a package (between ‘half-installed’ and
225 ‘config-failed’ inclusive) declares some trigger interests then the
226 triggering packages *will* await their configuration (which implies
227 completion of any necessary trigger processing) or removal.
229 It is not defined in what order triggers will run. dpkg will make
230 some effort to minimize redundant work in the case where many packages
231 have postinst trigger processing activating another package's triggers
232 (for example, by processing triggers in fifo order during a single
233 dpkg run). Cycles in the triggering graph are prohibited and will
234 eventually, perhaps after some looping, be detected by dpkg and cause
235 trigger processing to fail; when this happens one of the packages
236 involved will be put in state ‘config-failed’ so that the trigger loop
237 will not be reattempted. See “Cycle detection” below.
243 Explicit triggers have names with the same syntax as package names,
244 *but* should *not* normally be named identically to a package.
246 When choosing an explicit trigger name it is usually good to include a
247 relevant package name or some other useful identifier to help make the
248 trigger name unique. On the other hand, explicit triggers should
249 generally not be renamed just because the interested or triggering
250 packages' names change.
252 Explicit trigger names form part of the interface between packages.
253 Therefore in case of wider use of any trigger the name and purpose
254 should be discussed in the usual way and documented in the appropriate
255 packaging guidelines (eg, in the distribution policy).
261 File triggers have names of the form
262 /path/to/directory/or/file
263 and are activated when the specified filesystem object, or any object
264 under the specified subdirectory, is created, updated or deleted by
265 dpkg during package unpack or removal. The pathname must be absolute.
267 File triggers should not generally be used without mutual consent.
268 The use of a file trigger, and the name of the trigger used, should be
269 stated in the distribution policy, so that a package which creates a
270 relevant file in a maintainer script can activate the trigger explicitly.
272 File triggers must definitely not be used as an escalation tool in
273 disagreements between different packages as to the desired contents of
274 the filesystem. Trigger activation due to a particular file should
275 not generally modify that file again.
277 Configuration files (whether dpkg-handled conffiles or not), or any
278 other files which are modified at times other than package management,
279 should not rely on file triggers detecting all modifications; dpkg
280 triggers are not a general mechanism for filesystem monitoring.
282 If there are or might be directory symlinks which result in packages
283 referring to files by different names, then to be sure of activation
284 all of the paths which might be included in packages should be listed.
285 The path specified by the interested package is matched against the
286 path included in the triggering package, not against the truename of
287 the file as installed. Only textually identical filenames (or
288 filenames where the interest is a directory prefix of the installed
289 file) are guaranteed to match.
291 A file trigger is guaranteed to be activated before the file in
292 question is modified by dpkg; on the other hand, a file trigger might
293 be activated even though no file was actually modified. Changes made
294 by dpkg to the link count of a file, or to solely the inode number
295 (ie, if dpkg atomically replaces it with another identical file), are
296 not guaranteed to cause trigger activation.
298 Because of the restriction on trigger names, it is not possible to
299 declare a file trigger for a directory whose name contains whitespace,
300 i18n characters, etc. Such a trigger should not be necessary.
303 Package declarations regarding triggers
304 ---------------------------------------
308 Support future extension of the trigger name syntax with additional
309 dpkg-generated triggers is as follows: a package which is interested
310 in any unsupported trigger kinds cannot be configured (since such a
311 package cannot be guaranteed to have these triggers properly activated
312 by dpkg). Therefore no package can be interested in any unsupported
313 trigger kinds and they can be freely activated (both by ‘activate’ and
314 by dpkg-trigger). dpkg-deb will be changed to warn about unrecognized
315 trigger names syntaxes and unrecognized trigger control directives.
318 New command line interfaces to dpkg tools
319 -----------------------------------------
323 Here is a summary of the behaviors:
325 Command line Trigproc Trigproc Configure
327 ----------------------+---------------+---------------+-----------------
328 --unpack no usually[1] none
329 --remove n/a usually[1] none
330 --install n/a usually[1] these
331 --configure -a any needed usually[1] any needed
332 --configure <some> if needed usually[1] must, or trigproc
333 --triggers-only -a any needed usually[1] none
334 --triggers-only <some> must usually not[1] none
336 [1] can be specified explicitly by --triggers or --no-triggers
341 A trigger may be activated explicitly with:
342 dpkg-trigger [--by-package <package>] <name-of-trigger>
343 dpkg-trigger --no-await <name-of-trigger>
345 There will be no output to stdout, and none to stderr unless
346 dpkg-trigger is unable to make a record of the trigger activation.
348 NB that in the case of a file trigger the name of the trigger is
349 needed, not the name of a file which would match the trigger.
355 These must be taught about the new ‘triggers-awaited’ and
356 ‘triggers-pending’ states. Packages in these states should be treated
357 roughly like those in ‘unpacked’: the remedy is to run dpkg
360 Normally apt and aptitude will not see packages in ‘triggers-pending’
361 since dpkg will generally attempt to run the triggers thus leaving the
362 package in ‘config-failed’ or ‘installed’.
364 Note that automatic package management tools which call dpkg (like apt
365 and aptitude) should not attempt to configure individual packages in
366 state ‘triggers-pending’ (or indeed ‘triggers-awaited’) with dpkg
367 --triggers-only <package>... or dpkg --no-triggers --configure <package>...,
368 or similar approaches. This might defeat dpkg's trigger cycle detection.
370 A package management tool which will run dpkg --configure --pending at
371 the end may use --no-triggers on its other dpkg runs. This would be
372 more efficient as it allows more aggressive deferral (and hence more
373 unification) of trigger processing.
379 Packages should be written so that they DO NOT BREAK just because
380 their pending triggers have not yet been run. It is allowed for the
381 functionality relating to the unprocessed trigger to fail (ie, the
382 package which is awaiting the trigger processing may be broken), but
383 the remainder of the interested package must work normally.
385 For example, a package which uses file triggers to register addons
386 must cope with (a) an addon being dropped into the filesystem but not
387 yet registered and (b) an addon being removed but not yet
388 deregistered. In both of these cases the package's main functionality
389 must continue to work normally; failure of the addon in question is
390 expected, warning messages are tolerable, but complete failure of the
391 whole package, or failures of other addons, are not acceptable.
393 dpkg cannot ensure that triggers are run in a timely enough manner for
394 pathological error behaviors to be tolerable.
397 Where a trigger script finds bad data provided by a triggering
398 package, it should generally report to stderr the problem with the bad
399 data and exit nonzero, leaving the interested package in config-failed
400 and the triggering package in triggers-awaited and thus signalling the
403 Alternatively, in some situations it may be more desirable to allow
404 the interested package to be configured even though it can only
405 provide partial service. In this case clear information will have to
406 be given in appropriate places about the missing functionality, and a
407 record should be made of the cause of the errors. This option is
408 recommended for situations where the coupling between the interested
409 and triggering package is particularly loose; an example of such a
410 loose coupling would be Python modules.
414 WORKED EXAMPLE - SCROLLKEEPER
415 =============================
417 Currently, every Gnome program which comes with some help installs the
418 help files in /usr/share/gnome/help and then in the postinst runs
419 scrollkeeper-update. scrollkeeper-update reads, parses and rewrites
420 some large xml files in /var/lib/scrollkeeper; currently this
421 occurs at every relevant package installation, upgrade or removal.
423 When triggers are available, this will work as follows:
425 * gnome-foobar will ship its «omf» file in /usr/share/omf as
426 normal, but will not contain any special machinery to invoke
429 * scrollkeeper will in its triggers control file say:
430 interest /usr/share/omf
431 and in its postinst say:
432 scrollkeeper-update-now -q
434 dpkg will arrange that this is run once at the end of each run
435 where any documentation was updated.
437 Note that it is not necessary to execute this only on particular
438 postinst "$1" values; however, at the time of writing, scrollkeeper
441 if [ "$1" = "configure" ]; then
442 printf "Rebuilding the database. This may take some time.\n"
443 scrollkeeper-rebuilddb -q
446 and to retain this behavior, something along the following lines
449 if [ "$1" = "configure" ]; then
450 printf "Rebuilding the database. This may take some time.\n"
451 scrollkeeper-rebuilddb -q
453 printf "Updating GNOME help database.\n"
454 scrollkeeper-update-now -q
457 * dh_scrollkeeper will only adjust the DTD declarations and no longer
458 edit maintainer scripts.
461 Full implementation of the transition plan defined below, for
462 scrollkeeper, goes like this:
464 1. Update scrollkeeper:
465 - Add a ‘triggers’ control archive file containing
466 interest /usr/share/omf
467 - Make the postinst modifications as described above.
468 - Rename scrollkeeper-update to scrollkeeper-update-now
469 - Provide a new wrapper script as scrollkeeper-update:
472 if type dpkg-trigger >/dev/null 2>&1 && \
473 dpkg-trigger /usr/share/omf; then
476 exec scrollkeeper-update-now "$@"
478 2. In gnome-policy chapter 2, “Use of scrollkeeper”,
479 - delete the requirement that the package must depend on
481 - delete the requirement that the package must invoke
482 scrollkeeper in the postinst and postrm
485 OMF files should be installed under /usr/share/omf in the
486 usual way. A dpkg trigger is used to arrange to update the
487 scrollkeeper documentation index automatically and no special
488 care need be taken in packages which supply OMFs.
490 If an OMF file is placed, modified or removed other than as
491 a file installed in the ordinary way by dpkg, the dpkg file
492 trigger «/usr/share/omf» should be activated; see the dpkg
493 triggers specification for details.
495 Existing packages which Depend on scrollkeeper (>= 3.8)
496 because of dh_scrollkeeper or explicit calls to
497 scrollkeeper-update should be modified not to Depend on
500 3. Update debhelper's dh_scrollkeeper not to edit maintainer
501 scripts. One of dh_scrollkeeper or lintian should be changed to
502 issue a warning for packages with scrollkeeper (>= 3.8) in the
503 Depends control file line.
505 4. Remove the spurious dependencies on scrollkeeper, at our leisure.
506 As a bonus, after this is complete it will be possible to remove
507 scrollkeeper while keeping all of the documentation-supplying
508 gnome packages installed.
510 5. If there are any packages which do by hand what dh_scrollkeeper
511 does, change them not to call scrollkeeper-update and drop
512 their dependency on scrollkeeper.
514 This is not 100% in keeping with the full transition plan defined
515 below: if a new gnome package is used with an old scrollkeeper, there
516 is some possibility that the help will not properly be available.
518 Unfortunately, dh_scrollkeeper doesn't generate the scrollkeeper
519 dependency in the control file, which makes it excessively hard to get
520 the dependency up to date. The bad consequences of the inaccurate
521 dependencies are less severe than the contortions which would be
522 required to deal with the problem.
532 The first time a trigger-supporting dpkg is run on any system, it will
533 activate all triggers in which anyone is interested, immediately.
535 These trigger activations will not be processed in the same dpkg run,
536 to avoid unexpectedly processing triggers while attempting an
537 unrelated operation. dpkg --configure --pending (and not other dpkg
538 operations) will run the triggers, and the dpkg postinst will warn the
539 user about the need to run it (if this deferred triggers condition
540 exists). (Any triggers activated or reactivated *after* this
541 mass-activation will be processed in the normal way.)
543 To use this correctly:
544 * Packages which are interested in triggers, or which want to
545 explicitly activate triggers, should Depend on the
546 triggers-supporting version of dpkg.
547 * Update instructions and tools should arrange to run
548 dpkg --configure --pending
549 after the install; this will process the pending triggers.
551 dpkg's prerm will check for attempts to downgrade while triggers are
552 pending and refuse. (Since the new dpkg would be installed but then
553 refuse to read the status file.) In case this is necessary a separate
554 tool will be provided which will:
555 * Put all packages with any pending triggers into state
556 ‘config-failed’ and remove the list of pending triggers.
557 * Remove the list of awaited triggers from every package. This
558 may cause packages to go from ‘triggers-awaited’ to ‘installed’
559 which is not 100% accurate but the best that can be done.
560 * Remove /var/lib/dpkg/triggers (to put the situation to that which
561 we would have seen if the trigger-supporting dpkg had never been
565 Higher-level programs
566 ---------------------
568 The new dpkg will declare versioned Conflicts against apt and aptitude
569 and other critical package management tools which will be broken by
570 the new Status field values. Therefore, the new higher-level tools
571 will have to be deployed first.
573 The new dpkg will declare versioned Breaks against any known
574 noncritical package management tools which will be broken by the new
578 Transition hints for existing packages
579 --------------------------------------
581 When a central (consumer) package defines a directory where other leaf
582 (producer) packages may place files and/or directories, and currently
583 the producer packages are required to run an «update-consumer» script
585 1. In the relevant policy, define a trigger name which is the name of
586 the directory where the individual files are placed by producer
588 2. Update the consumer package:
589 * Declare an interest in the trigger.
590 * Edit «update-consumer» so that if it is called without --real
591 it does the following:
592 if type dpkg-trigger >/dev/null 2>&1 && \
593 dpkg-trigger name-of-trigger; then
596 If this fails to cause «update-consumer» to exit, it should do
597 its normal update processing. Alternatively, if it is more
598 convenient, «update-consumer» could be renamed and supplanted with
599 a wrapper script which conditionally runs the real
601 * In the postinst, arrange for the new ‘triggered’ invocation to
602 run «update-consumer --real». The consumer package's postinst
603 will already run «update-consumer» during configuration, and this
604 should be retained and supplemented with the --real option (or
605 changed to call the real script rather than the wrapper).
606 3. Update the producer packages:
607 * In the postinst, remove the call to «update-consumer».
608 * Change the dependency on consumer to be versioned, specifying a
609 trigger-interested consumer.
610 This can be done at our leisure. Ideally for loosely coupled
611 packages this would be done only in the release after the one
612 containing the triggers-interested consumer, to facilitate partial
613 upgrades and backports.
614 4. After all producer packages have been updated according to step 3,
615 «update-consumer» has become an interface internal to the consumer
616 and need no longer be kept stable. If un-updated producers are
617 still of interest, incompatible changes to «update-consumer» imply
618 a versioned Breaks against the old producers.
619 (See also “Transition plan”, below.)
621 If there are several consumer packages all of which are interested in
622 the features provided by producer packages, the current arrangements
623 usually involve an additional central switchboard package (eg,
624 emacsen-common). In this case:
626 -- NOTE - this part of the transition plan is still a proof of
627 concept and we might yet improve on it
629 1. Define the trigger name.
630 2. Update the switchboard to have any new functionality needed by the
631 consumers in step 3 (2nd bullet).
632 3. Update the consumer packages:
633 * Declare an interest in the trigger.
634 * In the postinst, arrange for the new ‘trigger’ invocation to run
635 the compilation/registration process. This may involve scanning
636 for new or removed producers, and may involve new common
637 functionality from the switchboard (in which case a versioned
639 * The old interface allowing the switchboard to run
640 compilation/registration should be preserved, including
641 calls to the switchboard to register this consumer.
642 4. When all consumers have been updated, update the switchboard:
643 * Make the registration scripts called by producers try to
644 activate the trigger and if that succeeds quit without
645 doing any work (as for bullet 2 in the simple case above).
646 * Versioned Breaks, against the old (pre-step-3) consumers.
647 5. After the switchboard has been updated, producers can be updated:
648 * Remove the calls to the switchboard registration/compilation
650 * Change the dependency on the switchboard to a versioned one,
651 specifying the one which Breaks old consumers. Alternatively,
652 it may be the case that the switchboard is no longer needed (or
653 not needed for this producer), in which case the dependency on
654 the switchboard can be removed in favour of an appropriate
655 versioned Breaks (probably, identical to that in the new
657 6. After all the producers have been updated, the cruft in the
658 consumers can go away:
659 * Remove the calls to the switchboard's registration system.
660 * Versioned Breaks against old switchboards, or versioned Depends
661 on new switchboards, depending on whether the switchboard is
662 still needed for other common functionality.
663 7. After all of the producers and consumers have been updated, the
664 cruft in the switchboard can go away:
665 * Remove the switchboard's registration system (but not obviously
666 the common functionality from step 3, discussed above).
667 * Versioned Breaks against pre-step-6 consumers and pre-step-5
674 The activation of a trigger does not record details of the activating
675 event. For example, file triggers do not inform the package of the
676 filename. In the future this might be added as an additional feature,
677 but there are some problems with this.
680 Broken producer packages, and error reporting
681 ---------------------------------------------
683 Often trigger processing will involve a central package registering,
684 compiling or generally parsing some data provided by a leaf package.
686 If the central package finds problems with the leaf package data it is
687 usually more correct for only the individual leaf package to be
688 recorded as not properly installed. There is not currently any way to
689 do this and there are no plans to provide one.
691 The naive approach of giving the postinst a list of the triggering
692 packages does not work because this information is not recorded in the
693 right way (it might suffer from lacunae); enhancing the bookkeeping
694 for this to work would be possible but it is far better simply to make
695 the system more idempotent. See above for the recommended approach.
706 A single file /var/lib/dpkg/triggers/File lists all of the filename
707 trigger interests in the form
708 /path/to/directory/or/file package
710 For each explicit trigger in which any package is interested,
711 a file /var/lib/dpkg/triggers/<name-of-trigger> is a list of
712 the interested packages, one per line.
714 These interest files are not updated to remove a package just because
715 a state change causes it not to be interested in any triggers any more
716 - they are updated when we remove or unpack.
718 For each package which has pending triggers, the status file contains
719 a Triggers-Pending field which contains the space-separated names of
720 the pending triggers. For each package which awaits triggers the
721 status file contains a Triggers-Awaited field which contains the
722 *package* names of the packages whose trigger processing is awaited.
723 See “Details - Overview table” above for the invariants which relate
724 Triggers-Pending, Triggers-Awaited, and Status.
726 During dpkg's execution, /var/lib/dpkg/triggers/Unincorp is a list of
727 the triggers which have been requested by dpkg-trigger but not yet
728 incorporated in the status file. Each line is a trigger name followed
729 by one or more triggering package names. The triggering package name
730 "-" is used to indicate one or more package(s) which did not need to
733 /var/lib/dpkg/triggers/Lock is the fcntl lockfile for the trigger
734 system. Processes hang onto this lock only briefly: dpkg-trigger
735 to add new activations, or dpkg to incorporate activations (and
736 perhaps when it updates interests). Therefore this lock is always
737 acquired with F_GETLKW so as to serialize rather than fail on
744 dpkg-trigger updates triggers/Unincorp, and does not read or write the
745 status file or take out the dpkg status lock. dpkg (and dpkg-query)
746 reads triggers/Unincorp after reading /var/lib/dpkg/status, and after
747 running a maintainer script. If the status database is opened for
748 writing then the data from Unincorp is moved to updates as
749 Triggers-Pending and Triggers-Awaited entries and corresponding Status
752 This means that dpkg is guaranteed to reincorporate pending trigger
753 information into the status file only 1. when a maintainer script has
754 finished, or 2. when dpkg starts up with a view to performing some
757 When a package is unpacked or removed, its triggers control file will
758 be parsed and /var/lib/dpkg/triggers/* updated accordingly.
760 Triggers are run as part of configuration. dpkg will try to first
761 configure all packages which do not depend on packages which are
762 awaiting triggers, and then run triggers one package at a time in the
763 hope of making useful progress. (This will involve a new ‘dependtry’
764 level in configure.c's algorithm.) The only constraint on the
765 ordering of postinsts is only the normal Depends constraint, so the
766 usual Depends cycle breaking will function properly. See “Cycle
767 detection” below regarding cycles in the “A triggers B” relation.
770 Processing - Transitional
771 -------------------------
773 The case where a triggers-supporting dpkg is run for the first time is
774 detected by the absence of /var/lib/dpkg/triggers/Unincorp. When the
775 triggers-supporting dpkg starts up without this it will set each
776 package's list of pending triggers equal to its interests (obviously
777 only for packages which are in ‘installed’ or ‘triggers-pending’).
778 This may result in a package going from ‘installed’ to
779 ‘triggers-pending’ but it will not create the directory at this time.
780 Packages marked as triggers-pending in this way will not be scheduled
781 for trigger processing in this dpkg run.
783 dpkg will also at this time create /var/lib/dpkg/triggers if
784 necessary, triggers/File, triggers/Unincorp, and the per-trigger
785 package lists in /var/lib/dpkg/triggers/<trigger-name>, so that future
786 trigger activations will be processed properly.
788 Only dpkg may create /var/lib/dpkg/triggers and only when it is
789 holding the overall dpkg status lock.
791 dpkg and/or dpkg-deb will be made to reject packages containing
792 Triggers-Pending and Triggers-Awaited control file fields, to prevent
799 In addition to dependency cycles, triggers raise the possibility of
800 mutually triggering packages - a cycle detectable only dynamically,
801 which we will call a “trigger cycle”.
803 Trigger cycles are detected using the usual hare-and-tortoise
804 approach. Each time after dpkg runs a postinst for triggers, dpkg
805 records the set of pending triggers (ie, the set of activated <pending
806 package, trigger name> tuples). If the hare set is a superset of the
807 tortoise set, a cycle has been found.
809 For guaranteed termination, it would be sufficient to declare a cycle
810 only when the two sets are identical, but because of the requirement
811 to make progress we can cut this short. Formally, there is supposed
812 to be a complete ordering of pending trigger sets satisfying the
813 condition that any set of pending triggers is (strictly) greater than
814 all its (strict) subsets. Trigger processing is supposed to
815 monotonically decrease the set in this ordering. (The set elements
816 are <package, trigger name> tuples.)
818 (See “Processing” above for discussion of dependency cycles.)