Kaynağa Gözat

dpkg-divert: new --listpackage option

* scripts/dpkg-divert.pl: Add new option --listpackage to
dpkg-divert.
* man/dpkg-divert.1: Document new option.
Timothy G Abbott 18 yıl önce
ebeveyn
işleme
f3382f0a8b
5 değiştirilmiş dosya ile 32 ekleme ve 0 silme
  1. 6 0
      ChangeLog
  2. 1 0
      THANKS
  3. 2 0
      debian/changelog
  4. 4 0
      man/dpkg-divert.8
  5. 19 0
      scripts/dpkg-divert.pl

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2008-06-23  Timothy G Abbott  <tabbott@MIT.EDU>
+
+	* scripts/dpkg-divert.pl: Add new option --listpackage to
+	dpkg-divert.
+	* man/dpkg-divert.1: Document new option.
+
 2008-06-22  Raphael Hertzog  <hertzog@debian.org>
 
 	* man/dpkg.1, man/dpkg-query.1: Clarify lisf of packages displayed

+ 1 - 0
THANKS

@@ -159,6 +159,7 @@ Steve Langasek <vorlon@debian.org>
 Sven Joachim <svenjoac@gmx.de>
 Sven Rudolph <sr1@loom.sax.de>
 Thomas Morin <thomas.morin@enst-bretagne.fr>
+Timothy G Abbott <tabbott@MIT.EDU>
 Tom Lees <tom@lpsg.demon.co.uk>
 Tomas Pospisek <tpo_deb@sourcepole.ch>
 Topi Miettinen <Topi.Miettinen@nic.fi>

+ 2 - 0
debian/changelog

@@ -51,6 +51,8 @@ dpkg (1.15.0) UNRELEASED; urgency=low
   * Document -A option in dpkg-buildpackage(1). Closes: #482834
   * Add some warning concerning the available file and the related commands.
     They are mostly obsolete for APT users. Closes: #481185
+  * Add new option --listpackage to dpkg-divert. Thanks to Timothy G Abbott
+    <tabbott@MIT.EDU> for the patch. Closes: #485012
 
   [ Pierre Habouzit ]
   * Add a --query option to update-alternatives. Closes: #336091, #441904

+ 4 - 0
man/dpkg-divert.8

@@ -32,6 +32,10 @@ Remove a diversion for \fIfile\fP.
 .BI \-\-list " glob-pattern"
 List diversions matching \fIglob-pattern\fP.
 .TP
+.BI \-\-listpackage " file"
+Print the name of the package that diverts \fIfile\fP.  Prints LOCAL if
+\fIfile\fP is locally diverted and nothing if \fIfile\fP is not diverted.
+.TP
 .BI \-\-truename " file"
 Print the real name for a diverted file.
 .

+ 19 - 0
scripts/dpkg-divert.pl

@@ -34,6 +34,7 @@ Commands:
   [--add] <file>           add a diversion.
   --remove <file>          remove the diversion.
   --list [<glob-pattern>]  show file diversions.
+  --listpackage <file>     show what package diverts the file.
   --truename <file>        return the diverted file.
 
 Options:
@@ -102,6 +103,9 @@ while (@ARGV) {
     } elsif (m/^--list$/) {
         &checkmanymodes;
         $mode= 'list';
+    } elsif (m/^--listpackage$/) {
+        &checkmanymodes;
+        $mode= 'listpackage';
     } elsif (m/^--truename$/) {
         &checkmanymodes;
         $mode= 'truename';
@@ -213,6 +217,21 @@ if ($mode eq 'add') {
     }
     print $file, "\n";
     exit(0);
+} elsif ($mode eq 'listpackage') {
+    @ARGV == 1 || &badusage(sprintf(_g("--%s needs a single argument"), $mode));
+    $file= $ARGV[0];
+    for (my $i = 0; $i <= $#contest; $i++) {
+	next unless $file eq $contest[$i];
+	if ($package[$i] eq ':') {
+	    # indicate package is local using something not in package namespace
+	    print "LOCAL\n";
+	} else {
+	    print $package[$i], "\n";
+	}
+	exit(0);
+    }
+    # print nothing if file is not diverted
+    exit(0);
 } else {
     &quit(sprintf(_g("internal error - bad mode \`%s'"), $mode));
 }