Bläddra i källkod

dpkg-divert: Use DPKG_MAINTSCRIPT_PACKAGE environment variable

Use it as package name on when no --package or --local options have
been specified.
Guillem Jover 15 år sedan
förälder
incheckning
dc98261980
3 ändrade filer med 14 tillägg och 1 borttagningar
  1. 2 0
      debian/changelog
  2. 7 1
      man/dpkg-divert.8
  3. 5 0
      src/divertcmd.c

+ 2 - 0
debian/changelog

@@ -2,6 +2,8 @@ dpkg (1.16.0) UNRELEASED; urgency=low
 
   [ Guillem Jover ]
   * Fix realloc usage on compat scandir() implementation.
+  * Use DPKG_MAINTSCRIPT_PACKAGE environment variable as package name on
+    dpkg-divert when no --package or --local options have been specified.
 
   [ Raphaël Hertzog ]
   * Fail properly when debian/source/format is empty. Closes: #600854

+ 7 - 1
man/dpkg-divert.8

@@ -1,4 +1,4 @@
-.TH dpkg\-divert 8 "2008-08-18" "Debian Project" "dpkg utilities"
+.TH dpkg\-divert 8 "2010-10-12" "Debian Project" "dpkg utilities"
 .SH NAME
 dpkg\-divert \- override a package's version of a file
 .
@@ -109,6 +109,12 @@ To remove that diversion:
 .HP
 dpkg-divert \-\-package wibble \-\-rename \-\-remove /usr/bin/example
 .
+.SH ENVIRONMENT
+.TP
+.B DPKG_MAINTSCRIPT_PACKAGE
+If set and the \fI\-\-local\fP and \fI\-\-package\fP options have not been
+specified, \fBdpkg\-divert\fP will use it as the package name.
+.
 .SH FILES
 .TP
 .I /var/lib/dpkg/diversions

+ 5 - 0
src/divertcmd.c

@@ -705,6 +705,7 @@ int
 main(int argc, const char * const *argv)
 {
 	jmp_buf ejbuf;
+	const char *env_pkgname;
 	int (*actionfunction)(const char *const *argv);
 	int ret;
 
@@ -715,6 +716,10 @@ main(int argc, const char * const *argv)
 	standard_startup(&ejbuf);
 	myopt(&argv, cmdinfos);
 
+	env_pkgname = getenv(MAINTSCRIPTPKGENVVAR);
+	if (!opt_pkgname && env_pkgname)
+		setpackage(NULL, env_pkgname);
+
 	if (!cipaction)
 		setaction(&cmdinfo_add, NULL);