Explorar o código

dpkg: Add explicit await trigger directives and command-line options

The current default of awaiting is really bad, because most packages
do not really require to be put in a triggers-awaited status. Also
maintainers tend to use it instead of the -noawait variant, making
trigger cycles more common.

Changing the default behavior was not an option, as precisely doing
so would affect the packages that would break when not put in a
triggers-awaited status.

Instead we'll add explicit await variants for the triggers, and
dpkg-trigger, and probably deprecate the implicit ones during the
1.18.x cycle. Maybe, and only maybe it can be switched to be the
noawait variants in 1.19.x or 1.20.x, perhaps.
Guillem Jover %!s(int64=11) %!d(string=hai) anos
pai
achega
a67c4ccd2d
Modificáronse 5 ficheiros con 42 adicións e 11 borrados
  1. 4 0
      debian/changelog
  2. 12 2
      lib/dpkg/triglib.c
  3. 15 2
      man/deb-triggers.5
  4. 4 0
      man/dpkg-trigger.1
  5. 7 7
      src/trigcmd.c

+ 4 - 0
debian/changelog

@@ -10,6 +10,10 @@ dpkg (1.17.21) UNRELEASED; urgency=low
     Instead allow only «--count=10» in addition to «--count 10».
   * Accept «-S value» in addition to «-Svalue» in dpkg-parsechangelog.
     Closes: #766559
+  * Add support for new interest-await and activate-await trigger directives.
+    And a new --await option to dpkg-trigger. This might allow possibly
+    switching the default meaning after a transition period no shorter than
+    two minor versions, so in 1.19.x or 1.20.x. Perhaps.
 
   [ Updated programs translations ]
   * Catalan (Guillem Jover).

+ 12 - 2
lib/dpkg/triglib.c

@@ -306,6 +306,10 @@ trk_explicit_activate_awaiter(struct pkginfo *aw)
 			noawait = true;
 			*slash = '\0';
 		}
+		if (slash && strcmp("/await", slash) == 0) {
+			noawait = false;
+			*slash = '\0';
+		}
 
 		pend = pkg_spec_parse_pkg(buf, &err);
 		if (pend == NULL)
@@ -518,6 +522,10 @@ trig_file_interests_ensure(void)
 			trig_opts = TRIG_NOAWAIT;
 			*slash = '\0';
 		}
+		if (slash && strcmp("/await", slash) == 0) {
+			trig_opts = TRIG_AWAIT;
+			*slash = '\0';
+		}
 
 		pkg = pkg_spec_parse_pkg(space, &err);
 		if (pkg == NULL)
