3 my $common_archive = 0;
4 my $common_repeatmerged = 1;
5 my %common_include = ();
6 my %common_exclude = ();
10 if ($opt eq "archive") { $common_archive = $val; }
11 if ($opt eq "repeatmerged") { $common_repeatmerged = $val; }
12 if ($opt eq "exclude") { %common_exclude = %{$val}; }
13 if ($opt eq "include") { %common_include = %{$val}; }
17 my ($in, $key, $val, %ret);
18 if (defined $ENV{"QUERY_STRING"} && $ENV{"QUERY_STRING"} ne "") {
19 $in=$ENV{QUERY_STRING};
20 } elsif(defined $ENV{"REQUEST_METHOD"}
21 && $ENV{"REQUEST_METHOD"} eq "POST")
23 read(STDIN,$in,$ENV{CONTENT_LENGTH});
27 foreach (split(/&/,$in)) {
29 ($key, $val) = split(/=/,$_,2);
30 $key=~s/%(..)/pack("c",hex($1))/ge;
31 $val=~s/%(..)/pack("c",hex($1))/ge;
39 print "Content-Type: text/html\n\n";
40 print "<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\n";
41 print "An error occurred. Dammit.\n";
42 print "Error was: $msg.\n";
43 print "</BODY></HTML>\n";
49 # my $Archive = $common_archive ? "archive" : "";
50 # print header . start_html("Sorry");
51 # print "Sorry bug #$msg doesn't seem to be in the $Archive database.\n";
58 my %status = getbugstatus($ref);
59 return htmlindexentrystatus(%status) if (%status);
63 sub htmlindexentrystatus {
69 if ($status{severity} eq 'normal') {
71 } elsif (grep($status{severity} eq $_, @debbugs::gStrongSeverities)) {
72 $showseverity = "<strong>Severity: $status{severity}</strong>;\n";
74 $showseverity = "Severity: <em>$status{severity}</em>;\n";
77 $result .= "Package: <a href=\"" . pkgurl($status{"package"}) . "\">"
78 . "<strong>" . htmlsanit($status{"package"}) . "</strong></a>;\n"
79 if (length($status{"package"}));
80 $result .= $showseverity;
81 $result .= "Reported by: " . htmlsanit($status{originator});
82 $result .= ";\nTags: <strong>"
83 . htmlsanit(join(", ", sort(split(/\s+/, $status{tags}))))
85 if (length($status{tags}));
87 my @merged= split(/ /,$status{mergedwith});
88 my $mseparator= ";\nmerged with ";
90 $result .= $mseparator."<A href=\"" . bugurl($m) . "\">#$m</A>";
94 if (length($status{done})) {
95 $result .= ";\n<strong>Done:</strong> " . htmlsanit($status{done});
96 } elsif (length($status{forwarded})) {
97 $result .= ";\n<strong>Forwarded</strong> to "
98 . htmlsanit($status{forwarded});
100 my $daysold = int((time - $status{date}) / 86400); # seconds to days
104 $font = "em" if ($daysold > 30);
105 $font = "strong" if ($daysold > 60);
106 $efont = "</$font>" if ($font);
107 $font = "<$font>" if ($font);
109 my $yearsold = int($daysold / 364);
110 $daysold = $daysold - $yearsold * 364;
112 $result .= ";\n $font";
113 $result .= "1 year and " if ($yearsold == 1);
114 $result .= "$yearsold years and " if ($yearsold > 1);
115 $result .= "1 day old" if ($daysold == 1);
116 $result .= "$daysold days old" if ($daysold != 1);
128 my $params = "maintenc=" . maintencoded($ref);
129 $params .= "&archive=yes" if ($common_archive);
130 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
131 return $debbugs::gCGIDomain . "pkgreport.cgi" . "?" . $params;
136 my $params = "pkg=$ref";
137 $params .= "&archive=yes" if ($common_archive);
138 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
140 return $debbugs::gCGIDomain . "pkgreport.cgi" . "?" . "$params";
144 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
147 while ($in =~ m/[<>&"]/) {
148 $out .= $`. '&'. $saniarray{$&}. ';';
157 my $params = "bug=$ref";
158 foreach my $val (@_) {
159 $params .= "\&msg=$1" if ($val =~ /^msg=([0-9]+)/);
160 $params .= "\&archive=yes" if (!$common_archive && $val =~ /^archive.*$/);
162 $params .= "&archive=yes" if ($common_archive);
163 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
165 return $debbugs::gCGIDomain . "bugreport.cgi" . "?" . "$params";
170 return $debbugs::gCGIDomain . "package.cgi" . "?" . "package=$ref";
176 opendir(D, "$debbugs::gSpoolDir/db") or &quit("opendir db: $!");
177 @bugs = sort {$a<=>$b} grep s/\.status$//,
178 (grep m/^[0-9]+\.status$/,
190 my %displayshowpending = ("pending", "outstanding",
192 "forwarded", "forwarded to upstream software authors");
195 return "<HR><H2>No reports found!</H2></HR>\n";
198 foreach my $bug (sort {$a<=>$b} @bugs) {
199 my %status = getbugstatus($bug);
201 my @merged = sort {$a<=>$b} ($bug, split(/ /, $status{mergedwith}));
202 next unless ($common_repeatmerged || $bug == $merged[0]);
203 if (%common_include) {
205 foreach my $t (split /\s+/, $status{tags}) {
206 $okay = 1, last if (defined $common_include{$t});
210 if (%common_exclude) {
212 foreach my $t (split /\s+/, $status{tags}) {
213 $okay = 0, last if (defined $comon_exclude{$t});
218 $section{$status{pending} . "_" . $status{severity}} .=
219 sprintf "<li><a href=\"%s\">#%d: %s</a>\n<br>",
220 bugurl($bug), $bug, htmlsanit($status{subject});
221 $section{$status{pending} . "_" . $status{severity}} .=
222 htmlindexentrystatus(\%status) . "\n";
227 foreach my $pending (qw(pending forwarded done)) {
228 foreach my $severity(@debbugs::gSeverityList) {
229 $severity = $debbugs::gDefaultSeverity if ($severity eq '');
230 next unless defined $section{${pending} . "_" . ${severity}};
231 $result .= "<HR><H2>$debbugs::gSeverityDisplay{$severity} - $displayshowpending{$pending}</H2>\n";
232 $result .= "(A list of <a href=\"http://www.debian.org/Bugs/db/si/$pending$severity\">all such bugs</a> is available).\n";
234 $result .= $section{$pending . "_" . $severity};
235 $result .= "</UL>\n";
236 $anydone = 1 if ($pending eq "done");
240 $result .= $debbugs::gHTMLExpireNote if ($anydone);
245 my $submitter = shift;
248 ($subemail = $d{"submitter"}) =~ s/\s*\(.*\)\s*//;
249 if ($subemail =~ m/<(.*)>/) { $subemail = $1 }
250 return $subemail eq $submitter;
252 return getbugs($chk);
257 my $severity = shift;
260 return ($d{"severity"} eq $severity) && ($d{"status"} eq $status);
262 return getbugs($chk);
267 my %maintainers = getmaintainers();
270 ($maintemail = $maintainers{$d{"pkg"}} || "") =~ s/\s*\(.*\)\s*//;
271 if ($maintemail =~ m/<(.*)>/) { $maintemail = $1 }
272 return $maintemail eq $maint;
274 return getbugs($chk);
278 my $maintenc = shift;
279 my %maintainers = getmaintainers();
280 return getbugs(sub {my %d=@_; return maintencoded($maintainers{$d{"pkg"}} || "") eq $maintenc});
285 return getbugs( sub { my %d = @_; return $inpkg eq $d{"pkg"} });
290 if ($common_archive) {
291 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
293 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
299 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
300 my $x = $bugfunc->(pkg => $1, bug => $2, status => $4,
301 submitter => $5, severity => $6, tags => $7);
312 if ( $common_archive ) {
313 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
315 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
321 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
322 if ($bugfunc->(pkg => $1, bug => $2, status => $4, submitter => $5,
323 severity => $6, tags => $7))
326 #last if (@result > 400);
331 return sort {$a <=> $b} @result;
336 if ( $common_archive ) {
337 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
339 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
342 $descstr{ $1 } = 1 if (m/^(\S+)/);
352 while ($input =~ m/\W/) {
353 $encoded.=$`.sprintf("-%02x_",unpack("C",$&));
358 $encoded =~ s/-2e_/\./g;
359 $encoded =~ s/^([^,]+)-20_-3c_(.*)-40_(.*)-3e_/$1,$2,$3,/;
360 $encoded =~ s/^(.*)-40_(.*)-20_-28_([^,]+)-29_$/,$1,$2,$3/;
361 $encoded =~ s/-20_/_/g;
362 $encoded =~ s/-([^_]+)_-/-$1/g;
369 open(MM,"$gMaintainerFile") or &quit("open $gMaintainerFile: $!");
371 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
386 unless (open(S,"$gSpoolDir/db/$bugnum.status")) {
387 my $archdir = sprintf "%02d", $bugnum % 100;
388 open(S,"$gSpoolDir/archive/$archdir/$bugnum.status" ) or return ();
390 my @lines = qw(originator date subject msgid package tags done
391 forwarded mergedwith severity);
394 $status{shift @lines} = $_;
397 $status{shift @lines} = '' while(@lines);
399 $status{"package"} =~ s/\s*$//;
400 $status{"package"} = 'unknown' if ($status{"package"} eq '');
401 $status{"severity"} = 'normal' if ($status{"severity"} eq '');
403 $status{"pending"} = 'pending';
404 $status{"pending"} = 'forwarded' if (length($status{"forwarded"}));
405 $status{"pending"} = 'done' if (length($status{"done"}));
414 $res = "$gSpoolDir/db/$bugnum.log";
415 return $res if ( -e $res );
417 my $archdir = sprintf "%02d", $bugnum % 100;
418 $res = "$gSpoolDir/archive/$archdir/$bugnum.log";
419 return $res if ( -e $res );