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($s_originator, $s_date, $s_subject, $s_msgid, $s_package, $s_keywords);
171 local($s_done, $s_forwarded, $s_mergedwith, $s_severity);
172 local($skip); # Flow control
173 local($walk); # index variable
174 local($taginfo); # Tag info
176 chdir($dir) or die "chdir $dir: $!\n";
178 opendir(DIR, $dir) or die "opendir $dir: $!\n";
179 @list = grep { s/\.status$// }
180 grep { m/^\d+\.status$/ }
185 next if $exclude{$f}; # Check the list of bugs to skip
186 next if (!open(S,"$f.status")); # Check bugs without a status (?)
188 chomp($s_originator = <S>);
189 chomp($s_date = <S>);
190 chomp($s_subject = <S>);
191 chomp($s_msgid = <S>);
192 chomp($s_package = <S>);
193 chomp($s_tags = <S>);
194 chomp($s_done = <S>);
195 chomp($s_forwarded = <S>);
196 chomp($s_mergedwith = <S>);
197 chomp($s_severity = <S>);
200 next if length($s_done) and not $premature{$f};
201 $premature{$f}++ if length($s_done);
203 $s_severity =~ y/A-Z/a-z/;
204 $s_tags =~ y/A-Z/a-z/;
207 for $walk (@priorities) {
208 $skip=0 if $walk eq $s_severity;
211 for $tag (split(' ', $s_tags)) {
213 $skip=1 if $tag eq $s;
219 $relinfo .= ($s_tags =~ /\bwoody\b/ ? "O" : "");
220 $relinfo .= ($s_tags =~ /\bsarge(|\s.*)%/ ? "S" : "");
221 $relinfo .= ($s_tags =~ /\betch(|\s.*)$/ ? "T" : "");
222 # etch-ignore matches \betch\b :(
223 $relinfo .= ($s_tags =~ /\bsid\b/ ? "U" : "");
224 $relinfo .= ($s_tags =~ /\bexperimental\b/ ? "E" : "");
227 $taginfo .= ($s_tags =~ /\bpending\b/ ? "P" : " ");
228 $taginfo .= ($s_tags =~ /\bpatch\b/ ? "+" : " ");
229 $taginfo .= ($s_tags =~ /\bhelp\b/ ? "H" : " ");
230 $taginfo .= ($s_tags =~ /\bmoreinfo\b/ ? "M" : " ");
231 $taginfo .= ($s_tags =~ /\bunreproducible\b/ ? "R" : " ");
232 $taginfo .= ($s_tags =~ /\bsecurity\b/ ? "S" : " ");
233 $taginfo .= ($s_tags =~ /\bupstream\b/ ? "U" : " ");
234 $taginfo .= ($s_tags =~ /\betch-ignore\b/ ? "I" : " ");
237 if ($s_mergedwith) { # Only show the first package if things are merged
238 my @merged = split(' ', $s_mergedwith);
239 next if ($merged[0] < $f);
242 for $package (split /[,\s]+/, $s_package) {
243 $_= $package; y/A-Z/a-z/; $_= $` if m/[^-+._a-z0-9]/;
244 if (not defined $section{$_}) {
245 if (defined $debbugssection{$_}) {
248 next; # Skip unavailable packages
252 $packagelist{$_} .= " $f";
255 if ($relinfo eq "") { # or $relinfo eq "U" # confuses e.g. #210306
258 $relinfo = " [$relinfo]";
261 $bugs{$f} = "$f $taginfo$relinfo $s_subject";
267 local ($bug); # Number of current bug
268 local ($subject); # Subject for current bug
269 local ($pkg); # Name of current package
270 local ($file); # Name of statusfile
271 local ($sect); # Section of current package
272 local ($mnt); # Maintainer of current package
275 open(P, $file) or die "open $file: $!";
279 ($bug,$subject)=split(/ /, $_, 2);
280 $bugs{$bug}=$subject;
281 $packagelist{$pkg} .= "$bug ";
283 ($pkg,$sect, $mnt)=split(/ /, $_, 3);
284 $section{$pkg}=$sect;
285 $maintainer{$pkg}=$mnt;
292 sub readNMUstatus() {
293 local ($bug); # Number of current bug
294 local ($source); # Source upload which closes this bug.
295 local ($version); # Version where this bug was closed.
296 local ($flag); # Whether this paragraph has been processed.
297 local ($field, $value);
299 for (split /\n/, LWP::UserAgent->new->request(HTTP::Request->new(GET => shift))->content) {
303 $NMU{$bug, "source"} = $source;
304 $NMU{$bug, "version"} = $version;
305 # $comments{$bug} .= "[FIXED] Fixed package $source is in Incoming\n";
308 ($field, $value) = split(/: /, $_, 2);
309 $bug = $value if($field =~ /bug/i);
310 $source = $value if($field =~ /source/i);
311 $version = $value if($field =~ /version/i);
317 $NMU{$bug, "source"} = $source;
318 $NMU{$bug, "version"} = $version;
319 # $comments{$bug} .= "[FIXED] Fixed package $source in in Incoming\n";
329 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
330 $url =~ s/([<>&"])/\&$saniarray{$1};/g;
335 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
336 my $in = shift || "";
337 $in =~ s/([<>&"])/\&$saniarray{$1};/g;
342 local ($number) = shift; # Number of bug to html-ize
343 # local ($section); # Section for the bug
345 "<A HREF=\"http://bugs.debian.org/cgi-bin/bugreport.cgi?archive=no&bug=" .
346 urlsanit($number) . '">' . htmlsanit($number) . '</A>';
347 # ($section=$number) =~ s/([0-9]{2}).*/$1/;
348 # "<A HREF=\"${btsURL}/db/$section/$number.html\">$number</A>";
352 local ($name) = shift; # Name of package
354 "<A HREF=\"http://bugs.debian.org/cgi-bin/pkgreport.cgi?archive=no&pkg=" .
355 urlsanit($name) . '">' . htmlsanit($name) . '</A>';
356 # "<A HREF=\"${btsURL}/db/pa/l$name.html\">$name</A>";