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 # %comments - map from bugnumber to bug description
10 # %premature - list of prematurely closed bugreports
11 # %exclude - list of bugreports to exclude from the report
12 # %maintainer - map from packagename to maintainer
13 # %section - map from packagename to section in the FTP-site
14 # %packagelist - map from packagename to bugreports
15 # %NMU - map with NMU information
22 # It is in paragraph format, with the first line of each paragraph being
23 # the bug number or package name to which the comment applies.
24 # Prefix a bug number with a * to force it to be listed even if it's closed.
25 # (This deals with prematurely closed bugs)
27 local($index); # Bug-number for current comment
28 local($file); # Name of comments-file
30 %comments = (); # Initialize our data
34 open(C, $file) or die "open $file: $!\n";
37 if (m/^\s*$/) { # Check for paragraph-breaks
39 } elsif (defined $index) {
40 $comments{$index} .= $_ . "\n";
42 if (s/^\*//) { # Test & remove initial *
45 if (s/\s+EXCLUDE\s*//) { # Test & remove EXCLUDE
50 $comments{$index} = ''; # New comment, initialize data
57 # Read the list of maintainer
58 sub readmaintainers() {
59 local ($pkg); # Name of package
60 local ($mnt); # Maintainer name & email
62 open(M, $maintainerlist) or die "open $maintainerlist: $!\n";
65 m/^(\S+)\s+(\S.*\S)\s*$/ or die "Maintainers: $_ ?";
66 ($pkg, $mnt) = ($1, $2);
67 $pkg =~ y/A-Z/a-z/; # Normalize package-name. why???
70 $mnt="$2 <$1>" if ( m/(\S+)\s+\(([^)]+)\)/ );
72 $maintainer{$pkg}= $mnt;
79 local($root); # Root of archive we are scanning
80 local($archive); # Name of archive we are scanning
81 local($sect); # Name of current section
85 for $sect ( @sections) {
86 open(P, "zcat $root/$sect/source/Sources.gz|")
87 or die open "open: $sect / $arch sourcelist: $!\n";
90 next unless m/^Package:\s/;
91 s/^Package:\s*//; # Strip the fieldname
92 $section{$_} = "$archive/$sect";
99 local($root); # Root of archive we are scanning
100 local($archive); # Name of archive we are scanning
101 local($sect); # Name of current section
102 local($arch); # Name of current architecture
106 for $arch ( @architectures ) {
107 for $sect ( @sections) {
108 open(P, "zcat $root/$sect/binary-$arch/Packages.gz|")
109 or die "open: $root/$sect/binary-$arch/Packages.gz: $!\n";
112 next unless m/^Package:\s/; # We're only interested in the packagenames
113 s/^Package:\s*//; # Strip the fieldname
114 $section{$_} = "$archive/$sect";
121 sub readdebbugssources() {
128 or die "open: $file: $!\n";
131 my ($host, $bin, $sect, $ver, $src) = split /\s+/;
132 my $sectname = ($sect =~ /^\Q$archive/) ? $sect : "$archive/$sect";
133 $debbugssection{$bin} = $sectname;
134 $debbugssection{$src} = $sectname;
139 sub readpseudopackages() {
140 open(P, $pseudolist) or die("open $pseudolist: $!\n");
144 $section{$_} = "pseudo";
154 chdir($spooldir) or die "chdir $spooldir: $!\n";
156 opendir(DIR, $spooldir) or die "opendir $spooldir: $!\n";
157 @dirs=grep(m/^\d+$/,readdir(DIR));
161 scanspooldir("$spooldir/$dir");
168 local($f); # While we're currently processing
169 local(@list); # List of files to process
170 local($skip); # Flow control
171 local($walk); # index variable
172 local($taginfo); # Tag info
174 chdir($dir) or die "chdir $dir: $!\n";
176 opendir(DIR, $dir) or die "opendir $dir: $!\n";
177 @list = grep { s/\.summary$// }
178 grep { m/^\d+\.summary$/ }
183 next if $exclude{$f}; # Check the list of bugs to skip
185 my $bug = readbug("$f.summary");
186 next if (!defined($bug));
189 for $walk (@priorities) {
190 $skip=0 if $walk eq $bug->{'severity'};
193 my @tags = split(' ', $bug->{'keywords'});
196 $skip=1 if $tag eq $s;
201 my $oldstable_tag = grep(/^woody$/, @tags);
202 my $stable_tag = grep(/^sarge$/, @tags);
203 my $testing_tag = grep(/^etch$/, @tags);
204 my $unstable_tag = grep(/^sid$/, @tags);
205 my $experimental_tag = grep(/^experimental$/, @tags);
207 # default according to dondelelcaro 2006-11-11
208 if (!$oldstable_tag && !$stable_tag && !$testing_tag && !$unstable_tag && !$experimental_tag) {
211 $experimental_tag = 1;
214 # only bother to check the versioning status for the distributions indicated by the tags
215 $status_oldstable = getbugstatus($bug, undef, 'oldstable') if ($oldstable_tag);
216 $status_stable = getbugstatus($bug, undef, 'stable') if ($stable_tag);
217 $status_testing = getbugstatus($bug, undef, 'testing') if ($testing_tag);
218 $status_unstable = getbugstatus($bug, undef, 'unstable') if ($unstable_tag);
219 $status_experimental = getbugstatus($bug, undef, 'experimental') if ($experimental_tag);
222 $relinfo .= (($oldstable_tag && $status_oldstable->{'pending'} eq 'pending') ? "O" : "");
223 $relinfo .= (($stable_tag && $status_stable->{'pending'} eq 'pending') ? "S" : "");
224 $relinfo .= (($testing_tag && $status_testing->{'pending'} eq 'pending') ? "T" : "");
225 $relinfo .= (($unstable_tag && $status_unstable->{'pending'} eq 'pending') ? "U" : "");
226 $relinfo .= (($experimental_tag && $status_experimental->{'pending'} eq 'pending') ? "E" : "");
228 next if $relinfo eq '' and not $premature{$f};
229 $premature{$f}++ if $relinfo eq '';
232 $taginfo .= ($bug->{'keywords'} =~ /\bpending\b/ ? "P" : " ");
233 $taginfo .= ($bug->{'keywords'} =~ /\bpatch\b/ ? "+" : " ");
234 $taginfo .= ($bug->{'keywords'} =~ /\bhelp\b/ ? "H" : " ");
235 $taginfo .= ($bug->{'keywords'} =~ /\bmoreinfo\b/ ? "M" : " ");
236 $taginfo .= ($bug->{'keywords'} =~ /\bunreproducible\b/ ? "R" : " ");
237 $taginfo .= ($bug->{'keywords'} =~ /\bsecurity\b/ ? "S" : " ");
238 $taginfo .= ($bug->{'keywords'} =~ /\bupstream\b/ ? "U" : " ");
239 $taginfo .= ($bug->{'keywords'} =~ /\betch-ignore\b/ ? "I" : " ");
242 if (length($bug->{'mergedwith'})) {
243 my @merged = split(' ', $bug->{'mergedwith'});
244 next if ($merged[0] < $f);
247 for $package (split /[,\s]+/, $bug->{'package'}) {
248 $_= $package; y/A-Z/a-z/; $_= $` if m/[^-+._a-z0-9]/;
249 if (not defined $section{$_}) {
250 if (defined $debbugssection{$_}) {
253 next; # Skip unavailable packages
257 $packagelist{$_} .= " $f";
260 if ($relinfo eq "") { # or $relinfo eq "U" # confuses e.g. #210306
263 $relinfo = " [$relinfo]";
266 $bugs{$f} = "$f $taginfo$relinfo " . $bug->{'subject'};
272 local ($bug); # Number of current bug
273 local ($subject); # Subject for current bug
274 local ($pkg); # Name of current package
275 local ($file); # Name of statusfile
276 local ($sect); # Section of current package
277 local ($mnt); # Maintainer of current package
280 open(P, $file) or die "open $file: $!";
284 ($bug,$subject)=split(/ /, $_, 2);
285 $bugs{$bug}=$subject;
286 $packagelist{$pkg} .= "$bug ";
288 ($pkg,$sect, $mnt)=split(/ /, $_, 3);
289 $section{$pkg}=$sect;
290 $maintainer{$pkg}=$mnt;
297 sub readNMUstatus() {
298 local ($bug); # Number of current bug
299 local ($source); # Source upload which closes this bug.
300 local ($version); # Version where this bug was closed.
301 local ($flag); # Whether this paragraph has been processed.
302 local ($field, $value);
304 for (split /\n/, LWP::UserAgent->new->request(HTTP::Request->new(GET => shift))->content) {
308 $NMU{$bug, "source"} = $source;
309 $NMU{$bug, "version"} = $version;
310 # $comments{$bug} .= "[FIXED] Fixed package $source is in Incoming\n";
313 ($field, $value) = split(/: /, $_, 2);
314 $bug = $value if($field =~ /bug/i);
315 $source = $value if($field =~ /source/i);
316 $version = $value if($field =~ /version/i);
322 $NMU{$bug, "source"} = $source;
323 $NMU{$bug, "version"} = $version;
324 # $comments{$bug} .= "[FIXED] Fixed package $source in in Incoming\n";
334 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
335 $url =~ s/([<>&"])/\&$saniarray{$1};/g;
340 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
341 my $in = shift || "";
342 $in =~ s/([<>&"])/\&$saniarray{$1};/g;
347 local ($number) = shift; # Number of bug to html-ize
348 # local ($section); # Section for the bug
350 "<A HREF=\"http://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=" .
351 urlsanit($number) . '">' . htmlsanit($number) . '</A>';
352 # ($section=$number) =~ s/([0-9]{2}).*/$1/;
353 # "<A HREF=\"${btsURL}/db/$section/$number.html\">$number</A>";
357 local ($name) = shift; # Name of package
359 "<A HREF=\"http://bugs.debian.org/cgi-bin/pkgreport.cgi?archive=no&pkg=" .
360 urlsanit($name) . '">' . htmlsanit($name) . '</A>';
361 # "<A HREF=\"${btsURL}/db/pa/l$name.html\">$name</A>";