瀏覽代碼

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.
Raphaël Hertzog 16 年之前
父節點
當前提交
d5b15f56fb
共有 5 個文件被更改,包括 10 次插入0 次删除
  1. 3 0
      debian/changelog
  2. 1 0
      lib/dpkg/dpkg.h
  3. 4 0
      man/dpkg.1
  4. 1 0
      src/Makefile.am
  5. 1 0
      src/help.c

+ 3 - 0
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

+ 1 - 0
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"

+ 4 - 0
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.

+ 1 - 0
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

+ 1 - 0
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"));