summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaphaël Hertzog <hertzog@debian.org>2010-04-16 11:56:17 +0200
committerRaphaël Hertzog <hertzog@debian.org>2010-04-16 16:49:42 +0200
commitd5b15f56fbc93983005cf2f9cc1117a3bbb3670c (patch)
tree4204da1f8a94ef29b524add42589e39bf89f7ce6
parent246cf59f8cb555bdaddd36e01d4b57a5e5ac3c7f (diff)
downloaddpkg-d5b15f56fbc93983005cf2f9cc1117a3bbb3670c.tar.gz
dpkg: export DPKG_LIBDIR to maintainer scripts
It can be used to find out the location of some internal dpkg programs that might be called from maintainer scripts. That way we can avoid hardcoding /usr/lib/dpkg and maintainer scripts will still work when called from a dpkg manually installed in /usr/local for example.
-rw-r--r--debian/changelog3
-rw-r--r--lib/dpkg/dpkg.h1
-rw-r--r--man/dpkg.14
-rw-r--r--src/Makefile.am1
-rw-r--r--src/help.c1
5 files changed, 10 insertions, 0 deletions
diff --git a/debian/changelog b/debian/changelog
index 4e2231657..06757d768 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -34,6 +34,9 @@ dpkg (1.15.6.2) UNRELEASED; urgency=low
* dpkg now exports DPKG_MAINTSCRIPT_NAME to maintainer scripts with the
type of maintainer script currently running (preinst, postinst, prerm,
postrm). Closes: #546577
+ * dpkg now exports DPKG_LIBDIR to maintainer scripts pointing to the
+ private directory containing internal programs like the upcoming
+ maintscript-helper.
[ Colin Watson ]
* Modern tar files typically use NormalFile1 rather than NormalFile0 for
diff --git a/lib/dpkg/dpkg.h b/lib/dpkg/dpkg.h
index d730923be..0c6eaa652 100644
--- a/lib/dpkg/dpkg.h
+++ b/lib/dpkg/dpkg.h
@@ -81,6 +81,7 @@ DPKG_BEGIN_DECLS
#define MAINTSCRIPTPKGENVVAR "DPKG_MAINTSCRIPT_PACKAGE"
#define MAINTSCRIPTARCHENVVAR "DPKG_MAINTSCRIPT_ARCH"
#define MAINTSCRIPTNAMEENVVAR "DPKG_MAINTSCRIPT_NAME"
+#define MAINTSCRIPTLIBDIRENVVAR "DPKG_LIBDIR"
#define MAINTSCRIPTDPKGENVVAR "DPKG_RUNNING_VERSION"
#define SHELLENV "SHELL"
diff --git a/man/dpkg.1 b/man/dpkg.1
index 1073be6e5..cbac66296 100644
--- a/man/dpkg.1
+++ b/man/dpkg.1
@@ -644,6 +644,10 @@ examine the situation. Contains the path to the new conffile.
Defined by \fBdpkg\fP on the maintainer script environment to the
version of the currently running \fBdpkg\fP instance.
.TP
+.B DPKG_LIBDIR
+Defined by \fBdpkg\fP on the maintainer script environment to the
+private library directory of the currently running \fBdpkg\fP instance.
+.TP
.B DPKG_MAINTSCRIPT_PACKAGE
Defined by \fBdpkg\fP on the maintainer script environment to the
package name being handled.
diff --git a/src/Makefile.am b/src/Makefile.am
index b3f2fe582..ddde846bb 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -6,6 +6,7 @@ pkgconfdir = $(sysconfdir)/@PACKAGE@
AM_CPPFLAGS = \
-DLOCALEDIR=\"$(localedir)\" \
-DADMINDIR=\"$(admindir)\" \
+ -DPKGLIBDIR=\"$(pkglibdir)\" \
-idirafter $(top_srcdir)/lib/compat \
-I$(top_builddir) \
-I$(top_srcdir)/lib
diff --git a/src/help.c b/src/help.c
index fb5ec9309..59bed9a8a 100644
--- a/src/help.c
+++ b/src/help.c
@@ -261,6 +261,7 @@ do_script(struct pkginfo *pkg, struct pkginfoperfile *pif,
if (setenv(MAINTSCRIPTPKGENVVAR, pkg->name, 1) ||
setenv(MAINTSCRIPTARCHENVVAR, pif->architecture, 1) ||
setenv(MAINTSCRIPTNAMEENVVAR, cmd->argv[0], 1) ||
+ setenv(MAINTSCRIPTLIBDIRENVVAR, PKGLIBDIR, 1) ||
setenv(MAINTSCRIPTDPKGENVVAR, PACKAGE_VERSION, 1))
ohshite(_("unable to setenv for maintainer script"));