Преглед изворни кода

dpkg: Defer trigger processing if the packages do not fulfill dependencies

The spec specified this behavior, but the code never abided by it.
Change it now that most of the packages with trigger cycles have been
switched to noawaiting triggers. The rest will make dpkg bail out on
upgrade.

We might need to add appropriate versioned Breaks before the Debian
release to get a smoother distribution upgrade.

Closes: #671711
Guillem Jover пре 14 година
родитељ
комит
35c1c59cfa
2 измењених фајлова са 25 додато и 0 уклоњено
  1. 2 0
      debian/changelog
  2. 23 0
      src/trigproc.c

+ 2 - 0
debian/changelog

@@ -6,6 +6,8 @@ dpkg (1.17.17) UNRELEASED; urgency=low
   * Fix some typos for versioned and mentioned in comments and changelogs.
   * Mark for translation and unify "rm cleanup" string in dpkg.
   * Mark for translation and improve dselect method handling error messages.
+  * Defer trigger processing if the package does not fulfill dependencies.
+    Closes: #671711
 
   [ Updated programs translations ]
   * German (Sven Joachim).

+ 23 - 0
src/trigproc.c

@@ -316,6 +316,7 @@ trigproc(struct pkginfo *pkg)
 {
 	static struct varbuf namesarg;
 
+	struct varbuf depwhynot = VARBUF_INIT;
 	struct trigpend *tp;
 	struct pkginfo *gaveup;
 
@@ -326,6 +327,8 @@ trigproc(struct pkginfo *pkg)
 	pkg->clientdata->trigprocdeferred = NULL;
 
 	if (pkg->trigpend_head) {
+		enum dep_check ok;
+
 		assert(pkg->status == PKG_STAT_TRIGGERSPENDING ||
 		       pkg->status == PKG_STAT_TRIGGERSAWAITED);
 
@@ -333,6 +336,26 @@ trigproc(struct pkginfo *pkg)
 		if (gaveup == pkg)
 			return;
 
+		ok = dependencies_ok(pkg, NULL, &depwhynot);
+		if (ok == DEP_CHECK_OK) {
+			debug(dbg_triggers, "trigproc %s dependencies satisfied, "
+			      "processing", pkg_name(pkg, pnaw_always));
+		} else if (ok == DEP_CHECK_DEFER) {
+			debug(dbg_triggers, "trigproc %s dependencies unsatisfied, "
+			      "defer processing", pkg_name(pkg, pnaw_always));
+			varbuf_destroy(&depwhynot);
+
+			enqueue_package(pkg);
+			return;
+		} else if (ok == DEP_CHECK_HALT) {
+			varbuf_end_str(&depwhynot);
+			debug(dbg_triggers, "trigproc %s dependencies unsatisfied, "
+			      "skipping due to:\n %s",
+			      pkg_name(pkg, pnaw_always), depwhynot.buf);
+			varbuf_destroy(&depwhynot);
+			return;
+		}
+
 		printf(_("Processing triggers for %s (%s) ...\n"),
 		       pkg_name(pkg, pnaw_nonambig),
 		       versiondescribe(&pkg->installed.version, vdew_nonambig));