2 # vim: ts=4 sw=4 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 # %premature - list of prematurely closed bugreports
10 # %exclude - list of bugreports to exclude from the report
11 # %maintainer - map from packagename to maintainer
12 # %section - map from packagename to section in the FTP-site
13 # %packagelist - map from packagename to bugreports
15 use lib qw(/org/bugs.debian.org/perl);
17 use Debbugs::MIME qw(decode_rfc1522 encode_rfc1522);
18 use Debbugs::Packages;
19 use Debbugs::Versions;
21 use Fcntl qw(O_RDONLY);
27 our (%premature,%exclude,%maintainer,%section,%packagelist,%debbugssection,%bugs);
30 # Read the list of maintainer
31 sub readmaintainers() {
32 my $pkg; # Name of package
33 my $mnt; # Maintainer name & email
35 open(M, $bugcfg::maintainerlist) or die "open $bugcfg::maintainerlist: $!\n";
38 m/^(\S+)\s+(\S.*\S)\s*$/ or die "Maintainers: $_ ?";
39 ($pkg, $mnt) = ($1, $2);
40 $pkg =~ y/A-Z/a-z/; # Normalize package-name. why???
43 $mnt="$2 <$1>" if ( m/(\S+)\s+\(([^)]+)\)/ );
45 $maintainer{$pkg}= $mnt;
52 my $root; # Root of archive we are scanning
53 my $archive; # Name of archive we are scanning
54 my $sect; # Name of current section
58 for $sect (@bugcfg::sections) {
59 open(P, "zcat $root/$sect/source/Sources.gz|")
60 or die open "open: $sect sourcelist: $!\n";
63 next unless m/^Package:\s/;
64 s/^Package:\s*//; # Strip the fieldname
65 $section{$_} = "$archive/$sect";
72 my $root; # Root of archive we are scanning
73 my $archive; # Name of archive we are scanning
74 my $sect; # Name of current section
75 my $arch; # Name of current architecture
79 for $arch ( @bugcfg::architectures ) {
80 for $sect ( @bugcfg::sections) {
81 open(P, "zcat $root/$sect/binary-$arch/Packages.gz|")
82 or die "open: $root/$sect/binary-$arch/Packages.gz: $!\n";
85 next unless m/^Package:\s/; # We're only interested in the packagenames
86 s/^Package:\s*//; # Strip the fieldname
87 $section{$_} = "$archive/$sect";
94 sub readdebbugssources() {
101 or die "open: $file: $!\n";
104 my ($host, $bin, $sect, $ver, $src) = split /\s+/;
105 my $sectname = ($sect =~ /^\Q$archive/) ? $sect : "$archive/$sect";
106 $debbugssection{$bin} = $sectname;
107 $debbugssection{$src} = $sectname;
112 sub readpseudopackages() {
113 open(P, $bugcfg::pseudolist) or die("open $bugcfg::pseudolist: $!\n");
117 $section{$_} = "pseudo";
127 chdir($bugcfg::spooldir) or die "chdir $bugcfg::spooldir: $!\n";
129 opendir(DIR, $bugcfg::spooldir) or die "opendir $bugcfg::spooldir: $!\n";
130 @dirs=grep(m/^\d+$/,readdir(DIR));
134 scanspooldir("$bugcfg::spooldir/$dir");
141 my $f; # While we're currently processing
142 my @list; # List of files to process
143 my $skip; # Flow control
144 my $walk; # index variable
145 my $taginfo; # Tag info
147 chdir($dir) or die "chdir $dir: $!\n";
149 opendir(DIR, $dir) or die "opendir $dir: $!\n";
150 @list = grep { s/\.summary$// }
151 grep { m/^\d+\.summary$/ }
156 next if $exclude{$f}; # Check the list of bugs to skip
158 my $bug = Debbugs::Status::read_bug(summary => "$f.summary");
159 next if (!defined($bug));
162 for $walk (@bugcfg::priorities) {
163 $skip=0 if $walk eq $bug->{'severity'};
166 my @tags = split(' ', $bug->{'keywords'});
167 for my $tag (@tags) {
168 for my $s (@bugcfg::skiptags) {
169 $skip=1 if $tag eq $s;
175 $disttags{'oldstable'} = grep(/^woody$/, @tags);
176 $disttags{'stable'} = grep(/^sarge$/, @tags);
177 $disttags{'testing'} = grep(/^etch$/, @tags);
178 $disttags{'unstable'} = grep(/^sid$/, @tags);
179 $disttags{'experimental'} = grep(/^experimental$/, @tags);
181 # default according to dondelelcaro 2006-11-11
182 if (!$disttags{'oldstable'} && !$disttags{'stable'} && !$disttags{'testing'} && !$disttags{'unstable'} && !$disttags{'experimental'}) {
183 $disttags{'testing'} = 1;
184 $disttags{'unstable'} = 1;
185 $disttags{'experimental'} = 1;
189 if (defined($section{$bug->{'package'}}) && $section{$bug->{'package'}} eq 'pseudo') {
190 # versioning information makes no sense for pseudo packages,
192 for my $dist qw(oldstable stable testing unstable experimental) {
193 $bi->{$dist} = $disttags{$dist};
195 next if (length($bug->{'done'}));
199 # only bother to check the versioning status for the distributions indicated by the tags
200 for my $dist qw(oldstable stable testing unstable experimental) {
201 local $SIG{__WARN__} = sub {};
204 next if (!$disttags{$dist});
206 my $presence = Debbugs::Status::bug_presence(
210 arch => \@bugcfg::architectures
213 # ignore bugs that are absent/fixed in this distribution, include everything
214 # else (that is, "found" which says that the bug is present, and undef, which
215 # indicates that no versioning information is present and it's not closed
217 if (!defined($presence) || ($presence ne 'absent' && $presence ne 'fixed')) {
223 next if !$affects_any and not $premature{$f};
224 $premature{$f}++ if !$affects_any;
227 for my $keyword qw(pending patch help moreinfo unreproducible security upstream etch-ignore) {
228 $bi->{$keyword} = ($bug->{'keywords'} =~ /\b$keyword\b/) ? 1 : 0;
231 if (length($bug->{'mergedwith'})) {
232 my @merged = split(' ', $bug->{'mergedwith'});
233 next if ($merged[0] < $f);
236 for my $package (split /[,\s]+/, $bug->{'package'}) {
237 $_= $package; y/A-Z/a-z/; $_= $` if m/[^-+._a-z0-9]/;
238 push @{$packagelist{$_}}, $f;
241 my $taginfo = get_taginfo($bi);
242 my $relinfo = get_relinfo($bi);
244 $bugs{$f} = "$f [$taginfo] [$relinfo] " . $bug->{'subject'};
250 my $bug; # Number of current bug
251 my $subject; # Subject for current bug
252 my $pkg; # Name of current package
253 my $file; # Name of statusfile
254 my $sect; # Section of current package
255 my $mnt; # Maintainer of current package
258 open(P, $file) or die "open $file: $!";
262 ($bug,$subject)=split(/ /, $_, 2);
263 $bugs{$bug}=$subject;
264 push @{$packagelist{$pkg}}, $bug;
266 ($pkg,$sect, $mnt)=split(/ /, $_, 3);
267 next if (!defined($pkg));
268 $section{$pkg}=$sect;
269 $maintainer{$pkg}=$mnt;
280 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
281 $url =~ s/([<>&"])/\&$saniarray{$1};/g;
286 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
287 my $in = shift || "";
288 $in =~ s/([<>&"])/\&$saniarray{$1};/g;
293 my $number = shift; # Number of bug to html-ize
295 "<A HREF=\"http://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=" .
296 urlsanit($number) . '">' . htmlsanit($number) . '</A>';
300 my $name = shift; # Name of package
302 "<A HREF=\"http://bugs.debian.org/cgi-bin/pkgreport.cgi?archive=no&pkg=" .
303 urlsanit($name) . '">' . htmlsanit($name) . '</A>';
309 if ($status =~ m/^\[[^]]*I/ or
310 $status !~ m/ \[[^]]*T/) {
316 sub check_worry_stable {
319 if ($status !~ m/ \[[^]]*S/) {
329 $taginfo .= $bi->{'pending'} ? "P" : " ";
330 $taginfo .= $bi->{'patch'} ? "+" : " ";
331 $taginfo .= $bi->{'help'} ? "H" : " ";
332 $taginfo .= $bi->{'moreinfo'} ? "M" : " ";
333 $taginfo .= $bi->{'unreproducible'} ? "R" : " ";
334 $taginfo .= $bi->{'security'} ? "S" : " ";
335 $taginfo .= $bi->{'upstream'} ? "U" : " ";
336 $taginfo .= $bi->{'etch-ignore'} ? "I" : " ";
345 for my $dist qw(oldstable stable testing unstable experimental) {
346 $relinfo .= uc(substr($dist, 0, 1)) if $bi->{$dist};