From: Timothy G Abbott Date: Mon, 23 Jun 2008 17:57:08 +0000 (+0200) Subject: dpkg-divert: new --listpackage option X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f3382f0a8b56d0043965fa51e767a9ca1ee4f569;p=dpkg dpkg-divert: new --listpackage option * scripts/dpkg-divert.pl: Add new option --listpackage to dpkg-divert. * man/dpkg-divert.1: Document new option. --- diff --git a/ChangeLog b/ChangeLog index 7ee4edeb..143f9786 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-06-23 Timothy G Abbott + + * scripts/dpkg-divert.pl: Add new option --listpackage to + dpkg-divert. + * man/dpkg-divert.1: Document new option. + 2008-06-22 Raphael Hertzog * man/dpkg.1, man/dpkg-query.1: Clarify lisf of packages displayed diff --git a/THANKS b/THANKS index 096a3442..31726197 100644 --- a/THANKS +++ b/THANKS @@ -159,6 +159,7 @@ Steve Langasek Sven Joachim Sven Rudolph Thomas Morin +Timothy G Abbott Tom Lees Tomas Pospisek Topi Miettinen diff --git a/debian/changelog b/debian/changelog index 6181ab1d..f4f27ced 100644 --- a/debian/changelog +++ b/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 + for the patch. Closes: #485012 [ Pierre Habouzit ] * Add a --query option to update-alternatives. Closes: #336091, #441904 diff --git a/man/dpkg-divert.8 b/man/dpkg-divert.8 index 2e9662ff..93f59114 100644 --- a/man/dpkg-divert.8 +++ b/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. . diff --git a/scripts/dpkg-divert.pl b/scripts/dpkg-divert.pl index ffc22bc0..1696ed73 100755 --- a/scripts/dpkg-divert.pl +++ b/scripts/dpkg-divert.pl @@ -34,6 +34,7 @@ Commands: [--add] add a diversion. --remove remove the diversion. --list [] show file diversions. + --listpackage show what package diverts the file. --truename 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)); }