Просмотр исходного кода

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
Родитель
Сommit
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
   * dpkg now exports DPKG_MAINTSCRIPT_NAME to maintainer scripts with the
     type of maintainer script currently running (preinst, postinst, prerm,
     type of maintainer script currently running (preinst, postinst, prerm,
     postrm). Closes: #546577
     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 ]
   [ Colin Watson ]
   * Modern tar files typically use NormalFile1 rather than NormalFile0 for
   * 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 MAINTSCRIPTPKGENVVAR "DPKG_MAINTSCRIPT_PACKAGE"
 #define MAINTSCRIPTARCHENVVAR "DPKG_MAINTSCRIPT_ARCH"
 #define MAINTSCRIPTARCHENVVAR "DPKG_MAINTSCRIPT_ARCH"
 #define MAINTSCRIPTNAMEENVVAR "DPKG_MAINTSCRIPT_NAME"
 #define MAINTSCRIPTNAMEENVVAR "DPKG_MAINTSCRIPT_NAME"
+#define MAINTSCRIPTLIBDIRENVVAR "DPKG_LIBDIR"
 #define MAINTSCRIPTDPKGENVVAR "DPKG_RUNNING_VERSION"
 #define MAINTSCRIPTDPKGENVVAR "DPKG_RUNNING_VERSION"
 
 
 #define SHELLENV            "SHELL"
 #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
 Defined by \fBdpkg\fP on the maintainer script environment to the
 version of the currently running \fBdpkg\fP instance.
 version of the currently running \fBdpkg\fP instance.
 .TP
 .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
 .B DPKG_MAINTSCRIPT_PACKAGE
 Defined by \fBdpkg\fP on the maintainer script environment to the
 Defined by \fBdpkg\fP on the maintainer script environment to the
 package name being handled.
 package name being handled.

+ 1 - 0
src/Makefile.am

@@ -6,6 +6,7 @@ pkgconfdir = $(sysconfdir)/@PACKAGE@
 AM_CPPFLAGS = \
 AM_CPPFLAGS = \
 	-DLOCALEDIR=\"$(localedir)\" \
 	-DLOCALEDIR=\"$(localedir)\" \
 	-DADMINDIR=\"$(admindir)\" \
 	-DADMINDIR=\"$(admindir)\" \
+	-DPKGLIBDIR=\"$(pkglibdir)\" \
 	-idirafter $(top_srcdir)/lib/compat \
 	-idirafter $(top_srcdir)/lib/compat \
 	-I$(top_builddir) \
 	-I$(top_builddir) \
 	-I$(top_srcdir)/lib
 	-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) ||
     if (setenv(MAINTSCRIPTPKGENVVAR, pkg->name, 1) ||
         setenv(MAINTSCRIPTARCHENVVAR, pif->architecture, 1) ||
         setenv(MAINTSCRIPTARCHENVVAR, pif->architecture, 1) ||
         setenv(MAINTSCRIPTNAMEENVVAR, cmd->argv[0], 1) ||
         setenv(MAINTSCRIPTNAMEENVVAR, cmd->argv[0], 1) ||
+        setenv(MAINTSCRIPTLIBDIRENVVAR, PKGLIBDIR, 1) ||
         setenv(MAINTSCRIPTDPKGENVVAR, PACKAGE_VERSION, 1))
         setenv(MAINTSCRIPTDPKGENVVAR, PACKAGE_VERSION, 1))
       ohshite(_("unable to setenv for maintainer script"));
       ohshite(_("unable to setenv for maintainer script"));