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}; }
18 print "Content-Type: text/html\n\n";
19 print "<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\n";
20 print "An error occurred. Dammit.\n";
21 print "Error was: $msg.\n";
22 print "</BODY></HTML>\n";
28 # my $Archive = $common_archive ? "archive" : "";
29 # print header . start_html("Sorry");
30 # print "Sorry bug #$msg doesn't seem to be in the $Archive database.\n";
37 my %status = getbugstatus($ref);
38 return htmlindexentrystatus(%status) if (%status);
42 sub htmlindexentrystatus {
48 if ($status{severity} eq 'normal') {
50 } elsif (grep($status{severity} eq $_, @debbugs::gStrongSeverities)) {
51 $showseverity = "<strong>Severity: $status{severity}</strong>;\n";
53 $showseverity = "Severity: <em>$status{severity}</em>;\n";
56 $result .= "Package: <a href=\"" . pkgurl($status{"package"}) . "\">"
57 . "<strong>" . htmlsanit($status{"package"}) . "</strong></a>;\n"
58 if (length($status{"package"}));
59 $result .= $showseverity;
60 $result .= "Reported by: " . htmlsanit($status{originator});
61 $result .= ";\nTags: <strong>"
62 . htmlsanit(join(", ", sort(split(/\s+/, $status{tags}))))
64 if (length($status{tags}));
66 my @merged= split(/ /,$status{mergedwith});
67 my $mseparator= ";\nmerged with ";
69 $result .= $mseparator."<A href=\"" . bugurl($m) . "\">#$m</A>";
73 if (length($status{done})) {
74 $result .= ";\n<strong>Done:</strong> " . htmlsanit($status{done});
75 } elsif (length($status{forwarded})) {
76 $result .= ";\n<strong>Forwarded</strong> to "
77 . htmlsanit($status{forwarded});
79 my $daysold = int((time - $status{date}) / 86400); # seconds to days
83 $font = "em" if ($daysold > 30);
84 $font = "strong" if ($daysold > 60);
85 $efont = "</$font>" if ($font);
86 $font = "<$font>" if ($font);
88 my $yearsold = int($daysold / 364);
89 $daysold = $daysold - $yearsold * 364;
91 $result .= ";\n $font";
92 $result .= "1 year and " if ($yearsold == 1);
93 $result .= "$yearsold years and " if ($yearsold > 1);
94 $result .= "1 day old" if ($daysold == 1);
95 $result .= "$daysold days old" if ($daysold != 1);
107 my $params = "maintenc=" . maintencoded($ref);
108 $params .= "&archive=yes" if ($common_archive);
109 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
110 return $debbugs::gCGIDomain . "pkgreport.cgi" . "?" . $params;
115 my $params = "pkg=$ref";
116 $params .= "&archive=yes" if ($common_archive);
117 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
119 return $debbugs::gCGIDomain . "pkgreport.cgi" . "?" . "$params";
123 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
126 while ($in =~ m/[<>&"]/) {
127 $out .= $`. '&'. $saniarray{$&}. ';';
136 my $params = "bug=$ref";
137 foreach my $val (@_) {
138 $params .= "\&msg=$1" if ($val =~ /^msg=([0-9]+)/);
139 $params .= "\&archive=yes" if (!$common_archive && $val =~ /^archive.*$/);
141 $params .= "&archive=yes" if ($common_archive);
142 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
144 return $debbugs::gCGIDomain . "bugreport.cgi" . "?" . "$params";
149 return $debbugs::gCGIDomain . "package.cgi" . "?" . "package=$ref";
155 opendir(D, "$debbugs::gSpoolDir/db") or &quit("opendir db: $!");
156 @bugs = sort {$a<=>$b} grep s/\.status$//,
157 (grep m/^[0-9]+\.status$/,
169 my %displayshowpending = ("pending", "outstanding",
171 "forwarded", "forwarded to upstream software authors");
174 return "<HR><H2>No reports found!</H2></HR>\n";
177 foreach my $bug (sort {$a<=>$b} @bugs) {
178 my %status = getbugstatus($bug);
180 my @merged = sort {$a<=>$b} ($bug, split(/ /, $status{mergedwith}));
181 next unless ($common_repeatmerged || $bug == $merged[0]);
182 if (%common_include) {
184 foreach my $t (split /\s+/, $status{tags}) {
185 $okay = 1, last if (defined $common_include{$t});
189 if (%common_exclude) {
191 foreach my $t (split /\s+/, $status{tags}) {
192 $okay = 0, last if (defined $comon_exclude{$t});
197 $section{$status{pending} . "_" . $status{severity}} .=
198 sprintf "<li><a href=\"%s\">#%d: %s</a>\n<br>",
199 bugurl($bug), $bug, htmlsanit($status{subject});
200 $section{$status{pending} . "_" . $status{severity}} .=
201 htmlindexentrystatus(\%status) . "\n";
206 foreach my $pending (qw(pending forwarded done)) {
207 foreach my $severity(@debbugs::gSeverityList) {
208 $severity = $debbugs::gDefaultSeverity if ($severity eq '');
209 next unless defined $section{${pending} . "_" . ${severity}};
210 $result .= "<HR><H2>$debbugs::gSeverityDisplay{$severity} - $displayshowpending{$pending}</H2>\n";
211 $result .= "(A list of <a href=\"http://www.debian.org/Bugs/db/si/$pending$severity\">all such bugs</a> is available).\n";
213 $result .= $section{$pending . "_" . $severity};
214 $result .= "</UL>\n";
215 $anydone = 1 if ($pending eq "done");
219 $result .= $debbugs::gHTMLExpireNote if ($anydone);
224 my $submitter = shift;
227 ($subemail = $d{"submitter"}) =~ s/\s*\(.*\)\s*//;
228 if ($subemail =~ m/<(.*)>/) { $subemail = $1 }
229 return $subemail eq $submitter;
231 return getbugs($chk);
236 my $severity = shift;
239 return ($d{"severity"} eq $severity) && ($d{"status"} eq $status);
241 return getbugs($chk);
246 my %maintainers = getmaintainers();
249 ($maintemail = $maintainers{$d{"pkg"}} || "") =~ s/\s*\(.*\)\s*//;
250 if ($maintemail =~ m/<(.*)>/) { $maintemail = $1 }
251 return $maintemail eq $maint;
253 return getbugs($chk);
258 my %maintainers = getmaintainers();
259 return getbugs(sub {my %d=@_; return maintencoded($maintainers{$d{"pkg"}} || "") eq $maint});
264 return getbugs( sub { my %d = @_; return $inpkg eq $d{"pkg"} });
270 if ( $common_archive ) {
271 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
273 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
279 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
280 if ($bugfunc->(pkg => $1, bug => $2, status => $4, submitter => $5,
281 severity => $6, tags => $7))
284 #last if (@result > 400);
289 return sort {$a <=> $b} @result;
294 if ( $common_archive ) {
295 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
297 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
300 $descstr{ $1 } = 1 if (m/^(\S+)/);
310 while ($input =~ m/\W/) {
311 $encoded.=$`.sprintf("-%02x_",unpack("C",$&));
316 $encoded =~ s/-2e_/\./g;
317 $encoded =~ s/^([^,]+)-20_-3c_(.*)-40_(.*)-3e_/$1,$2,$3,/;
318 $encoded =~ s/^(.*)-40_(.*)-20_-28_([^,]+)-29_$/,$1,$2,$3/;
319 $encoded =~ s/-20_/_/g;
320 $encoded =~ s/-([^_]+)_-/-$1/g;
327 open(MM,"$gMaintainerFile") or &quit("open $gMaintainerFile: $!");
329 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
344 unless (open(S,"$gSpoolDir/db/$bugnum.status")) {
345 my $archdir = sprintf "%02d", $bugnum % 100;
346 open(S,"$gSpoolDir/archive/$archdir/$bugnum.status" ) or return ();
348 my @lines = qw(originator date subject msgid package tags done
349 forwarded mergedwith severity);
352 $status{shift @lines} = $_;
355 $status{shift @lines} = '' while(@lines);
357 $status{"package"} =~ s/\s*$//;
358 $status{"package"} = 'unknown' if ($status{"package"} eq '');
359 $status{"severity"} = 'normal' if ($status{"severity"} eq '');
361 $status{"pending"} = 'pending';
362 $status{"pending"} = 'forwarded' if (length($status{"forwarded"}));
363 $status{"pending"} = 'done' if (length($status{"done"}));
372 $res = "$gSpoolDir/db/$bugnum.log";
373 return $res if ( -e $res );
375 my $archdir = sprintf "%02d", $bugnum % 100;
376 $res = "$gSpoolDir/archive/$archdir/$bugnum.log";
377 return $res if ( -e $res );