@@ -699,11 +707,13 @@ trig_parse_ci(const char *file, trig_parse_cicb *interest,
 		*spc++ = '\0';
 		while (cisspace(*spc))
 			spc++;
-		if (strcmp(cmd, "interest") == 0) {
+		if (strcmp(cmd, "interest") == 0 ||
+		    strcmp(cmd, "interest-await") == 0) {
 			parse_ci_call(file, cmd, interest, spc, pkg, pkgbin, TRIG_AWAIT);
 		} else if (strcmp(cmd, "interest-noawait") == 0) {
 			parse_ci_call(file, cmd, interest, spc, pkg, pkgbin, TRIG_NOAWAIT);
-		} else if (strcmp(cmd, "activate") == 0) {
+		} else if (strcmp(cmd, "activate") == 0 ||
+		           strcmp(cmd, "activate-await") == 0) {
 			parse_ci_call(file, cmd, activate, spc, pkg, pkgbin, TRIG_AWAIT);
 		} else if (strcmp(cmd, "activate-noawait") == 0) {
 			parse_ci_call(file, cmd, activate, spc, pkg, pkgbin, TRIG_NOAWAIT);

+ 15 - 2
man/deb-triggers.5

@@ -1,6 +1,6 @@
 .\" dpkg manual page - deb-triggers(5)
 .\"
-.\" Copyright © 2008, 2013 Guillem Jover <guillem@debian.org>
+.\" Copyright © 2008, 2013, 2014 Guillem Jover <guillem@debian.org>
 .\" Copyright © 2011, 2014 Raphaël Hertzog <hertzog@debian.org>
 .\"
 .\" This is free software; you can redistribute it and/or modify
@@ -16,7 +16,7 @@
 .\" You should have received a copy of the GNU General Public License
 .\" along with this program.  If not, see <https://www.gnu.org/licenses/>.
 .
-.TH deb\-triggers 5 "2013-04-02" "Debian Project" "dpkg utilities"
+.TH deb\-triggers 5 "2014-10-15" "Debian Project" "dpkg utilities"
 .SH NAME
 deb\-triggers \- package triggers
 .
@@ -39,6 +39,10 @@ The trigger control directives currently supported are:
 .I trigger-name
 .PP
 .in +5
+.B interest\-await
+.I trigger-name
+.PP
+.in +5
 .B interest\-noawait
 .I trigger-name
 .PP
@@ -54,6 +58,10 @@ be used when the functionality provided by the trigger is not crucial.
 .I trigger-name
 .PP
 .in +5
+.B activate\-await
+.I trigger-name
+.PP
+.in +5
 .B activate\-noawait
 .I trigger-name
 .PP
@@ -88,6 +96,11 @@ The "\-noawait" variants are only supported since dpkg 1.16.1, and
 will lead to errors if used with an older dpkg. It is thus recommended
 to add a "Pre\-Depends: dpkg (>= 1.16.1)" to any package that wish to use
 those directives.
+.PP
+The "\-await" alias variants are only supported since dpkg 1.17.21, and
+will lead to errors if used with an older dpkg. It is thus recommended
+to add a "Pre\-Depends: dpkg (>= 1.17.21)" to any package that wish to use
+those directives.
 .
 .SH SEE ALSO
 .BR dpkg\-trigger (1),

+ 4 - 0
man/dpkg-trigger.1

@@ -71,6 +71,10 @@ added to T's trigger processing awaited list and T's status is unchanged.
 T may be considered installed even though I may not yet have processed
 the trigger.
 .TP
+.BR \-\-await
+This option does the inverse of \fB\-\-no\-await\fP. It is currently the
+default behavior.
+.TP
 .BR \-\-no\-act
 Just test, do not actually change anything.
 .

+ 7 - 7
src/trigcmd.c

@@ -82,6 +82,7 @@ usage(const struct cmdinfo *ci, const char *value)
 "  --admindir=<directory>           Use <directory> instead of %s.\n"
 "  --by-package=<package>           Override trigger awaiter (normally set\n"
 "                                     by dpkg).\n"
+"  --await                          Package needs to await the processing.\n"
 "  --no-await                       No package needs to await the processing.\n"
 "  --no-act                         Just test - don't actually change anything.\n"
 "\n"), ADMINDIR);
@@ -93,16 +94,11 @@ usage(const struct cmdinfo *ci, const char *value)
 
 static const char *admindir;
 static int f_noact, f_check;
+static int f_await = 1;
 
 static const char *bypackage, *activate;
 static bool done_trig, ctrig;
 
-static void
-noawait(const struct cmdinfo *ci, const char *value)
-{
-	bypackage = "-";
-}
-
 static void
 yespackage(const char *awname)
 {
@@ -115,6 +111,9 @@ parse_awaiter_package(void)
 	struct dpkg_error err = DPKG_ERROR_INIT;
 	struct pkginfo *pkg;
 
+	if (!f_await)
+		bypackage = "-";
+
 	if (bypackage == NULL) {
 		const char *pkgname, *archname;
 
@@ -193,7 +192,8 @@ do_check(void)
 static const struct cmdinfo cmdinfos[] = {
 	{ "admindir",        0,   1, NULL,     &admindir },
 	{ "by-package",      'f', 1, NULL,     &bypackage },
-	{ "no-await",        0,   0, NULL,     &bypackage, noawait },
+	{ "await",           0,   0, &f_await, NULL,       NULL, 1 },
+	{ "no-await",        0,   0, &f_await, NULL,       NULL, 0 },
 	{ "no-act",          0,   0, &f_noact, NULL,       NULL, 1 },
 	{ "check-supported", 0,   0, &f_check, NULL,       NULL, 1 },
 	{ "help",            '?', 0, NULL,     NULL,       usage   },