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 # %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";
92 sub readdebbugssources() {
99 or die "open: $file: $!\n";
102 my ($host, $bin, $sect, $ver, $src) = split /\s+/;
103 my $sectname = ($sect =~ /^\Q$archive/) ? $sect : "$archive/$sect";
104 $debbugssection{$bin} = $sectname;
105 $debbugssection{$src} = $sectname;
110 sub readpseudopackages() {
111 open(P, $bugcfg::pseudolist) or die("open $bugcfg::pseudolist: $!\n");
115 $section{$_} = "pseudo";
125 chdir($bugcfg::spooldir) or die "chdir $bugcfg::spooldir: $!\n";
127 opendir(DIR, $bugcfg::spooldir) or die "opendir $bugcfg::spooldir: $!\n";
128 @dirs=grep(m/^\d+$/,readdir(DIR));
132 scanspooldir("$bugcfg::spooldir/$dir");
139 my $f; # While we're currently processing
140 my @list; # List of files to process
141 my $skip; # Flow control
142 my $walk; # index variable
143 my $taginfo; # Tag info
145 chdir($dir) or die "chdir $dir: $!\n";
147 opendir(DIR, $dir) or die "opendir $dir: $!\n";
148 @list = grep { s/\.summary$// }
149 grep { m/^\d+\.summary$/ }
154 my $bug = Debbugs::Status::read_bug(summary => "$f.summary");
155 next if (!defined($bug));
158 for $walk (@bugcfg::priorities) {
159 $skip=0 if $walk eq $bug->{'severity'};
162 my @tags = split(' ', $bug->{'keywords'});
163 for my $tag (@tags) {
164 for my $s (@bugcfg::skiptags) {
165 $skip=1 if $tag eq $s;
171 $disttags{'oldstable'} = grep(/^woody$/, @tags);
172 $disttags{'stable'} = grep(/^sarge$/, @tags);
173 $disttags{'testing'} = grep(/^etch$/, @tags);
174 $disttags{'unstable'} = grep(/^sid$/, @tags);
175 $disttags{'experimental'} = grep(/^experimental$/, @tags);
177 # default according to dondelelcaro 2006-11-11
178 if (!$disttags{'oldstable'} && !$disttags{'stable'} && !$disttags{'testing'} && !$disttags{'unstable'} && !$disttags{'experimental'}) {
179 $disttags{'testing'} = 1;
180 $disttags{'unstable'} = 1;
181 $disttags{'experimental'} = 1;
185 if (defined($section{$bug->{'package'}}) && $section{$bug->{'package'}} eq 'pseudo') {
186 # versioning information makes no sense for pseudo packages,
188 for my $dist qw(oldstable stable testing unstable experimental) {
189 $bi->{$dist} = $disttags{$dist};
191 next if (length($bug->{'done'}));
195 # only bother to check the versioning status for the distributions indicated by the tags
196 for my $dist qw(oldstable stable testing unstable experimental) {
197 local $SIG{__WARN__} = sub {};
200 next if (!$disttags{$dist});
202 my $presence = Debbugs::Status::bug_presence(
206 arch => \@bugcfg::architectures
209 # ignore bugs that are absent/fixed in this distribution, include everything
210 # else (that is, "found" which says that the bug is present, and undef, which
211 # indicates that no versioning information is present and it's not closed
213 if (!defined($presence) || ($presence ne 'absent' && $presence ne 'fixed')) {
219 next if !$affects_any;
222 for my $keyword qw(pending patch help moreinfo unreproducible security upstream etch-ignore) {
223 $bi->{$keyword} = ($bug->{'keywords'} =~ /\b$keyword\b/) ? 1 : 0;
226 if (length($bug->{'mergedwith'})) {
227 my @merged = split(' ', $bug->{'mergedwith'});
228 next if ($merged[0] < $f);
231 for my $package (split /[,\s]+/, $bug->{'package'}) {
232 $_= $package; y/A-Z/a-z/; $_= $` if m/[^-+._a-z0-9]/;
233 push @{$packagelist{$_}}, $f;
236 my $taginfo = get_taginfo($bi);
237 my $relinfo = get_relinfo($bi);
239 $bugs{$f} = "$f [$taginfo] [$relinfo] " . $bug->{'subject'};
245 my $bug; # Number of current bug
246 my $subject; # Subject for current bug
247 my $pkg; # Name of current package
248 my $file; # Name of statusfile
249 my $sect; # Section of current package
250 my $mnt; # Maintainer of current package
253 open(P, $file) or die "open $file: $!";
257 ($bug,$subject)=split(/ /, $_, 2);
258 $bugs{$bug}=$subject;
259 push @{$packagelist{$pkg}}, $bug;
261 ($pkg,$sect, $mnt)=split(/ /, $_, 3);
262 next if (!defined($pkg));
263 $section{$pkg}=$sect;
264 $maintainer{$pkg}=$mnt;
275 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
276 $url =~ s/([<>&"])/\&$saniarray{$1};/g;
281 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
282 my $in = shift || "";
283 $in =~ s/([<>&"])/\&$saniarray{$1};/g;
288 my $number = shift; # Number of bug to html-ize
290 "<A HREF=\"http://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=" .
291 urlsanit($number) . '">' . htmlsanit($number) . '</A>';
295 my $name = shift; # Name of package
297 "<A HREF=\"http://bugs.debian.org/cgi-bin/pkgreport.cgi?archive=no&pkg=" .
298 urlsanit($name) . '">' . htmlsanit($name) . '</A>';
304 if ($status =~ m/^\[[^]]*I/ or
305 $status !~ m/ \[[^]]*T/) {
311 sub check_worry_stable {
314 if ($status !~ m/ \[[^]]*S/) {
324 $taginfo .= $bi->{'pending'} ? "P" : " ";
325 $taginfo .= $bi->{'patch'} ? "+" : " ";
326 $taginfo .= $bi->{'help'} ? "H" : " ";
327 $taginfo .= $bi->{'moreinfo'} ? "M" : " ";
328 $taginfo .= $bi->{'unreproducible'} ? "R" : " ";
329 $taginfo .= $bi->{'security'} ? "S" : " ";
330 $taginfo .= $bi->{'upstream'} ? "U" : " ";
331 $taginfo .= $bi->{'etch-ignore'} ? "I" : " ";
340 for my $dist qw(oldstable stable testing unstable experimental) {
341 $relinfo .= uc(substr($dist, 0, 1)) if $bi->{$dist};