3 # dd-list: Generate a list of maintainers of packages.
5 # Written by Joey Hess <joeyh@debian.org>
6 # Based on a python implementation by Lars Wirzenius.
7 # Copyright 2005 Lars Wirzenius, Joey Hess
9 # This program is free software; you can redistribute it and/or modify
10 # it under the terms of the GNU General Public License as published by
11 # the Free Software Foundation; either version 2 of the License, or
12 # (at your option) any later version.
14 # This program is distributed in the hope that it will be useful,
15 # but WITHOUT ANY WARRANTY; without even the implied warranty of
16 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 # GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License
20 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 my $version='###VERSION###';
27 sub get_developers_given_package {
28 my ($package_name,$print_binary) = @_;
34 open (F, "apt-cache showsrc '$package_name' |");
37 if (/^Maintainer: (.*)/) {
40 elsif (/^Uploaders: (.*)/) {
42 @uploaders = split /\s*,\s*/, $uploaders;
45 elsif (/^Package: (.*)/) {
46 $print_name = $print_binary ? $package_name : $1 ;
50 return ($developer, \@uploaders, $print_name);
56 my ($name, $domain) = $developer=~/^(.*)\s+<.*@(.*)>\s*$/i;
57 if (defined $domain && $domain !~ /^(lists(\.alioth)?\.debian\.org|teams\.debian\.net)$/) {
58 return join " ", reverse split " ", $name;
60 elsif (defined $name) {
69 sort { uc(parse_developer($a)) cmp uc(parse_developer($b)) } @_;
74 Usage: dd-list [options] [package ...]
80 Read package names from the standard input.
83 Read package list in Debian control data from standard input.
86 Also list Uploaders of packages, not only the listed Maintainers
87 (this is the default behaviour, use --nouploaders to prevent this).
90 Only list package Maintainers, do not list Uploaders.
93 If binary package names are given as input, print these names
94 in the output instead of corresponding source packages.
97 Print version (it\'s $version by the way).
103 my $show_uploaders=1;
106 "help" => sub { help(); exit },
107 "stdin|i" => \$use_stdin,
108 "dctrl|d" => \$use_dctrl,
109 "uploaders|u!" => \$show_uploaders,
110 "print-binary|b" => \$print_binary,
111 "version" => sub { print "dd-list version $version\n" })) {
121 my ($package, $maintainer, $uploaders, @uploaders);
123 if (/^Package:\s+(.*)$/m) {
126 if (/^Source:\s+(.*)$/m && ! $print_binary ) {
129 if (/^Maintainer:\s+(.*)$/m) {
132 if (/^Uploaders:\s+(.*)$/m) {
134 @uploaders = split /\s*,\s*/, $uploaders;
137 if (defined $maintainer && defined $package) {
138 push @{$dict{$maintainer}}, $package;
139 if ($show_uploaders && defined $uploaders) {
140 foreach my $uploader (@uploaders) {
141 push @{$dict{$uploader}}, "$package (U)";
146 print STDERR "E: parse error in stanza $.\n";
158 push @package_names, split ' ', $_;
162 @package_names=@ARGV;
165 foreach my $package_name (@package_names) {
166 my ($developer, $uploaders, $print_name)=get_developers_given_package($package_name,$print_binary);
167 if (defined $developer) {
168 push @{$dict{$developer}}, $print_name;
169 if ($show_uploaders && @$uploaders) {
170 foreach my $uploader (@$uploaders) {
171 push @{$dict{$uploader}}, "$print_name (U)";
176 print STDERR "E: Unknown package: $package_name\n";
182 foreach my $developer (sort_developers(keys %dict)) {
183 print "$developer\n";
185 foreach my $package (sort @{$dict{$developer}}) {
186 next if $seen{$package};