Branch data Line data Source code
1 : : /*
2 : : * dpkg - main program for package management
3 : : * trigproc.c - trigger processing
4 : : *
5 : : * Copyright © 2007 Canonical Ltd
6 : : * written by Ian Jackson <ijackson@chiark.greenend.org.uk>
7 : : * Copyright © 2008-2014 Guillem Jover <guillem@debian.org>
8 : : *
9 : : * This is free software; you can redistribute it and/or modify
10 : : * it under the terms of the GNU General Public License as published by
11 : : * the Free Software Foundation; either version 2 of the License, or
12 : : * (at your option) any later version.
13 : : *
14 : : * This is distributed in the hope that it will be useful,
15 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : : * GNU General Public License for more details.
18 : : *
19 : : * You should have received a copy of the GNU General Public License
20 : : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : : */
22 : :
23 : : #include <config.h>
24 : : #include <compat.h>
25 : :
26 : : #include <sys/stat.h>
27 : :
28 : : #include <fcntl.h>
29 : : #include <stdlib.h>
30 : :
31 : : #include <dpkg/i18n.h>
32 : : #include <dpkg/dpkg.h>
33 : : #include <dpkg/dpkg-db.h>
34 : : #include <dpkg/pkg.h>
35 : : #include <dpkg/pkg-queue.h>
36 : : #include <dpkg/db-ctrl.h>
37 : : #include <dpkg/db-fsys.h>
38 : : #include <dpkg/triglib.h>
39 : :
40 : : #include "main.h"
41 : :
42 : : /*
43 : : * Trigger processing algorithms:
44 : : *
45 : : *
46 : : * There is a separate queue (‘deferred trigproc list’) for triggers
47 : : * ‘relevant’ to what we just did; when we find something triggered ‘now’
48 : : * we add it to that queue (unless --no-triggers).
49 : : *
50 : : *
51 : : * We want to prefer configuring packages where possible to doing trigger
52 : : * processing, although it would be better to prefer trigger processing
53 : : * to cycle-breaking we need to do the latter first or we might generate
54 : : * artificial trigger cycles, but we always want to prefer trigger
55 : : * processing to dependency forcing. This is achieved as follows:
56 : : *
57 : : * Each time during configure processing where a package D is blocked by
58 : : * only (ie Depends unsatisfied but would be satisfied by) a t-awaiter W
59 : : * we make a note of (one of) W's t-pending, T. (Only the last such T.)
60 : : * (If --no-triggers and nonempty argument list and package isn't in
61 : : * argument list then we don't do this.)
62 : : *
63 : : * Each time in process_queue() where we increment dependtry, we instead
64 : : * see if we have encountered such a t-pending T. If we do and are in
65 : : * a trigger processing try, we trigproc T instead of incrementing
66 : : * dependtry and this counts as having done something so we reset
67 : : * sincenothing.
68 : : *
69 : : *
70 : : * For --triggers-only and --configure, we go through each thing in the
71 : : * argument queue (the enqueue_package queue) and check what its state is
72 : : * and if appropriate we trigproc it. If we didn't have a queue (or had
73 : : * just --pending) we search all triggers-pending packages and add them
74 : : * to the deferred trigproc list.
75 : : *
76 : : *
77 : : * Before quitting from most operations, we trigproc each package in the
78 : : * deferred trigproc list. This may (if not --no-triggers) of course add
79 : : * new things to the deferred trigproc list.
80 : : *
81 : : *
82 : : * Note that ‘we trigproc T’ must involve trigger cycle detection and
83 : : * also automatic setting of t-awaiters to t-pending or installed. In
84 : : * particular, we do cycle detection even for trigger processing in the
85 : : * configure dependtry loop (and it is OK to do it for explicitly
86 : : * specified packages from the command line arguments; duplicates are
87 : : * removed by packages.c:process_queue).
88 : : */
89 : :
90 : : /*========== Deferred trigger queue. ==========*/
91 : :
92 : : static struct pkg_queue deferred = PKG_QUEUE_INIT;
93 : :
94 : : static void
95 : 0 : trigproc_enqueue_deferred(struct pkginfo *pend)
96 : : {
97 [ # # ]: 0 : if (f_triggers < 0)
98 : 0 : return;
99 : 0 : ensure_package_clientdata(pend);
100 [ # # ]: 0 : if (pend->clientdata->trigprocdeferred)
101 : 0 : return;
102 : 0 : pend->clientdata->trigprocdeferred = pkg_queue_push(&deferred, pend);
103 : 0 : debug(dbg_triggers, "trigproc_enqueue_deferred pend=%s",
104 : : pkg_name(pend, pnaw_always));
105 : : }
106 : :
107 : : /**
108 : : * Populate the deferred trigger queue.
109 : : *
110 : : * When dpkg is called with a specific set of packages to act on, we might
111 : : * have packages pending trigger processing. But because there are frontends
112 : : * that do not perform a final «dpkg --configure --pending» call (i.e. apt),
113 : : * the system is left in a state with packages not fully installed.
114 : : *
115 : : * We have to populate the deferred trigger queue from the entire package
116 : : * database, so that we might try to do opportunistic trigger processing
117 : : * when going through the deferred trigger queue, because a fixed apt will
118 : : * not request the necessary processing anyway.
119 : : *
120 : : * XXX: This can be removed once apt is fixed in the next stable release.
121 : : */
122 : : void
123 : 0 : trigproc_populate_deferred(void)
124 : : {
125 : : struct pkg_hash_iter *iter;
126 : : struct pkginfo *pkg;
127 : :
128 : 0 : iter = pkg_hash_iter_new();
129 [ # # ]: 0 : while ((pkg = pkg_hash_iter_next_pkg(iter))) {
130 [ # # ]: 0 : if (!pkg->trigpend_head)
131 : 0 : continue;
132 : :
133 [ # # ]: 0 : if (pkg->status != PKG_STAT_TRIGGERSAWAITED &&
134 [ # # ]: 0 : pkg->status != PKG_STAT_TRIGGERSPENDING)
135 : 0 : continue;
136 : :
137 [ # # ]: 0 : if (pkg->want != PKG_WANT_INSTALL &&
138 [ # # ]: 0 : pkg->want != PKG_WANT_HOLD)
139 : 0 : continue;
140 : :
141 : 0 : trigproc_enqueue_deferred(pkg);
142 : : }
143 : 0 : pkg_hash_iter_free(iter);
144 : 0 : }
145 : :
146 : : void
147 : 0 : trigproc_run_deferred(void)
148 : : {
149 : : jmp_buf ejbuf;
150 : :
151 : 0 : debug(dbg_triggers, "trigproc_run_deferred");
152 [ # # ]: 0 : while (!pkg_queue_is_empty(&deferred)) {
153 : : struct pkginfo *pkg;
154 : :
155 : 0 : pkg = pkg_queue_pop(&deferred);
156 [ # # ]: 0 : if (!pkg)
157 : 0 : continue;
158 : :
159 [ # # ]: 0 : if (setjmp(ejbuf)) {
160 : 0 : pop_error_context(ehflag_bombout);
161 : 0 : continue;
162 : : }
163 : 0 : push_error_context_jump(&ejbuf, print_error_perpackage,
164 : 0 : pkg_name(pkg, pnaw_nonambig));
165 : :
166 : 0 : ensure_package_clientdata(pkg);
167 : 0 : pkg->clientdata->trigprocdeferred = NULL;
168 : 0 : trigproc(pkg, TRIGPROC_TRY_DEFERRED);
169 : :
170 : 0 : pop_error_context(ehflag_normaltidy);
171 : : }
172 : 0 : }
173 : :
174 : : /*
175 : : * Called by modstatdb_note.
176 : : */
177 : : void
178 : 0 : trig_activate_packageprocessing(struct pkginfo *pkg)
179 : : {
180 : 0 : debug(dbg_triggersdetail, "trigproc_activate_packageprocessing pkg=%s",
181 : : pkg_name(pkg, pnaw_always));
182 : :
183 : 0 : trig_parse_ci(pkg_infodb_get_file(pkg, &pkg->installed, TRIGGERSCIFILE),
184 : : NULL, trig_cicb_statuschange_activate,
185 : : pkg, &pkg->installed);
186 : 0 : }
187 : :
188 : : /*========== Actual trigger processing. ==========*/
189 : :
190 : : struct trigcyclenode {
191 : : struct trigcyclenode *next;
192 : : struct trigcycleperpkg *pkgs;
193 : : struct pkginfo *then_processed;
194 : : };
195 : :
196 : : struct trigcycleperpkg {
197 : : struct trigcycleperpkg *next;
198 : : struct pkginfo *pkg;
199 : : struct trigpend *then_trigs;
200 : : };
201 : :
202 : : static bool tortoise_advance;
203 : : static struct trigcyclenode *tortoise, *hare;
204 : :
205 : : void
206 : 0 : trigproc_reset_cycle(void)
207 : : {
208 : 0 : tortoise_advance = false;
209 : 0 : tortoise = hare = NULL;
210 : 0 : }
211 : :
212 : : static bool
213 : 0 : tortoise_in_hare(struct pkginfo *processing_now,
214 : : struct trigcycleperpkg *tortoise_pkg)
215 : : {
216 : : const char *processing_now_name, *tortoise_name;
217 : : struct trigpend *hare_trig, *tortoise_trig;
218 : :
219 : 0 : processing_now_name = pkg_name(processing_now, pnaw_nonambig);
220 : 0 : tortoise_name = pkg_name(tortoise_pkg->pkg, pnaw_nonambig);
221 : :
222 : 0 : debug(dbg_triggersdetail, "%s pnow=%s tortoise=%s", __func__,
223 : : processing_now_name, tortoise_name);
224 : 0 : for (tortoise_trig = tortoise_pkg->then_trigs;
225 [ # # ]: 0 : tortoise_trig;
226 : 0 : tortoise_trig = tortoise_trig->next) {
227 : 0 : debug(dbg_triggersdetail,
228 : : "%s pnow=%s tortoise=%s tortoisetrig=%s", __func__,
229 : : processing_now_name, tortoise_name, tortoise_trig->name);
230 : :
231 : : /* hare is now so we can just look up in the actual data. */
232 : 0 : for (hare_trig = tortoise_pkg->pkg->trigpend_head;
233 [ # # ]: 0 : hare_trig;
234 : 0 : hare_trig = hare_trig->next) {
235 : 0 : debug(dbg_triggersstupid, "%s pnow=%s tortoise=%s"
236 : : " tortoisetrig=%s haretrig=%s", __func__,
237 : : processing_now_name, tortoise_name,
238 : : tortoise_trig->name, hare_trig->name);
239 [ # # ]: 0 : if (strcmp(hare_trig->name, tortoise_trig->name) == 0)
240 : 0 : break;
241 : : }
242 : :
243 [ # # ]: 0 : if (hare_trig == NULL) {
244 : : /* Not found in hare, yay! */
245 : 0 : debug(dbg_triggersdetail, "%s pnow=%s tortoise=%s OK",
246 : : __func__, processing_now_name, tortoise_name);
247 : 0 : return false;
248 : : }
249 : : }
250 : :
251 : 0 : return true;
252 : : }
253 : :
254 : : static struct trigcyclenode *
255 : 0 : trigproc_new_cyclenode(struct pkginfo *processing_now)
256 : : {
257 : : struct trigcyclenode *tcn;
258 : : struct trigcycleperpkg *tcpp;
259 : : struct pkginfo *pkg;
260 : : struct pkg_hash_iter *iter;
261 : :
262 : 0 : tcn = nfmalloc(sizeof(*tcn));
263 : 0 : tcn->pkgs = NULL;
264 : 0 : tcn->next = NULL;
265 : 0 : tcn->then_processed = processing_now;
266 : :
267 : 0 : iter = pkg_hash_iter_new();
268 [ # # ]: 0 : while ((pkg = pkg_hash_iter_next_pkg(iter))) {
269 [ # # ]: 0 : if (!pkg->trigpend_head)
270 : 0 : continue;
271 : 0 : tcpp = nfmalloc(sizeof(*tcpp));
272 : 0 : tcpp->pkg = pkg;
273 : 0 : tcpp->then_trigs = pkg->trigpend_head;
274 : 0 : tcpp->next = tcn->pkgs;
275 : 0 : tcn->pkgs = tcpp;
276 : : }
277 : 0 : pkg_hash_iter_free(iter);
278 : :
279 : 0 : return tcn;
280 : : }
281 : :
282 : : /*
283 : : * Returns package we are to give up on.
284 : : */
285 : : static struct pkginfo *
286 : 0 : check_trigger_cycle(struct pkginfo *processing_now)
287 : : {
288 : : struct trigcyclenode *tcn;
289 : : struct trigcycleperpkg *tortoise_pkg;
290 : : struct trigpend *tortoise_trig;
291 : : struct pkginfo *giveup;
292 : : const char *sep;
293 : :
294 : 0 : debug(dbg_triggers, "check_triggers_cycle pnow=%s",
295 : : pkg_name(processing_now, pnaw_always));
296 : :
297 : 0 : tcn = trigproc_new_cyclenode(processing_now);
298 : :
299 [ # # ]: 0 : if (!hare) {
300 : 0 : debug(dbg_triggersdetail, "check_triggers_cycle pnow=%s first",
301 : : pkg_name(processing_now, pnaw_always));
302 : 0 : hare = tortoise = tcn;
303 : 0 : return NULL;
304 : : }
305 : :
306 : 0 : hare->next = tcn;
307 : 0 : hare = hare->next;
308 [ # # ]: 0 : if (tortoise_advance)
309 : 0 : tortoise = tortoise->next;
310 : 0 : tortoise_advance = !tortoise_advance;
311 : :
312 : : /* Now we compare hare to tortoise.
313 : : * We want to find a trigger pending in tortoise which is not in hare
314 : : * if we find such a thing we have proved that hare isn't a superset
315 : : * of tortoise and so that we haven't found a loop (yet). */
316 : 0 : for (tortoise_pkg = tortoise->pkgs;
317 [ # # ]: 0 : tortoise_pkg;
318 : 0 : tortoise_pkg = tortoise_pkg->next) {
319 [ # # ]: 0 : if (!tortoise_in_hare(processing_now, tortoise_pkg))
320 : 0 : return NULL;
321 : : }
322 : : /* Oh dear. hare is a superset of tortoise. We are making no
323 : : * progress. */
324 : 0 : notice(_("cycle found while processing triggers:\n"
325 : : " chain of packages whose triggers are or may be responsible:"));
326 : 0 : sep = " ";
327 [ # # ]: 0 : for (tcn = tortoise; tcn; tcn = tcn->next) {
328 : 0 : fprintf(stderr, "%s%s", sep,
329 : : pkg_name(tcn->then_processed, pnaw_nonambig));
330 : 0 : sep = " -> ";
331 : : }
332 : 0 : fprintf(stderr, _("\n" " packages' pending triggers which are"
333 : : " or may be unresolvable:\n"));
334 : 0 : for (tortoise_pkg = tortoise->pkgs;
335 [ # # ]: 0 : tortoise_pkg;
336 : 0 : tortoise_pkg = tortoise_pkg->next) {
337 : 0 : fprintf(stderr, " %s",
338 : : pkg_name(tortoise_pkg->pkg, pnaw_nonambig));
339 : 0 : sep = ": ";
340 : 0 : for (tortoise_trig = tortoise_pkg->then_trigs;
341 [ # # ]: 0 : tortoise_trig;
342 : 0 : tortoise_trig = tortoise_trig->next) {
343 : 0 : fprintf(stderr, "%s%s", sep, tortoise_trig->name);
344 : : }
345 : 0 : fprintf(stderr, "\n");
346 : : }
347 : :
348 : : /* We give up on the _earliest_ package involved. */
349 : 0 : giveup = tortoise->pkgs->pkg;
350 : 0 : debug(dbg_triggers, "check_triggers_cycle pnow=%s giveup=%s",
351 : : pkg_name(processing_now, pnaw_always),
352 : : pkg_name(giveup, pnaw_always));
353 [ # # ]: 0 : if (giveup->status != PKG_STAT_TRIGGERSAWAITED &&
354 [ # # ]: 0 : giveup->status != PKG_STAT_TRIGGERSPENDING)
355 : 0 : internerr("package %s in non-trigger state %s",
356 : : pkg_name(giveup, pnaw_always),
357 : : pkg_status_name(giveup));
358 : 0 : giveup->clientdata->istobe = PKG_ISTOBE_NORMAL;
359 : 0 : pkg_set_status(giveup, PKG_STAT_HALFCONFIGURED);
360 : 0 : modstatdb_note(giveup);
361 : 0 : print_error_perpackage(_("triggers looping, abandoned"),
362 : 0 : pkg_name(giveup, pnaw_nonambig));
363 : :
364 : 0 : return giveup;
365 : : }
366 : :
367 : : /*
368 : : * Does cycle checking. Doesn't mind if pkg has no triggers pending - in
369 : : * that case does nothing but fix up any stale awaiters.
370 : : */
371 : : void
372 : 0 : trigproc(struct pkginfo *pkg, enum trigproc_type type)
373 : : {
374 : : static struct varbuf namesarg;
375 : :
376 : 0 : struct varbuf depwhynot = VARBUF_INIT;
377 : :
378 : 0 : debug(dbg_triggers, "trigproc %s", pkg_name(pkg, pnaw_always));
379 : :
380 : 0 : ensure_package_clientdata(pkg);
381 [ # # ]: 0 : if (pkg->clientdata->trigprocdeferred)
382 : 0 : pkg->clientdata->trigprocdeferred->pkg = NULL;
383 : 0 : pkg->clientdata->trigprocdeferred = NULL;
384 : :
385 [ # # ]: 0 : if (pkg->trigpend_head) {
386 : : struct pkginfo *gaveup;
387 : : struct trigpend *tp;
388 : : enum dep_check ok;
389 : :
390 [ # # ]: 0 : if (pkg->status != PKG_STAT_TRIGGERSPENDING &&
391 [ # # ]: 0 : pkg->status != PKG_STAT_TRIGGERSAWAITED)
392 : 0 : internerr("package %s in non-trigger state %s",
393 : : pkg_name(pkg, pnaw_always),
394 : : pkg_status_name(pkg));
395 : :
396 [ # # # # ]: 0 : if (dependtry < DEPEND_TRY_TRIGGERS &&
397 : : type == TRIGPROC_TRY_QUEUED) {
398 : : /* We are not yet in a triggers run, so postpone this
399 : : * package completely. */
400 : 0 : enqueue_package(pkg);
401 : 0 : return;
402 : : }
403 : :
404 [ # # ]: 0 : if (dependtry >= DEPEND_TRY_CYCLES) {
405 [ # # ]: 0 : if (findbreakcycle(pkg))
406 : 0 : sincenothing = 0;
407 : : }
408 : :
409 : 0 : ok = dependencies_ok(pkg, NULL, &depwhynot);
410 [ # # ]: 0 : if (ok == DEP_CHECK_DEFER) {
411 [ # # ]: 0 : if (dependtry >= DEPEND_TRY_TRIGGERS_CYCLES) {
412 : 0 : gaveup = check_trigger_cycle(pkg);
413 [ # # ]: 0 : if (gaveup == pkg)
414 : 0 : return;
415 : : }
416 : :
417 : 0 : varbuf_destroy(&depwhynot);
418 : 0 : enqueue_package(pkg);
419 : 0 : return;
420 [ # # ]: 0 : } else if (ok == DEP_CHECK_HALT) {
421 : : /* When doing opportunistic deferred trigger processing,
422 : : * nothing requires us to be able to make progress;
423 : : * skip the package and silently ignore the error due
424 : : * to unsatisfiable dependencies. And because we can
425 : : * end up here repeatedly, if this package is required
426 : : * to make progress for other packages, we need to
427 : : * reset the trigger cycle tracking to avoid detecting
428 : : * bogus cycles*/
429 [ # # ]: 0 : if (type == TRIGPROC_TRY_DEFERRED) {
430 : 0 : trigproc_reset_cycle();
431 : :
432 : 0 : varbuf_destroy(&depwhynot);
433 : 0 : return;
434 : : }
435 : :
436 : 0 : sincenothing = 0;
437 : 0 : notice(_("dependency problems prevent processing "
438 : : "triggers for %s:\n%s"),
439 : : pkg_name(pkg, pnaw_nonambig),
440 : : varbuf_str(&depwhynot));
441 : 0 : varbuf_destroy(&depwhynot);
442 : 0 : ohshit(_("dependency problems - leaving triggers unprocessed"));
443 [ # # ]: 0 : } else if (depwhynot.used) {
444 : 0 : notice(_("%s: dependency problems, but processing "
445 : : "triggers anyway as you requested:\n%s"),
446 : : pkg_name(pkg, pnaw_nonambig),
447 : : varbuf_str(&depwhynot));
448 : 0 : varbuf_destroy(&depwhynot);
449 : : }
450 : :
451 : 0 : gaveup = check_trigger_cycle(pkg);
452 [ # # ]: 0 : if (gaveup == pkg)
453 : 0 : return;
454 : :
455 : 0 : printf(_("Processing triggers for %s (%s) ...\n"),
456 : : pkg_name(pkg, pnaw_nonambig),
457 : 0 : versiondescribe(&pkg->installed.version, vdew_nonambig));
458 : 0 : log_action("trigproc", pkg, &pkg->installed);
459 : :
460 : 0 : varbuf_reset(&namesarg);
461 [ # # ]: 0 : for (tp = pkg->trigpend_head; tp; tp = tp->next) {
462 : 0 : varbuf_add_char(&namesarg, ' ');
463 : 0 : varbuf_add_str(&namesarg, tp->name);
464 : : }
465 : :
466 : : /* Setting the status to half-configured
467 : : * causes modstatdb_note to clear pending triggers. */
468 : 0 : pkg_set_status(pkg, PKG_STAT_HALFCONFIGURED);
469 : 0 : modstatdb_note(pkg);
470 : :
471 [ # # ]: 0 : if (!f_noact) {
472 : 0 : sincenothing = 0;
473 : 0 : maintscript_postinst(pkg, "triggered",
474 : 0 : varbuf_str(&namesarg) + 1, NULL);
475 : : }
476 : :
477 : 0 : post_postinst_tasks(pkg, PKG_STAT_INSTALLED);
478 : : } else {
479 : : /* In other branch is done by modstatdb_note(), from inside
480 : : * post_postinst_tasks(). */
481 : 0 : trig_clear_awaiters(pkg);
482 : : }
483 : : }
484 : :
485 : : /*========== Transitional global activation. ==========*/
486 : :
487 : : static void
488 : 0 : transitional_interest_callback_ro(const char *trig, struct pkginfo *pkg,
489 : : struct pkgbin *pkgbin, enum trig_options opts)
490 : : {
491 : 0 : struct pkginfo *pend = pkg;
492 : 0 : struct pkgbin *pendbin = pkgbin;
493 : :
494 : 0 : debug(dbg_triggersdetail,
495 : : "trig_transitional_interest_callback trig=%s pend=%s",
496 : : trig, pkgbin_name(pend, pendbin, pnaw_always));
497 [ # # ]: 0 : if (pend->status >= PKG_STAT_TRIGGERSAWAITED)
498 : 0 : trig_note_pend(pend, nfstrsave(trig));
499 : 0 : }
500 : :
501 : : static void
502 : 0 : transitional_interest_callback(const char *trig, struct pkginfo *pkg,
503 : : struct pkgbin *pkgbin, enum trig_options opts)
504 : : {
505 : 0 : struct pkginfo *pend = pkg;
506 : 0 : struct pkgbin *pendbin = pkgbin;
507 : :
508 : 0 : trig_cicb_interest_add(trig, pend, pendbin, opts);
509 : 0 : transitional_interest_callback_ro(trig, pend, pendbin, opts);
510 : 0 : }
511 : :
512 : : /*
513 : : * cstatus might be msdbrw_readonly if we're in --no-act mode, in which
514 : : * case we don't write out all of the interest files etc. but we do
515 : : * invent all of the activations for our own benefit.
516 : : */
517 : : static void
518 : 0 : trig_transitional_activate(enum modstatdb_rw cstatus)
519 : : {
520 : : struct pkg_hash_iter *iter;
521 : : struct pkginfo *pkg;
522 : :
523 : 0 : iter = pkg_hash_iter_new();
524 [ # # ]: 0 : while ((pkg = pkg_hash_iter_next_pkg(iter))) {
525 [ # # ]: 0 : if (pkg->status <= PKG_STAT_HALFINSTALLED)
526 : 0 : continue;
527 : 0 : debug(dbg_triggersdetail, "trig_transitional_activate %s %s",
528 : : pkg_name(pkg, pnaw_always),
529 : : pkg_status_name(pkg));
530 : 0 : pkg->trigpend_head = NULL;
531 [ # # ]: 0 : trig_parse_ci(pkg_infodb_get_file(pkg, &pkg->installed,
532 : : TRIGGERSCIFILE),
533 : : cstatus >= msdbrw_write ?
534 : : transitional_interest_callback :
535 : : transitional_interest_callback_ro, NULL,
536 : : pkg, &pkg->installed);
537 : : /* Ensure we're not creating incoherent data that can't
538 : : * be written down. This should never happen in theory but
539 : : * can happen if you restore an old status file that is
540 : : * not in sync with the infodb files. */
541 [ # # ]: 0 : if (pkg->status < PKG_STAT_TRIGGERSAWAITED)
542 : 0 : continue;
543 : :
544 [ # # ]: 0 : if (pkg->trigaw.head)
545 : 0 : pkg_set_status(pkg, PKG_STAT_TRIGGERSAWAITED);
546 [ # # ]: 0 : else if (pkg->trigpend_head)
547 : 0 : pkg_set_status(pkg, PKG_STAT_TRIGGERSPENDING);
548 : : else
549 : 0 : pkg_set_status(pkg, PKG_STAT_INSTALLED);
550 : : }
551 : 0 : pkg_hash_iter_free(iter);
552 : :
553 [ # # ]: 0 : if (cstatus >= msdbrw_write) {
554 : 0 : modstatdb_checkpoint();
555 : 0 : trig_file_interests_save();
556 : : }
557 : 0 : }
558 : :
559 : : /*========== Hook setup. ==========*/
560 : :
561 [ # # ]: 0 : TRIGHOOKS_DEFINE_NAMENODE_ACCESSORS
562 : :
563 : : static const struct trig_hooks trig_our_hooks = {
564 : : .enqueue_deferred = trigproc_enqueue_deferred,
565 : : .transitional_activate = trig_transitional_activate,
566 : : .namenode_find = th_nn_find,
567 : : .namenode_interested = th_nn_interested,
568 : : .namenode_name = th_nn_name,
569 : : };
570 : :
571 : : void
572 : 0 : trigproc_install_hooks(void)
573 : : {
574 : 0 : trig_override_hooks(&trig_our_hooks);
575 : 0 : }
|