4 use Fcntl qw/O_RDONLY/;
6 my $common_archive = 0;
7 my $common_repeatmerged = 1;
8 my %common_include = ();
9 my %common_exclude = ();
15 if ($opt eq "archive") { $common_archive = $val; }
16 if ($opt eq "repeatmerged") { $common_repeatmerged = $val; }
17 if ($opt eq "exclude") { %common_exclude = %{$val}; }
18 if ($opt eq "include") { %common_include = %{$val}; }
22 my ($in, $key, $val, %ret);
23 if (defined $ENV{"QUERY_STRING"} && $ENV{"QUERY_STRING"} ne "") {
24 $in=$ENV{QUERY_STRING};
25 } elsif(defined $ENV{"REQUEST_METHOD"}
26 && $ENV{"REQUEST_METHOD"} eq "POST")
28 read(STDIN,$in,$ENV{CONTENT_LENGTH});
32 foreach (split(/&/,$in)) {
34 ($key, $val) = split(/=/,$_,2);
35 $key=~s/%(..)/pack("c",hex($1))/ge;
36 $val=~s/%(..)/pack("c",hex($1))/ge;
37 if ( exists $ret{$key} ) {
38 if ( !exists $ret{"&$key"} ) {
39 $ret{"&$key"} = [ $ret{$key} ];
41 push @{$ret{"&$key"}},$val;
45 $debug = 1 if (defined $ret{"debug"} && $ret{"debug"} eq "aj");
51 print "Content-Type: text/html\n\n";
52 print "<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\n";
53 print "An error occurred. Dammit.\n";
54 print "Error was: $msg.\n";
55 print "</BODY></HTML>\n";
61 # my $Archive = $common_archive ? "archive" : "";
62 # print header . start_html("Sorry");
63 # print "Sorry bug #$msg doesn't seem to be in the $Archive database.\n";
70 my %status = %{getbugstatus($ref)};
71 return htmlindexentrystatus(%status) if (%status);
75 sub htmlindexentrystatus {
81 if ($status{severity} eq 'normal') {
83 } elsif (grep($status{severity} eq $_, @debbugs::gStrongSeverities)) {
84 $showseverity = "<strong>Severity: $status{severity}</strong>;\n";
86 $showseverity = "Severity: <em>$status{severity}</em>;\n";
89 $result .= "Package: <a href=\"" . pkgurl($status{"package"}) . "\">"
90 . "<strong>" . htmlsanit($status{"package"}) . "</strong></a>;\n"
91 if (length($status{"package"}));
92 $result .= $showseverity;
93 $result .= "Reported by: " . htmlsanit($status{originator});
94 $result .= ";\nTags: <strong>"
95 . htmlsanit(join(", ", sort(split(/\s+/, $status{tags}))))
97 if (length($status{tags}));
99 my @merged= split(/ /,$status{mergedwith});
100 my $mseparator= ";\nmerged with ";
101 for my $m (@merged) {
102 $result .= $mseparator."<A href=\"" . bugurl($m) . "\">#$m</A>";
106 if (length($status{done})) {
107 $result .= ";\n<strong>Done:</strong> " . htmlsanit($status{done});
108 } elsif (length($status{forwarded})) {
109 $result .= ";\n<strong>Forwarded</strong> to "
110 . htmlsanit($status{forwarded});
112 my $daysold = int((time - $status{date}) / 86400); # seconds to days
116 $font = "em" if ($daysold > 30);
117 $font = "strong" if ($daysold > 60);
118 $efont = "</$font>" if ($font);
119 $font = "<$font>" if ($font);
121 my $yearsold = int($daysold / 364);
122 $daysold = $daysold - $yearsold * 364;
124 $result .= ";\n $font";
125 $result .= "1 year and " if ($yearsold == 1);
126 $result .= "$yearsold years and " if ($yearsold > 1);
127 $result .= "1 day old" if ($daysold == 1);
128 $result .= "$daysold days old" if ($daysold != 1);
139 my $ref = shift || "";
140 my $params = "submitter=" . emailfromrfc822($ref);
141 $params .= "&archive=yes" if ($common_archive);
142 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
143 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . $params);
147 my $ref = shift || "";
148 my $params = "maint=" . emailfromrfc822($ref);
149 $params .= "&archive=yes" if ($common_archive);
150 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
151 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . $params);
156 my $params = "pkg=$ref";
157 $params .= "&archive=yes" if ($common_archive);
158 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
160 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . "$params");
165 my $params = "src=$ref";
166 $params .= "&archive=yes" if ($common_archive);
167 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
168 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . "$params");
175 my %saniarray = ('<','lt', '>','gt', '"','quot');
177 while ($url =~ m/[<>"]/) {
178 $out .= $`. '&'. $saniarray{$&}. ';';
186 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
187 my $in = shift || "";
189 while ($in =~ m/[<>&"]/) {
190 $out .= $`. '&'. $saniarray{$&}. ';';
199 my $params = "bug=$ref";
200 foreach my $val (@_) {
201 $params .= "\&msg=$1" if ($val =~ /^msg=([0-9]+)/);
202 $params .= "\&archive=yes" if (!$common_archive && $val =~ /^archive.*$/);
204 $params .= "&archive=yes" if ($common_archive);
205 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
207 return urlsanit($debbugs::gCGIDomain . "bugreport.cgi" . "?" . "$params");
212 return urlsanit($debbugs::gCGIDomain . "package.cgi" . "?" . "package=$ref");
218 opendir(D, "$debbugs::gSpoolDir/db") or &quit("opendir db: $!");
219 @bugs = sort {$a<=>$b} grep s/\.status$//,
220 (grep m/^[0-9]+\.status$/,
233 my %displayshowpending = ("pending", "outstanding",
234 "pending-fixed", "pending upload",
235 "fixed", "fixed in NMU",
237 "forwarded", "forwarded to upstream software authors");
240 return "<HR><H2>No reports found!</H2></HR>\n";
243 foreach my $bug (sort {$a<=>$b} @bugs) {
244 my %status = %{getbugstatus($bug)};
246 my @merged = sort {$a<=>$b} ($bug, split(/ /, $status{mergedwith}));
247 next unless ($common_repeatmerged || $bug == $merged[0]);
248 if (%common_include) {
250 foreach my $t (split /\s+/, $status{tags}) {
251 $okay = 1, last if (defined $common_include{$t});
253 if (defined $common_include{subj}) {
254 if (index($status{subject}, $common_include{subj}) > -1) {
260 if (%common_exclude) {
262 foreach my $t (split /\s+/, $status{tags}) {
263 $okay = 0, last if (defined $common_exclude{$t});
265 if (defined $common_exclude{subj}) {
266 if (index($status{subject}, $common_exclude{subj}) > -1) {
273 $section{$status{pending} . "_" . $status{severity}} .=
274 sprintf "<li><a href=\"%s\">#%d: %s</a>\n<br>",
275 bugurl($bug), $bug, htmlsanit($status{subject});
276 $section{$status{pending} . "_" . $status{severity}} .=
277 htmlindexentrystatus(\%status) . "\n";
282 foreach my $pending (qw(pending forwarded pending-fixed fixed done)) {
283 foreach my $severity(@debbugs::gSeverityList) {
284 $severity = $debbugs::gDefaultSeverity if ($severity eq '');
285 next unless defined $section{${pending} . "_" . ${severity}};
286 $result .= "<HR><H2>$debbugs::gSeverityDisplay{$severity} - $displayshowpending{$pending}</H2>\n";
287 #$result .= "(A list of <a href=\"http://${debbugs::gWebDomain}/db/si/$pending$severity\">all such bugs</a> is available).\n";
288 $result .= "(A list of all such bugs used to be available).\n";
290 $result .= $section{$pending . "_" . $severity};
291 $result .= "</UL>\n";
292 $anydone = 1 if ($pending eq "done");
296 $result .= $debbugs::gHTMLExpireNote if ($anydone);
302 if ($common_archive) {
303 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
305 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
311 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
312 my $x = $bugfunc->(pkg => $1, bug => $2, status => $4,
313 submitter => $5, severity => $6, tags => $7);
327 if (!$common_archive && defined $opt &&
328 -e "$debbugs::gSpoolDir/by-$opt.idx")
331 print STDERR "optimized\n" if ($debug);
332 tie %lookup, DB_File => "$debbugs::gSpoolDir/by-$opt.idx", O_RDONLY
333 or die "$0: can't open $debbugs::gSpoolDir/by-$opt.idx ($!)\n";
334 while ($key = shift) {
335 my $bugs = $lookup{$key};
337 push @result, (unpack 'N*', $bugs);
341 print STDERR "done optimized\n" if ($debug);
343 if ( $common_archive ) {
344 open I, "<$debbugs::gSpoolDir/index.archive"
345 or &quit("bugindex: $!");
347 open I, "<$debbugs::gSpoolDir/index.db"
348 or &quit("bugindex: $!");
351 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
352 if ($bugfunc->(pkg => $1, bug => $2, status => $4,
353 submitter => $5, severity => $6, tags => $7))
361 @result = sort {$a <=> $b} @result;
365 sub emailfromrfc822 {
367 $email =~ s/\s*\(.*\)\s*//;
368 $email = $1 if ($email =~ m/<(.*)>/);
376 while ($input =~ m/\W/) {
377 $encoded.=$`.sprintf("-%02x_",unpack("C",$&));
382 $encoded =~ s/-2e_/\./g;
383 $encoded =~ s/^([^,]+)-20_-3c_(.*)-40_(.*)-3e_/$1,$2,$3,/;
384 $encoded =~ s/^(.*)-40_(.*)-20_-28_([^,]+)-29_$/,$1,$2,$3/;
385 $encoded =~ s/-20_/_/g;
386 $encoded =~ s/-([^_]+)_-/-$1/g;
393 open(MM,"$gMaintainerFile") or &quit("open $gMaintainerFile: $!");
395 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
401 open(MM,"$gMaintainerFileOverride") or &quit("open $gMaintainerFileOverride: $!");
403 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
416 open(MM,"$gPackageSource") or &quit("open $gPackageSource: $!");
418 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
429 my ( $bugnum, $ext ) = @_;
430 my $archdir = sprintf "%02d", $bugnum % 100;
431 foreach ( ( "$gSpoolDir/db-h/$archdir", "$gSpoolDir/db", "$gSpoolDir/archive/$archdir" ) ) {
432 return $_ if ( -r "$_/$bugnum.$ext" );
442 my $dir = getbugdir( $bugnum, "status" );
443 return {} if ( !$dir );
444 open S, "< $dir/$bugnum.status";
445 my @lines = qw(originator date subject msgid package tags done
446 forwarded mergedwith severity);
449 $status{shift @lines} = $_;
452 $status{shift @lines} = '' while(@lines);
454 $status{"package"} =~ s/\s*$//;
455 $status{"package"} = 'unknown' if ($status{"package"} eq '');
456 $status{"severity"} = 'normal' if ($status{"severity"} eq '');
458 $status{"pending"} = 'pending';
459 $status{"pending"} = 'forwarded' if (length($status{"forwarded"}));
460 $status{"pending"} = 'fixed' if ($status{"tags"} =~ /\bfixed\b/);
461 $status{"pending"} = 'pending-fixed' if ($status{"tags"} =~ /\bpending\b/);
462 $status{"pending"} = 'done' if (length($status{"done"}));
470 my %pkgsrc = %{getpkgsrc()};
472 foreach ( keys %pkgsrc ) {
473 push @pkgs, $_ if $pkgsrc{$_} eq $src;
481 my $dir = getbugdir( $bugnum, "log" );
482 return "" if ( !$dir );
483 return "$dir/$bugnum.log";