[Reproducible-commits] [dpkg] 24/54: dpkg: Add support for DPKG_MAINTSCRIPT_DEBUG environment variable

Mattia Rizzolo mattia at debian.org
Fri Jan 15 18:54:00 UTC 2016


This is an automated email from the git hooks/post-receive script.

mattia pushed a commit to branch pu/reproducible_builds
in repository dpkg.

commit 522a3ba2853b41602d5452be598d5ccb4d326621
Author: Guillem Jover <guillem at debian.org>
Date:   Tue Nov 3 15:39:30 2015 +0100

    dpkg: Add support for DPKG_MAINTSCRIPT_DEBUG environment variable
    
    This variable will be set on the maintainer scripts environment to
    either 0 or 1, depending on whether dpkg was called with --debug
    requesting maintainer scripts debugging output.
---
 debian/changelog | 1 +
 man/dpkg.1       | 6 ++++++
 src/script.c     | 5 +++++
 3 files changed, 12 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index ba65be6..0c027d9 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -16,6 +16,7 @@ dpkg (1.18.4) UNRELEASED; urgency=low
   * Make dpkg-architecture warning on non-matching GNU system type compiler
     agnostic.
   * Add ‘.gitreview’ to the default dpkg-source ignore lists.
+  * Add support for DPKG_MAINTSCRIPT_DEBUG environment variable to dpkg.
   * Test suite:
     - Improve perl code test coverage.
   * Build system:
diff --git a/man/dpkg.1 b/man/dpkg.1
index b545550..ed01445 100644
--- a/man/dpkg.1
+++ b/man/dpkg.1
@@ -858,6 +858,12 @@ architecture the package got built for (since dpkg 1.15.4).
 Defined by \fBdpkg\fP on the maintainer script environment to the
 name of the script running, one of \fBpreinst\fP, \fBpostinst\fP,
 \fBprerm\fP or \fBpostrm\fP (since dpkg 1.15.7).
+.TP
+.B DPKG_MAINTSCRIPT_DEBUG
+Defined by \fBdpkg\fP on the maintainer script environment to a value
+(\(oq\fB0\fP\(cq or \(oq\fB1\fP\(cq) noting whether debugging has been
+requested (with the \fB\-\-debug\fP option) for the maintainer scripts
+(since dpkg 1.18.4).
 .
 .SH FILES
 .TP
diff --git a/src/script.c b/src/script.c
index a3d0d58..d9514da 100644
--- a/src/script.c
+++ b/src/script.c
@@ -36,6 +36,7 @@
 #endif
 
 #include <dpkg/i18n.h>
+#include <dpkg/debug.h>
 #include <dpkg/dpkg.h>
 #include <dpkg/dpkg-db.h>
 #include <dpkg/pkg.h>
@@ -165,13 +166,17 @@ maintscript_exec(struct pkginfo *pkg, struct pkgbin *pkgbin,
 	pid = subproc_fork();
 	if (pid == 0) {
 		char *pkg_count;
+		const char *maintscript_debug;
 
 		pkg_count = str_fmt("%d", pkgset_installed_instances(pkg->set));
 
+		maintscript_debug = debug_has_flag(dbg_scripts) ? "1" : "0";
+
 		if (setenv("DPKG_MAINTSCRIPT_PACKAGE", pkg->set->name, 1) ||
 		    setenv("DPKG_MAINTSCRIPT_PACKAGE_REFCOUNT", pkg_count, 1) ||
 		    setenv("DPKG_MAINTSCRIPT_ARCH", pkgbin->arch->name, 1) ||
 		    setenv("DPKG_MAINTSCRIPT_NAME", cmd->argv[0], 1) ||
+		    setenv("DPKG_MAINTSCRIPT_DEBUG", maintscript_debug, 1) ||
 		    setenv("DPKG_RUNNING_VERSION", PACKAGE_VERSION, 1))
 			ohshite(_("unable to setenv for maintainer script"));
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list