1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193
|
#!/usr/bin/perl -w
#
# dd-list: Generate a list of maintainers of packages.
#
# Written by Joey Hess <joeyh@debian.org>
# Based on a python implementation by Lars Wirzenius.
# Copyright 2005 Lars Wirzenius, Joey Hess
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
use strict;
use Getopt::Long;
my $version='###VERSION###';
sub get_developers_given_package {
my ($package_name,$print_binary) = @_;
my $developer;
my $print_name;
my $uploaders;
my @uploaders;
open (F, "apt-cache showsrc '$package_name' |");
while (<F>) {
chomp;
if (/^Maintainer: (.*)/) {
$developer=$1;
}
elsif (/^Uploaders: (.*)/) {
$uploaders=$1;
@uploaders = split /\s*,\s*/, $uploaders;
}
elsif (/^Package: (.*)/) {
$print_name = $print_binary ? $package_name : $1 ;
}
}
close F;
return ($developer, \@uploaders, $print_name);
}
sub parse_developer {
my $developer=shift;
my ($name, $domain) = $developer=~/^(.*)\s+<.*@(.*)>\s*$/i;
if (defined $domain && $domain !~ /^(lists(\.alioth)?\.debian\.org|teams\.debian\.net)$/) {
return join " ", reverse split " ", $name;
}
elsif (defined $name) {
return $name;
}
else {
return $developer;
}
}
sub sort_developers {
sort { uc(parse_developer($a)) cmp uc(parse_developer($b)) } @_;
}
sub help {
print <<"EOF"
Usage: dd-list [options] [package ...]
-h, --help
Print this help text.
-i, --stdin
Read package names from the standard input.
-d, --dctrl
Read package list in Debian control data from standard input.
-u, --uploaders
Also list Uploaders of packages, not only the listed Maintainers
(this is the default behaviour, use --nouploaders to prevent this).
-nou, --nouploaders
Only list package Maintainers, do not list Uploaders.
-b, --print-binary
If binary package names are given as input, print these names
in the output instead of corresponding source packages.
-V, --version
Print version (it\'s $version by the way).
EOF
}
my $use_stdin=0;
my $use_dctrl=0;
my $show_uploaders=1;
my $print_binary=0;
if (! GetOptions(
"help" => sub { help(); exit },
"stdin|i" => \$use_stdin,
"dctrl|d" => \$use_dctrl,
"uploaders|u!" => \$show_uploaders,
"print-binary|b" => \$print_binary,
"version" => sub { print "dd-list version $version\n" })) {
exit(1);
}
my %dict;
my $errors=0;
if ($use_dctrl) {
local $/="\n\n";
while (<>) {
my ($package, $maintainer, $uploaders, @uploaders);
if (/^Package:\s+(.*)$/m) {
$package=$1;
}
if (/^Source:\s+(.*)$/m && ! $print_binary ) {
$package=$1;
}
if (/^Maintainer:\s+(.*)$/m) {
$maintainer=$1;
}
if (/^Uploaders:\s+(.*)$/m) {
$uploaders=$1;
@uploaders = split /\s*,\s*/, $uploaders;
}
if (defined $maintainer && defined $package) {
push @{$dict{$maintainer}}, $package;
if ($show_uploaders && defined $uploaders) {
foreach my $uploader (@uploaders) {
push @{$dict{$uploader}}, "$package (U)";
}
}
}
else {
print STDERR "E: parse error in stanza $.\n";
$errors=1;
}
}
}
else {
my @package_names;
if ($use_stdin) {
while (<>) {
chomp;
s/^\s+//;
s/\s+$//;
push @package_names, split ' ', $_;
}
}
else {
@package_names=@ARGV;
}
foreach my $package_name (@package_names) {
my ($developer, $uploaders, $print_name)=get_developers_given_package($package_name,$print_binary);
if (defined $developer) {
push @{$dict{$developer}}, $print_name;
if ($show_uploaders && @$uploaders) {
foreach my $uploader (@$uploaders) {
push @{$dict{$uploader}}, "$print_name (U)";
}
}
}
else {
print STDERR "E: Unknown package: $package_name\n";
$errors=1;
}
}
}
foreach my $developer (sort_developers(keys %dict)) {
print "$developer\n";
my %seen;
foreach my $package (sort @{$dict{$developer}}) {
next if $seen{$package};
$seen{$package}=1;
print " $package\n";
}
print "\n";
}
exit($errors);
|