2 # vim: ts=8 sw=8 nowrap
4 # General functions for scanning the BTS-database.
5 # Based on bugscan, written by Richard Braakman <dark@debian.org>,
6 # which was based on an unknown other script.
9 # %maintainer - map from packagename to maintainer
10 # %section - map from packagename to section in the FTP-site
11 # %packagelist - map from packagename to bugreports
16 use lib qw(/org/bugs.debian.org/perl);
18 use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522);
19 use Debbugs::Packages;
20 use Debbugs::Versions;
22 use IO::Uncompress::AnyUncompress;
23 use Fcntl qw(O_RDONLY);
26 use lib dirname(__FILE__);
31 our (%maintainer,%section,%packagelist,%debbugssection,%bugs);
34 # Read the list of maintainer
35 sub readmaintainers() {
36 my $pkg; # Name of package
37 my $mnt; # Maintainer name & email
39 open(M, $bugcfg::maintainerlist) or die "open $bugcfg::maintainerlist: $!\n";
42 m/^(\S+)\s+(\S.*\S)\s*$/ or die "Maintainers: $_ ?";
43 ($pkg, $mnt) = ($1, $2);
44 $pkg =~ y/A-Z/a-z/; # Normalize package-name. why???
47 $mnt="$2 <$1>" if ( m/(\S+)\s+\(([^)]+)\)/ );
49 $maintainer{$pkg}= $mnt;
54 sub glob_compressed_fh {
56 $fn = (grep { -f $_ } glob $fn)[0];
57 my $fh = IO::Uncompress::AnyUncompress->new($fn) or
58 die "Unable to open $fn for reading: $!";
64 my ($root,$archive) = @_;
66 for my $sect (@bugcfg::sections) {
67 my $p = glob_compressed_fh("$root/$sect/source/Sources.*");
70 next unless m/^Package:\s/;
71 s/^Package:\s*//; # Strip the fieldname
72 $section{$_} = "$archive/$sect";
79 my ($root,$archive) = @_;
80 for my $arch ( @bugcfg::architectures ) {
81 for my $sect ( @bugcfg::sections) {
82 my $p = glob_compressed_fh("$root/$sect/binary-$arch/Packages.*");
85 next unless m/^Package:\s/; # We're only interested in the packagenames
86 s/^Package:\s*//; # Strip the fieldname
87 $section{$_} = "$archive/$sect";
88 print "$root/$sect/binary-$arch/Packages.gz\n" if ($_ eq 'xtla');
93 # handle the source packages
94 for my $sect (@bugcfg::sections) {
95 my $fh = glob_compressed_fh("$root/$sect/source/Sources.*");
98 next unless m/^Package:\s/; # We're only interested in the packagenames
99 s/^Package:\s*//; # Strip the fieldname
100 $section{$_} = "$archive/$sect";
105 sub readdebbugssources {
106 my ($file,$archive) = @_;
109 or die "open: $file: $!\n";
112 my ($host, $bin, $sect, $ver, $src) = split /\s+/;
113 my $sectname = ($sect =~ /^\Q$archive/) ? $sect : "$archive/$sect";
114 $debbugssection{$bin} = $sectname;
115 $debbugssection{$src} = $sectname;
120 sub readpseudopackages() {
121 open(P, $bugcfg::pseudolist) or die("open $bugcfg::pseudolist: $!\n");
125 $section{$_} = "pseudo";
135 chdir($bugcfg::spooldir) or die "chdir $bugcfg::spooldir: $!\n";
137 opendir(DIR, $bugcfg::spooldir) or die "opendir $bugcfg::spooldir: $!\n";
138 @dirs=grep(m/^\d+$/,readdir(DIR));
142 scanspooldir("$bugcfg::spooldir/$dir");
149 my $f; # While we're currently processing
150 my @list; # List of files to process
151 my $skip; # Flow control
152 my $walk; # index variable
153 my $taginfo; # Tag info
155 my @archs_with_source = ( @bugcfg::architectures, 'source' );
157 chdir($dir) or die "chdir $dir: $!\n";
159 opendir(DIR, $dir) or die "opendir $dir: $!\n";
160 @list = grep { s/\.summary$// }
161 grep { m/^\d+\.summary$/ }
166 my $bug = Debbugs::Status::read_bug(summary => "$f.summary");
167 next if (!defined($bug));
171 subject => $bug->{'subject'},
172 package => $bug->{'package'}
176 for $walk (@bugcfg::priorities) {
177 $skip=0 if $walk eq $bug->{'severity'};
180 my @tags = split(' ', $bug->{'keywords'});
181 for my $tag (@tags) {
182 for my $s (@bugcfg::skiptags) {
183 $skip=1 if $tag eq $s;
189 for my $release (qw(oldstable stable testing unstable)) {
190 $disttags{$release} = grep(/^$bugcfg::debian_releases->{$release}$/, @tags);
192 $disttags{'experimental'} = grep(/^experimental$/, @tags);
194 # default according to vorlon 2007-06-17
195 if (!$disttags{'oldstable'} && !$disttags{'stable'} && !$disttags{'testing'} && !$disttags{'unstable'} && !$disttags{'experimental'}) {
196 $disttags{'stable'} = 1;
197 $disttags{'testing'} = 1;
198 $disttags{'unstable'} = 1;
199 $disttags{'experimental'} = 1;
202 if (defined($section{$bug->{'package'}}) && $section{$bug->{'package'}} eq 'pseudo') {
203 # versioning information makes no sense for pseudo packages,
205 for my $dist (qw(oldstable stable testing unstable experimental)) {
206 $bi->{$dist} = $disttags{$dist};
208 next if (length($bug->{'done'}));
212 # only bother to check the versioning status for the distributions indicated by the tags
213 for my $dist (qw(oldstable stable testing unstable experimental)) {
214 local $SIG{__WARN__} = sub {};
217 next if (!$disttags{$dist});
219 my $presence = Debbugs::Status::bug_presence(
223 arch => \@archs_with_source
226 # ignore bugs that are absent/fixed in this distribution, include everything
227 # else (that is, "found" which says that the bug is present, and undef, which
228 # indicates that no versioning information is present and it's not closed
230 if (!defined($presence) || ($presence ne 'absent' && $presence ne 'fixed')) {
236 next if !$affects_any;
239 for my $keyword (qw(pending patch help moreinfo unreproducible security upstream),
240 map {$bugcfg::debian_releases->{$_}.'-ignore'} keys %{$bugcfg::debian_releases}) {
241 $bi->{$keyword} = grep(/^$keyword$/, @tags);
244 if (length($bug->{'mergedwith'})) {
245 my @merged = split(' ', $bug->{'mergedwith'});
246 next if ($merged[0] < $f);
249 for my $package (split /[,\s]+/, $bug->{'package'}) {
250 $_= $package; y/A-Z/a-z/; $_= $` if m/[^-+._:a-z0-9]/;
251 push @{$packagelist{$_}}, $f;
254 my $taginfo = get_taginfo($bi);
255 my $relinfo = get_relinfo($bi);
263 my $filename = shift;
264 open STATUS, "<", $filename
265 or die "$filename: $!";
268 chomp (my $type = <STATUS>);
269 if ($type eq 'package') {
270 chomp (my $package = <STATUS>);
271 chomp (my $section = <STATUS>);
272 chomp (my $maintainer = <STATUS>);
273 my $blank = <STATUS>;
275 $section{$package} = $section;
276 $maintainer{$package} = $maintainer;
278 if ($type eq 'bug') {
282 last if ($line !~ /^(.*?)=(.*)$/);
286 $bugs{$bug->{'number'}} = $bug;
288 for my $package (split /[,\s]+/, $bug->{'package'}) {
289 $_= $package; y/A-Z/a-z/; $_= $` if m/[^-+._:a-z0-9]/;
290 push @{$packagelist{$_}}, $bug->{'number'};
293 last if ($type eq 'end');
303 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
304 $url =~ s/([<>&"])/\&$saniarray{$1};/g;
309 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
310 my $in = shift || "";
311 $in =~ s/([<>&"])/\&$saniarray{$1};/g;
316 my $number = shift; # Number of bug to html-ize
318 "<A HREF=\"http://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=" .
319 urlsanit($number) . '">' . htmlsanit($number) . '</A>';
323 my $name = shift; # Name of package
325 "<A HREF=\"http://bugs.debian.org/cgi-bin/pkgreport.cgi?archive=no&pkg=" .
326 urlsanit($name) . '">' . htmlsanit($name) . '</A>';
332 return ($bi->{'testing'} && !$bi->{$bugcfg::debian_releases->{testing}.'-ignore'});
335 sub check_worry_stable {
338 return ($bi->{'stable'} && !$bi->{$bugcfg::debian_releases->{stable}.'-ignore'});
341 sub check_worry_unstable {
344 return ($bi->{'unstable'});
351 $taginfo .= $bi->{'pending'} ? "P" : " ";
352 $taginfo .= $bi->{'patch'} ? "+" : " ";
353 $taginfo .= $bi->{'help'} ? "H" : " ";
354 $taginfo .= $bi->{'moreinfo'} ? "M" : " ";
355 $taginfo .= $bi->{'unreproducible'} ? "R" : " ";
356 $taginfo .= $bi->{'security'} ? "S" : " ";
357 $taginfo .= $bi->{'upstream'} ? "U" : " ";
358 $taginfo .= ($bi->{$bugcfg::debian_releases->{stable}.'-ignore'} || $bi->{$bugcfg::debian_releases->{testing}.'-ignore'}) ? "I" : " ";
367 for my $dist (qw(oldstable stable testing unstable experimental)) {
368 $relinfo .= uc(substr($dist, 0, 1)) if $bi->{$dist};