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 return htmlsanit($url);
179 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
180 my $in = shift || "";
182 while ($in =~ m/[<>&"]/) {
183 $out .= $`. '&'. $saniarray{$&}. ';';
192 my $params = "bug=$ref";
193 foreach my $val (@_) {
194 $params .= "\&msg=$1" if ($val =~ /^msg=([0-9]+)/);
195 $params .= "\&archive=yes" if (!$common_archive && $val =~ /^archive.*$/);
197 $params .= "&archive=yes" if ($common_archive);
198 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
200 return urlsanit($debbugs::gCGIDomain . "bugreport.cgi" . "?" . "$params");
205 return urlsanit($debbugs::gCGIDomain . "package.cgi" . "?" . "package=$ref");
211 opendir(D, "$debbugs::gSpoolDir/db") or &quit("opendir db: $!");
212 @bugs = sort {$a<=>$b} grep s/\.status$//,
213 (grep m/^[0-9]+\.status$/,
226 my %displayshowpending = ("pending", "outstanding",
227 "pending-fixed", "pending upload",
228 "fixed", "fixed in NMU",
230 "forwarded", "forwarded to upstream software authors");
233 return "<HR><H2>No reports found!</H2></HR>\n";
236 foreach my $bug (sort {$a<=>$b} @bugs) {
237 my %status = %{getbugstatus($bug)};
239 my @merged = sort {$a<=>$b} ($bug, split(/ /, $status{mergedwith}));
240 next unless ($common_repeatmerged || $bug == $merged[0]);
241 if (%common_include) {
243 foreach my $t (split /\s+/, $status{tags}) {
244 $okay = 1, last if (defined $common_include{$t});
246 if (defined $common_include{subj}) {
247 if (index($status{subject}, $common_include{subj}) > -1) {
253 if (%common_exclude) {
255 foreach my $t (split /\s+/, $status{tags}) {
256 $okay = 0, last if (defined $common_exclude{$t});
258 if (defined $common_exclude{subj}) {
259 if (index($status{subject}, $common_exclude{subj}) > -1) {
266 $section{$status{pending} . "_" . $status{severity}} .=
267 sprintf "<li><a href=\"%s\">#%d: %s</a>\n<br>",
268 bugurl($bug), $bug, htmlsanit($status{subject});
269 $section{$status{pending} . "_" . $status{severity}} .=
270 htmlindexentrystatus(\%status) . "\n";
275 foreach my $pending (qw(pending forwarded pending-fixed fixed done)) {
276 foreach my $severity(@debbugs::gSeverityList) {
277 $severity = $debbugs::gDefaultSeverity if ($severity eq '');
278 next unless defined $section{${pending} . "_" . ${severity}};
279 $result .= "<HR><H2>$debbugs::gSeverityDisplay{$severity} - $displayshowpending{$pending}</H2>\n";
280 #$result .= "(A list of <a href=\"http://${debbugs::gWebDomain}/db/si/$pending$severity\">all such bugs</a> is available).\n";
281 $result .= "(A list of all such bugs used to be available).\n";
283 $result .= $section{$pending . "_" . $severity};
284 $result .= "</UL>\n";
285 $anydone = 1 if ($pending eq "done");
289 $result .= $debbugs::gHTMLExpireNote if ($anydone);
295 if ($common_archive) {
296 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
298 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
304 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
305 my $x = $bugfunc->(pkg => $1, bug => $2, status => $4,
306 submitter => $5, severity => $6, tags => $7);
320 if (!$common_archive && defined $opt &&
321 -e "$debbugs::gSpoolDir/by-$opt.idx")
324 print STDERR "optimized\n" if ($debug);
325 tie %lookup, DB_File => "$debbugs::gSpoolDir/by-$opt.idx", O_RDONLY
326 or die "$0: can't open $debbugs::gSpoolDir/by-$opt.idx ($!)\n";
327 while ($key = shift) {
328 my $bugs = $lookup{$key};
330 push @result, (unpack 'N*', $bugs);
334 print STDERR "done optimized\n" if ($debug);
336 if ( $common_archive ) {
337 open I, "<$debbugs::gSpoolDir/index.archive"
338 or &quit("bugindex: $!");
340 open I, "<$debbugs::gSpoolDir/index.db"
341 or &quit("bugindex: $!");
344 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
345 if ($bugfunc->(pkg => $1, bug => $2, status => $4,
346 submitter => $5, severity => $6, tags => $7))
354 @result = sort {$a <=> $b} @result;
358 sub emailfromrfc822 {
360 $email =~ s/\s*\(.*\)\s*//;
361 $email = $1 if ($email =~ m/<(.*)>/);
369 while ($input =~ m/\W/) {
370 $encoded.=$`.sprintf("-%02x_",unpack("C",$&));
375 $encoded =~ s/-2e_/\./g;
376 $encoded =~ s/^([^,]+)-20_-3c_(.*)-40_(.*)-3e_/$1,$2,$3,/;
377 $encoded =~ s/^(.*)-40_(.*)-20_-28_([^,]+)-29_$/,$1,$2,$3/;
378 $encoded =~ s/-20_/_/g;
379 $encoded =~ s/-([^_]+)_-/-$1/g;
386 open(MM,"$gMaintainerFile") or &quit("open $gMaintainerFile: $!");
388 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
394 open(MM,"$gMaintainerFileOverride") or &quit("open $gMaintainerFileOverride: $!");
396 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
409 open(MM,"$gPackageSource") or &quit("open $gPackageSource: $!");
411 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
422 my ( $bugnum, $ext ) = @_;
423 my $archdir = sprintf "%02d", $bugnum % 100;
424 foreach ( ( "$gSpoolDir/db-h/$archdir", "$gSpoolDir/db", "$gSpoolDir/archive/$archdir" ) ) {
425 return $_ if ( -r "$_/$bugnum.$ext" );
435 my $dir = getbugdir( $bugnum, "status" );
436 return {} if ( !$dir );
437 open S, "< $dir/$bugnum.status";
438 my @lines = qw(originator date subject msgid package tags done
439 forwarded mergedwith severity);
442 $status{shift @lines} = $_;
445 $status{shift @lines} = '' while(@lines);
447 $status{"package"} =~ s/\s*$//;
448 $status{"package"} = 'unknown' if ($status{"package"} eq '');
449 $status{"severity"} = 'normal' if ($status{"severity"} eq '');
451 $status{"pending"} = 'pending';
452 $status{"pending"} = 'forwarded' if (length($status{"forwarded"}));
453 $status{"pending"} = 'fixed' if ($status{"tags"} =~ /\bfixed\b/);
454 $status{"pending"} = 'pending-fixed' if ($status{"tags"} =~ /\bpending\b/);
455 $status{"pending"} = 'done' if (length($status{"done"}));
463 my %pkgsrc = %{getpkgsrc()};
465 foreach ( keys %pkgsrc ) {
466 push @pkgs, $_ if $pkgsrc{$_} eq $src;
474 my $dir = getbugdir( $bugnum, "log" );
475 return "" if ( !$dir );
476 return "$dir/$bugnum.log";