[Reproducible-commits] [dpkg] 93/105: dpkg: Export variable DPKG_ROOT in maintainer scripts
Niko Tyni
ntyni at moszumanska.debian.org
Mon May 2 13:49:57 UTC 2016
This is an automated email from the git hooks/post-receive script.
ntyni pushed a commit to branch ntyni/reproducible_builds
in repository dpkg.
commit 1a1cb120d14c9e77e7e560587f444cb1bfc6da5c
Author: Helmut Grohne <helmut at subdivi.de>
Date: Mon Nov 9 22:07:52 2015 +0100
dpkg: Export variable DPKG_ROOT in maintainer scripts
This variable holds the value of instdir. It is supposed to be used
in maintainer scripts. It should be prepended to all paths that are
operated on. Currently, dpkg chroots to the instdir before invoking
maintainer scripts, so when it does that DPKG_ROOT is set to the empty
string. Thus currently, DPKG_ROOT is always empty.
[guillem at debian.org:
- Reword man page to clarify current status. ]
Closes: #804624
Signed-off-by: Guillem Jover <guillem at debian.org>
---
debian/changelog | 2 ++
man/dpkg.1 | 10 ++++++++++
src/main.c | 2 ++
src/script.c | 2 ++
4 files changed, 16 insertions(+)
diff --git a/debian/changelog b/debian/changelog
index 22c5744..591ab59 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -80,6 +80,8 @@ dpkg (1.18.5) UNRELEASED; urgency=medium
* Add new -I option to dpkg-shlibdeps to ignore package build directories.
Closes: #821025
* Add new -O option to dpkg-genchanges.
+ * Make dpkg export variable DPKG_ROOT in maintainer scripts. Closes: #804624
+ Thanks to Helmut Grohne <helmut at subdivi.de>.
* Portability:
- Move DPKG_ADMINDIR environment variable name out from update-alternatives
code, to make life easier for non-dpkg-based systems.
diff --git a/man/dpkg.1 b/man/dpkg.1
index 2992359..dc3d163 100644
--- a/man/dpkg.1
+++ b/man/dpkg.1
@@ -857,6 +857,16 @@ The currently accepted values are: \fBauto\fP, \fBalways\fP and
\fBnever\fP (default).
.SS Internal environment
.TP
+.B DPKG_ROOT
+Defined by \fBdpkg\fP on the maintainer script environment to indicate
+which installation to act on (since dpkg 1.18.5).
+The value is intended to be prepended to any path maintainer scripts
+operate on.
+During normal operation, this variable is empy.
+When installing packages into a different \fBinstdir\fP, \fBdpkg\fP
+normally invokes maintainer scripts using \fBchroot\fP(2) and leaves
+this variable empty.
+.TP
.B DPKG_SHELL_REASON
Defined by \fBdpkg\fP on the shell spawned on the conffile prompt to
examine the situation (since dpkg 1.15.6).
diff --git a/src/main.c b/src/main.c
index cd4211b..790919e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -876,6 +876,8 @@ int main(int argc, const char *const *argv) {
/* Always set environment, to avoid possible security risks. */
if (setenv("DPKG_ADMINDIR", admindir, 1) < 0)
ohshite(_("unable to setenv for subprocesses"));
+ if (setenv("DPKG_ROOT", instdir, 1) < 0)
+ ohshite(_("unable to setenv for subprocesses"));
if (!f_triggers)
f_triggers = (cipaction->arg_int == act_triggers && *argv) ? -1 : 1;
diff --git a/src/script.c b/src/script.c
index 41cd501..270ec6e 100644
--- a/src/script.c
+++ b/src/script.c
@@ -105,6 +105,8 @@ maintscript_pre_exec(struct command *cmd)
ohshit(_("admindir must be inside instdir for dpkg to work properly"));
if (setenv("DPKG_ADMINDIR", admindir + instdirl, 1) < 0)
ohshite(_("unable to setenv for subprocesses"));
+ if (setenv("DPKG_ROOT", "", 1) < 0)
+ ohshite(_("unable to setenv for subprocesses"));
if (chroot(instdir))
ohshite(_("failed to chroot to '%.250s'"), instdir);
--
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