3 my $common_archive = 0;
4 my $common_repeatmerged = 1;
8 if ($opt eq "archive") { $common_archive = $val; }
9 if ($opt eq "repeatmerged") { $common_repeatmerged = $val; }
14 print "Content-Type: text/html\n\n";
15 print "<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\n";
16 print "An error occurred. Dammit.\n";
17 print "Error was: $msg.\n";
18 print "</BODY></HTML>\n";
24 # my $Archive = $common_archive ? "archive" : "";
25 # print header . start_html("Sorry");
26 # print "Sorry bug #$msg doesn't seem to be in the $Archive database.\n";
33 my %status = getbugstatus($ref);
34 return htmlindexentrystatus(%status) if (%status);
38 sub htmlindexentrystatus {
44 if ($status{severity} eq 'normal') {
46 } elsif (grep($status{severity} eq $_, @debbugs::gStrongSeverities)) {
47 $showseverity = "<strong>Severity: $status{severity}</strong>;\n";
49 $showseverity = "Severity: <em>$status{severity}</em>;\n";
52 $result .= "Package: <a href=\"" . pkgurl($status{"package"}) . "\">"
53 . "<strong>" . htmlsanit($status{"package"}) . "</strong></a>;\n"
54 if (length($status{"package"}));
55 $result .= $showseverity;
56 $result .= "Reported by: " . htmlsanit($status{originator});
57 $result .= ";\nTags: <strong>"
58 . htmlsanit(join(", ", sort(split(/\s+/, $status{tags}))))
60 if (length($status{tags}));
62 my @merged= split(/ /,$status{mergedwith});
63 my $mseparator= ";\nmerged with ";
65 $result .= $mseparator."<A href=\"" . bugurl($m) . "\">#$m</A>";
69 if (length($status{done})) {
70 $result .= ";\n<strong>Done:</strong> " . htmlsanit($status{done});
71 } elsif (length($status{forwarded})) {
72 $result .= ";\n<strong>Forwarded</strong> to "
73 . htmlsanit($status{forwarded});
75 my $daysold = int((time - $status{date}) / 86400); # seconds to days
79 $font = "em" if ($daysold > 30);
80 $font = "strong" if ($daysold > 60);
81 $efont = "</$font>" if ($font);
82 $font = "<$font>" if ($font);
84 my $yearsold = int($daysold / 364);
85 $daysold = $daysold - $yearsold * 364;
87 $result .= ";\n $font";
88 $result .= "1 year and " if ($yearsold == 1);
89 $result .= "$yearsold years and " if ($yearsold > 1);
90 $result .= "1 day old" if ($daysold == 1);
91 $result .= "$daysold days old" if ($daysold != 1);
103 my $params = "maintenc=" . maintencoded($ref);
104 $params .= "&archive=yes" if ($common_archive);
105 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
106 return $debbugs::gCGIDomain . "pkgreport.cgi" . "?" . $params;
111 my $params = "pkg=$ref";
112 $params .= "&archive=yes" if ($common_archive);
113 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
115 return $debbugs::gCGIDomain . "pkgreport.cgi" . "?" . "$params";
119 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
122 while ($in =~ m/[<>&"]/) {
123 $out .= $`. '&'. $saniarray{$&}. ';';
132 my $params = "bug=$ref";
133 foreach my $val (@_) {
134 $params .= "\&msg=$1" if ($val =~ /^msg=([0-9]+)/);
135 $params .= "\&archive=yes" if (!$common_archive && $val =~ /^archive.*$/);
137 $params .= "&archive=yes" if ($common_archive);
138 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
140 return $debbugs::gCGIDomain . "bugreport.cgi" . "?" . "$params";
145 return $debbugs::gCGIDomain . "package.cgi" . "?" . "package=$ref";
151 opendir(D, "$debbugs::gSpoolDir/db") or &quit("opendir db: $!");
152 @bugs = sort {$a<=>$b} grep s/\.status$//,
153 (grep m/^[0-9]+\.status$/,
165 my %displayshowpending = ("pending", "outstanding",
167 "forwarded", "forwarded to upstream software authors");
170 return "<HR><H2>No reports found!</H2></HR>\n";
173 foreach my $bug (sort {$a<=>$b} @bugs) {
174 my %status = getbugstatus($bug);
176 my @merged = sort {$a<=>$b} ($bug, split(/ /, $status{mergedwith}));
177 if ($common_repeatmerged || $bug == $merged[0]) {
178 $section{$status{pending} . "_" . $status{severity}} .=
179 sprintf "<li><a href=\"%s\">#%d: %s</a>\n<br>",
180 bugurl($bug), $bug, htmlsanit($status{subject});
181 $section{$status{pending} . "_" . $status{severity}} .=
182 htmlindexentrystatus(\%status) . "\n";
188 foreach my $pending (qw(pending forwarded done)) {
189 foreach my $severity(@debbugs::gSeverityList) {
190 $severity = $debbugs::gDefaultSeverity if ($severity eq '');
191 next unless defined $section{${pending} . "_" . ${severity}};
192 $result .= "<HR><H2>$debbugs::gSeverityDisplay{$severity} - $displayshowpending{$pending}</H2>\n";
193 $result .= "(A list of <a href=\"http://www.debian.org/Bugs/db/si/$pending$severity\">all such bugs</a> is available).\n";
195 $result .= $section{$pending . "_" . $severity};
196 $result .= "</UL>\n";
197 $anydone = 1 if ($pending eq "done");
201 $result .= $debbugs::gHTMLExpireNote if ($anydone);
206 my $submitter = shift;
209 ($subemail = $d{"submitter"}) =~ s/\s*\(.*\)\s*//;
210 if ($subemail =~ m/<(.*)>/) { $subemail = $1 }
211 return $subemail eq $submitter;
213 return getbugs($chk);
218 my $severity = shift;
221 return ($d{"severity"} eq $severity) && ($d{"status"} eq $status);
223 return getbugs($chk);
228 my %maintainers = getmaintainers();
231 ($maintemail = $maintainers{$d{"pkg"}} || "") =~ s/\s*\(.*\)\s*//;
232 if ($maintemail =~ m/<(.*)>/) { $maintemail = $1 }
233 return $maintemail eq $maint;
235 return getbugs($chk);
240 my %maintainers = getmaintainers();
241 return getbugs(sub {my %d=@_; return maintencoded($maintainers{$d{"pkg"}} || "") eq $maint});
246 return getbugs( sub { my %d = @_; return $inpkg eq $d{"pkg"} });
252 if ( $common_archive ) {
253 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
255 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
261 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.+)$/) {
262 if ($bugfunc->(pkg => $1, bug => $2, status => $4, submitter => $5,
263 severity => $6, title => $7))
270 return sort {$a <=> $b} @result;
275 if ( $common_archive ) {
276 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
278 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
281 $descstr{ $1 } = 1 if (m/^(\S+)/);
290 while ($input =~ m/\W/) {
291 $encoded.=$`.sprintf("-%02x_",unpack("C",$&));
296 $encoded =~ s/-2e_/\./g;
297 $encoded =~ s/^([^,]+)-20_-3c_(.*)-40_(.*)-3e_/$1,$2,$3,/;
298 $encoded =~ s/^(.*)-40_(.*)-20_-28_([^,]+)-29_$/,$1,$2,$3/;
299 $encoded =~ s/-20_/_/g;
300 $encoded =~ s/-([^_]+)_-/-$1/g;
307 open(MM,"$gMaintainerFile") or &quit("open $gMaintainerFile: $!");
309 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
324 unless (open(S,"$gSpoolDir/db/$bugnum.status")) {
325 my $archdir = sprintf "%02d", $bugnum % 100;
326 open(S,"$gSpoolDir/archive/$archdir/$bugnum.status" ) or return ();
328 my @lines = qw(originator date subject msgid package tags done
329 forwarded mergedwith severity);
332 $status{shift @lines} = $_;
335 $status{shift @lines} = '' while(@lines);
337 $status{"package"} =~ s/\s*$//;
338 $status{"package"} = 'unknown' if ($status{"package"} eq '');
339 $status{"severity"} = 'normal' if ($status{"severity"} eq '');
341 $status{"pending"} = 'pending';
342 $status{"pending"} = 'forwarded' if (length($status{"forwarded"}));
343 $status{"pending"} = 'done' if (length($status{"done"}));
352 $res = "$gSpoolDir/db/$bugnum.log";
353 return $res if ( -e $res );
355 my $archdir = sprintf "%02d", $bugnum % 100;
356 $res = "$gSpoolDir/archive/$archdir/$bugnum.log";
357 return $res if ( -e $res );