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; # Root of archive we are scanning
71 my $archive; # Name of archive we are scanning
72 my $sect; # Name of current section
73 my $arch; # Name of current architecture
77 for $arch ( @bugcfg::architectures ) {
78 for $sect ( @bugcfg::sections) {
79 open(P, "zcat $root/$sect/binary-$arch/Packages.gz|")
80 or die "open: $root/$sect/binary-$arch/Packages.gz: $!\n";
83 next unless m/^Package:\s/; # We're only interested in the packagenames
84 s/^Package:\s*//; # Strip the fieldname
85 $section{$_} = "$archive/$sect";
86 print "$root/$sect/binary-$arch/Packages.gz\n" if ($_ eq 'xtla');
93 sub readdebbugssources() {
100 or die "open: $file: $!\n";
103 my ($host, $bin, $sect, $ver, $src) = split /\s+/;
104 my $sectname = ($sect =~ /^\Q$archive/) ? $sect : "$archive/$sect";
105 $debbugssection{$bin} = $sectname;
106 $debbugssection{$src} = $sectname;
111 sub readpseudopackages() {
112 open(P, $bugcfg::pseudolist) or die("open $bugcfg::pseudolist: $!\n");
116 $section{$_} = "pseudo";
126 chdir($bugcfg::spooldir) or die "chdir $bugcfg::spooldir: $!\n";
128 opendir(DIR, $bugcfg::spooldir) or die "opendir $bugcfg::spooldir: $!\n";
129 @dirs=grep(m/^\d+$/,readdir(DIR));
133 scanspooldir("$bugcfg::spooldir/$dir");
140 my $f; # While we're currently processing
141 my @list; # List of files to process
142 my $skip; # Flow control
143 my $walk; # index variable
144 my $taginfo; # Tag info
146 chdir($dir) or die "chdir $dir: $!\n";
148 opendir(DIR, $dir) or die "opendir $dir: $!\n";
149 @list = grep { s/\.summary$// }
150 grep { m/^\d+\.summary$/ }
155 my $bug = Debbugs::Status::read_bug(summary => "$f.summary");
156 next if (!defined($bug));
160 subject => $bug->{'subject'},
161 package => $bug->{'package'}
165 for $walk (@bugcfg::priorities) {
166 $skip=0 if $walk eq $bug->{'severity'};
169 my @tags = split(' ', $bug->{'keywords'});
170 for my $tag (@tags) {
171 for my $s (@bugcfg::skiptags) {
172 $skip=1 if $tag eq $s;
178 $disttags{'oldstable'} = grep(/^sarge$/, @tags);
179 $disttags{'stable'} = grep(/^etch$/, @tags);
180 $disttags{'testing'} = grep(/^lenny$/, @tags);
181 $disttags{'unstable'} = grep(/^sid$/, @tags);
182 $disttags{'experimental'} = grep(/^experimental$/, @tags);
184 # default according to vorlon 2007-06-17
185 if (!$disttags{'oldstable'} && !$disttags{'stable'} && !$disttags{'testing'} && !$disttags{'unstable'} && !$disttags{'experimental'}) {
186 $disttags{'stable'} = 1;
187 $disttags{'testing'} = 1;
188 $disttags{'unstable'} = 1;
189 $disttags{'experimental'} = 1;
192 if (defined($section{$bug->{'package'}}) && $section{$bug->{'package'}} eq 'pseudo') {
193 # versioning information makes no sense for pseudo packages,
195 for my $dist qw(oldstable stable testing unstable experimental) {
196 $bi->{$dist} = $disttags{$dist};
198 next if (length($bug->{'done'}));
202 # only bother to check the versioning status for the distributions indicated by the tags
203 for my $dist qw(oldstable stable testing unstable experimental) {
204 local $SIG{__WARN__} = sub {};
207 next if (!$disttags{$dist});
209 my $presence = Debbugs::Status::bug_presence(
213 arch => \@bugcfg::architectures
216 # ignore bugs that are absent/fixed in this distribution, include everything
217 # else (that is, "found" which says that the bug is present, and undef, which
218 # indicates that no versioning information is present and it's not closed
220 if (!defined($presence) || ($presence ne 'absent' && $presence ne 'fixed')) {
226 next if !$affects_any;
229 for my $keyword qw(pending patch help moreinfo unreproducible security upstream etch-ignore lenny-ignore) {
230 $bi->{$keyword} = grep(/^$keyword$/, @tags);
233 if (length($bug->{'mergedwith'})) {
234 my @merged = split(' ', $bug->{'mergedwith'});
235 next if ($merged[0] < $f);
238 for my $package (split /[,\s]+/, $bug->{'package'}) {
239 $_= $package; y/A-Z/a-z/; $_= $` if m/[^-+._a-z0-9]/;
240 push @{$packagelist{$_}}, $f;
243 my $taginfo = get_taginfo($bi);
244 my $relinfo = get_relinfo($bi);
252 my $filename = shift;
253 open STATUS, "<", $filename
254 or die "$filename: $!";
257 chomp (my $type = <STATUS>);
258 if ($type eq 'package') {
259 chomp (my $package = <STATUS>);
260 chomp (my $section = <STATUS>);
261 chomp (my $maintainer = <STATUS>);
262 my $blank = <STATUS>;
264 $section{$package} = $section;
265 $maintainer{$package} = $maintainer;
267 if ($type eq 'bug') {
271 last if ($line !~ /^(.*?)=(.*)$/);
275 $bugs{$bug->{'number'}} = $bug;
277 for my $package (split /[,\s]+/, $bug->{'package'}) {
278 $_= $package; y/A-Z/a-z/; $_= $` if m/[^-+._a-z0-9]/;
279 push @{$packagelist{$_}}, $bug->{'number'};
282 last if ($type eq 'end');
292 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
293 $url =~ s/([<>&"])/\&$saniarray{$1};/g;
298 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
299 my $in = shift || "";
300 $in =~ s/([<>&"])/\&$saniarray{$1};/g;
305 my $number = shift; # Number of bug to html-ize
307 "<A HREF=\"http://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=" .
308 urlsanit($number) . '">' . htmlsanit($number) . '</A>';
312 my $name = shift; # Name of package
314 "<A HREF=\"http://bugs.debian.org/cgi-bin/pkgreport.cgi?archive=no&pkg=" .
315 urlsanit($name) . '">' . htmlsanit($name) . '</A>';
321 return ($bi->{'testing'} && !$bi->{'lenny-ignore'});
324 sub check_worry_stable {
327 return ($bi->{'stable'} && !$bi->{'etch-ignore'});
330 sub check_worry_unstable {
333 return ($bi->{'unstable'});
340 $taginfo .= $bi->{'pending'} ? "P" : " ";
341 $taginfo .= $bi->{'patch'} ? "+" : " ";
342 $taginfo .= $bi->{'help'} ? "H" : " ";
343 $taginfo .= $bi->{'moreinfo'} ? "M" : " ";
344 $taginfo .= $bi->{'unreproducible'} ? "R" : " ";
345 $taginfo .= $bi->{'security'} ? "S" : " ";
346 $taginfo .= $bi->{'upstream'} ? "U" : " ";
347 $taginfo .= ($bi->{'etch-ignore'} || $bi->{'lenny-ignore'}) ? "I" : " ";
356 for my $dist qw(oldstable stable testing unstable experimental) {
357 $relinfo .= uc(substr($dist, 0, 1)) if $bi->{$dist};