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
13 use lib qw(/org/bugs.debian.org/perl);
15 use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522);
16 use Debbugs::Packages;
17 use Debbugs::Versions;
19 use Fcntl qw(O_RDONLY);
25 our (%maintainer,%section,%packagelist,%debbugssection,%bugs);
28 # Read the list of maintainer
29 sub readmaintainers() {
30 my $pkg; # Name of package
31 my $mnt; # Maintainer name & email
33 open(M, $bugcfg::maintainerlist) or die "open $bugcfg::maintainerlist: $!\n";
36 m/^(\S+)\s+(\S.*\S)\s*$/ or die "Maintainers: $_ ?";
37 ($pkg, $mnt) = ($1, $2);
38 $pkg =~ y/A-Z/a-z/; # Normalize package-name. why???
41 $mnt="$2 <$1>" if ( m/(\S+)\s+\(([^)]+)\)/ );
43 $maintainer{$pkg}= $mnt;
50 my $root; # Root of archive we are scanning
51 my $archive; # Name of archive we are scanning
52 my $sect; # Name of current section
56 for $sect (@bugcfg::sections) {
57 open(P, "zcat $root/$sect/source/Sources.gz|")
58 or die open "open: $sect sourcelist: $!\n";
61 next unless m/^Package:\s/;
62 s/^Package:\s*//; # Strip the fieldname
63 $section{$_} = "$archive/$sect";
70 my ($root,$archive) = @_;
71 for my $arch ( @bugcfg::architectures ) {
72 for my $sect ( @bugcfg::sections) {
73 open(P, "zcat $root/$sect/binary-$arch/Packages.gz|")
74 or die "open: $root/$sect/binary-$arch/Packages.gz: $!\n";
77 next unless m/^Package:\s/; # We're only interested in the packagenames
78 s/^Package:\s*//; # Strip the fieldname
79 $section{$_} = "$archive/$sect";
80 print "$root/$sect/binary-$arch/Packages.gz\n" if ($_ eq 'xtla');
85 # handle the source packages
86 for my $sect (@bugcfg::sections) {
88 open($fh,'-|','zcat',"$root/$sect/source/Sources.gz") or
89 die "Unable to open zcat $root/$sect/source/Sources.gz for reading: $!";
92 next unless m/^Package:\s/; # We're only interested in the packagenames
93 s/^Package:\s*//; # Strip the fieldname
94 $section{$_} = "$archive/$sect";
99 sub readdebbugssources() {
106 or die "open: $file: $!\n";
109 my ($host, $bin, $sect, $ver, $src) = split /\s+/;
110 my $sectname = ($sect =~ /^\Q$archive/) ? $sect : "$archive/$sect";
111 $debbugssection{$bin} = $sectname;
112 $debbugssection{$src} = $sectname;
117 sub readpseudopackages() {
118 open(P, $bugcfg::pseudolist) or die("open $bugcfg::pseudolist: $!\n");
122 $section{$_} = "pseudo";
132 chdir($bugcfg::spooldir) or die "chdir $bugcfg::spooldir: $!\n";
134 opendir(DIR, $bugcfg::spooldir) or die "opendir $bugcfg::spooldir: $!\n";
135 @dirs=grep(m/^\d+$/,readdir(DIR));
139 scanspooldir("$bugcfg::spooldir/$dir");
146 my $f; # While we're currently processing
147 my @list; # List of files to process
148 my $skip; # Flow control
149 my $walk; # index variable
150 my $taginfo; # Tag info
152 my @archs_with_source = ( @bugcfg::architectures, 'source' );
154 chdir($dir) or die "chdir $dir: $!\n";
156 opendir(DIR, $dir) or die "opendir $dir: $!\n";
157 @list = grep { s/\.summary$// }
158 grep { m/^\d+\.summary$/ }
163 my $bug = Debbugs::Status::read_bug(summary => "$f.summary");
164 next if (!defined($bug));
168 subject => $bug->{'subject'},
169 package => $bug->{'package'}
173 for $walk (@bugcfg::priorities) {
174 $skip=0 if $walk eq $bug->{'severity'};
177 my @tags = split(' ', $bug->{'keywords'});
178 for my $tag (@tags) {
179 for my $s (@bugcfg::skiptags) {
180 $skip=1 if $tag eq $s;
186 $disttags{'oldstable'} = grep(/^etch$/, @tags);
187 $disttags{'stable'} = grep(/^lenny$/, @tags);
188 $disttags{'testing'} = grep(/^squeeze$/, @tags);
189 $disttags{'unstable'} = grep(/^sid$/, @tags);
190 $disttags{'experimental'} = grep(/^experimental$/, @tags);
192 # default according to vorlon 2007-06-17
193 if (!$disttags{'oldstable'} && !$disttags{'stable'} && !$disttags{'testing'} && !$disttags{'unstable'} && !$disttags{'experimental'}) {
194 $disttags{'stable'} = 1;
195 $disttags{'testing'} = 1;
196 $disttags{'unstable'} = 1;
197 $disttags{'experimental'} = 1;
200 if (defined($section{$bug->{'package'}}) && $section{$bug->{'package'}} eq 'pseudo') {
201 # versioning information makes no sense for pseudo packages,
203 for my $dist qw(oldstable stable testing unstable experimental) {
204 $bi->{$dist} = $disttags{$dist};
206 next if (length($bug->{'done'}));
210 # only bother to check the versioning status for the distributions indicated by the tags
211 for my $dist qw(oldstable stable testing unstable experimental) {
212 local $SIG{__WARN__} = sub {};
215 next if (!$disttags{$dist});
217 my $presence = Debbugs::Status::bug_presence(
221 arch => \@archs_with_source
224 # ignore bugs that are absent/fixed in this distribution, include everything
225 # else (that is, "found" which says that the bug is present, and undef, which
226 # indicates that no versioning information is present and it's not closed
228 if (!defined($presence) || ($presence ne 'absent' && $presence ne 'fixed')) {
234 next if !$affects_any;
237 for my $keyword qw(pending patch help moreinfo unreproducible security upstream etch-ignore lenny-ignore squeeze-ignore) {
238 $bi->{$keyword} = grep(/^$keyword$/, @tags);
241 if (length($bug->{'mergedwith'})) {
242 my @merged = split(' ', $bug->{'mergedwith'});
243 next if ($merged[0] < $f);
246 for my $package (split /[,\s]+/, $bug->{'package'}) {
247 $_= $package; y/A-Z/a-z/; $_= $` if m/[^-+._:a-z0-9]/;
248 push @{$packagelist{$_}}, $f;
251 my $taginfo = get_taginfo($bi);
252 my $relinfo = get_relinfo($bi);
260 my $filename = shift;
261 open STATUS, "<", $filename
262 or die "$filename: $!";
265 chomp (my $type = <STATUS>);
266 if ($type eq 'package') {
267 chomp (my $package = <STATUS>);
268 chomp (my $section = <STATUS>);
269 chomp (my $maintainer = <STATUS>);
270 my $blank = <STATUS>;
272 $section{$package} = $section;
273 $maintainer{$package} = $maintainer;
275 if ($type eq 'bug') {
279 last if ($line !~ /^(.*?)=(.*)$/);
283 $bugs{$bug->{'number'}} = $bug;
285 for my $package (split /[,\s]+/, $bug->{'package'}) {
286 $_= $package; y/A-Z/a-z/; $_= $` if m/[^-+._:a-z0-9]/;
287 push @{$packagelist{$_}}, $bug->{'number'};
290 last if ($type eq 'end');
300 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
301 $url =~ s/([<>&"])/\&$saniarray{$1};/g;
306 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
307 my $in = shift || "";
308 $in =~ s/([<>&"])/\&$saniarray{$1};/g;
313 my $number = shift; # Number of bug to html-ize
315 "<A HREF=\"http://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=" .
316 urlsanit($number) . '">' . htmlsanit($number) . '</A>';
320 my $name = shift; # Name of package
322 "<A HREF=\"http://bugs.debian.org/cgi-bin/pkgreport.cgi?archive=no&pkg=" .
323 urlsanit($name) . '">' . htmlsanit($name) . '</A>';
329 return ($bi->{'testing'} && !$bi->{'squeeze-ignore'});
332 sub check_worry_stable {
335 return ($bi->{'stable'} && !$bi->{'lenny-ignore'});
338 sub check_worry_unstable {
341 return ($bi->{'unstable'});
348 $taginfo .= $bi->{'pending'} ? "P" : " ";
349 $taginfo .= $bi->{'patch'} ? "+" : " ";
350 $taginfo .= $bi->{'help'} ? "H" : " ";
351 $taginfo .= $bi->{'moreinfo'} ? "M" : " ";
352 $taginfo .= $bi->{'unreproducible'} ? "R" : " ";
353 $taginfo .= $bi->{'security'} ? "S" : " ";
354 $taginfo .= $bi->{'upstream'} ? "U" : " ";
355 $taginfo .= ($bi->{'lenny-ignore'} || $bi->{'squeeze-ignore'}) ? "I" : " ";
364 for my $dist qw(oldstable stable testing unstable experimental) {
365 $relinfo .= uc(substr($dist, 0, 1)) if $bi->{$dist};