4 use Fcntl qw/O_RDONLY/;
6 my $common_archive = 0;
7 my $common_repeatmerged = 1;
8 my %common_include = ();
9 my %common_exclude = ();
10 my $common_raw_sort = 0;
16 if ($opt eq "archive") { $common_archive = $val; }
17 if ($opt eq "repeatmerged") { $common_repeatmerged = $val; }
18 if ($opt eq "exclude") { %common_exclude = %{$val}; }
19 if ($opt eq "include") { %common_include = %{$val}; }
20 if ($opt eq "raw") { $common_raw_sort = $val; }
24 my ($in, $key, $val, %ret);
25 if (defined $ENV{"QUERY_STRING"} && $ENV{"QUERY_STRING"} ne "") {
26 $in=$ENV{QUERY_STRING};
27 } elsif(defined $ENV{"REQUEST_METHOD"}
28 && $ENV{"REQUEST_METHOD"} eq "POST")
30 read(STDIN,$in,$ENV{CONTENT_LENGTH});
34 foreach (split(/&/,$in)) {
36 ($key, $val) = split(/=/,$_,2);
37 $key=~s/%(..)/pack("c",hex($1))/ge;
38 $val=~s/%(..)/pack("c",hex($1))/ge;
39 if ( exists $ret{$key} ) {
40 if ( !exists $ret{"&$key"} ) {
41 $ret{"&$key"} = [ $ret{$key} ];
43 push @{$ret{"&$key"}},$val;
47 $debug = 1 if (defined $ret{"debug"} && $ret{"debug"} eq "aj");
53 print "Content-Type: text/html\n\n";
54 print "<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\n";
55 print "An error occurred. Dammit.\n";
56 print "Error was: $msg.\n";
57 print "</BODY></HTML>\n";
63 # my $Archive = $common_archive ? "archive" : "";
64 # print header . start_html("Sorry");
65 # print "Sorry bug #$msg doesn't seem to be in the $Archive database.\n";
72 my %status = %{getbugstatus($ref)};
73 return htmlindexentrystatus(%status) if (%status);
77 sub htmlindexentrystatus {
83 if ($status{severity} eq 'normal') {
85 } elsif (grep($status{severity} eq $_, @debbugs::gStrongSeverities)) {
86 $showseverity = "<strong>Severity: $status{severity}</strong>;\n";
88 $showseverity = "Severity: <em>$status{severity}</em>;\n";
91 $result .= "Package: <a href=\"" . pkgurl($status{"package"}) . "\">"
92 . "<strong>" . htmlsanit($status{"package"}) . "</strong></a>;\n"
93 if (length($status{"package"}));
94 $result .= $showseverity;
95 $result .= "Reported by: " . htmlsanit($status{originator});
96 $result .= ";\nTags: <strong>"
97 . htmlsanit(join(", ", sort(split(/\s+/, $status{tags}))))
99 if (length($status{tags}));
101 my @merged= split(/ /,$status{mergedwith});
102 my $mseparator= ";\nmerged with ";
103 for my $m (@merged) {
104 $result .= $mseparator."<A href=\"" . bugurl($m) . "\">#$m</A>";
108 if (length($status{done})) {
109 $result .= ";\n<strong>Done:</strong> " . htmlsanit($status{done});
110 } elsif (length($status{forwarded})) {
111 $result .= ";\n<strong>Forwarded</strong> to "
112 . htmlsanit($status{forwarded});
114 my $daysold = int((time - $status{date}) / 86400); # seconds to days
118 $font = "em" if ($daysold > 30);
119 $font = "strong" if ($daysold > 60);
120 $efont = "</$font>" if ($font);
121 $font = "<$font>" if ($font);
123 my $yearsold = int($daysold / 364);
124 $daysold = $daysold - $yearsold * 364;
126 $result .= ";\n $font";
127 $result .= "1 year and " if ($yearsold == 1);
128 $result .= "$yearsold years and " if ($yearsold > 1);
129 $result .= "1 day old" if ($daysold == 1);
130 $result .= "$daysold days old" if ($daysold != 1);
141 my $ref = shift || "";
142 my $params = "submitter=" . emailfromrfc822($ref);
143 $params .= "&archive=yes" if ($common_archive);
144 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
145 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . $params);
149 my $ref = shift || "";
150 my $params = "maint=" . emailfromrfc822($ref);
151 $params .= "&archive=yes" if ($common_archive);
152 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
153 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . $params);
158 my $params = "pkg=$ref";
159 $params .= "&archive=yes" if ($common_archive);
160 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
162 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . "$params");
167 my $params = "src=$ref";
168 $params .= "&archive=yes" if ($common_archive);
169 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
170 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . "$params");
177 my %saniarray = ('<','lt', '>','gt', '"','quot');
179 while ($url =~ m/[<>"]/) {
180 $out .= $`. '&'. $saniarray{$&}. ';';
188 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
189 my $in = shift || "";
191 while ($in =~ m/[<>&"]/) {
192 $out .= $`. '&'. $saniarray{$&}. ';';
201 my $params = "bug=$ref";
202 foreach my $val (@_) {
203 $params .= "\&msg=$1" if ($val =~ /^msg=([0-9]+)/);
204 $params .= "\&archive=yes" if (!$common_archive && $val =~ /^archive.*$/);
206 $params .= "&archive=yes" if ($common_archive);
207 $params .= "&repeatmerged=yes" if ($common_repeatmerged);
209 return urlsanit($debbugs::gCGIDomain . "bugreport.cgi" . "?" . "$params");
214 return urlsanit($debbugs::gCGIDomain . "package.cgi" . "?" . "package=$ref");
220 opendir(D, "$debbugs::gSpoolDir/db") or &quit("opendir db: $!");
221 @bugs = sort {$a<=>$b} grep s/\.status$//,
222 (grep m/^[0-9]+\.status$/,
236 my %displayshowpending = ("pending", "outstanding",
237 "pending-fixed", "pending upload",
238 "fixed", "fixed in NMU",
240 "forwarded", "forwarded to upstream software authors");
243 return "<HR><H2>No reports found!</H2></HR>\n";
246 foreach my $bug (sort {$a<=>$b} @bugs) {
247 my %status = %{getbugstatus($bug)};
249 my @merged = sort {$a<=>$b} ($bug, split(/ /, $status{mergedwith}));
250 next unless ($common_repeatmerged || $bug == $merged[0]);
251 if (%common_include) {
253 foreach my $t (split /\s+/, $status{tags}) {
254 $okay = 1, last if (defined $common_include{$t});
256 if (defined $common_include{subj}) {
257 if (index($status{subject}, $common_include{subj}) > -1) {
263 if (%common_exclude) {
265 foreach my $t (split /\s+/, $status{tags}) {
266 $okay = 0, last if (defined $common_exclude{$t});
268 if (defined $common_exclude{subj}) {
269 if (index($status{subject}, $common_exclude{subj}) > -1) {
276 my $html = sprintf "<li><a href=\"%s\">#%d: %s</a>\n<br>",
277 bugurl($bug), $bug, htmlsanit($status{subject});
278 $html .= htmlindexentrystatus(\%status) . "\n";
279 $section{$status{pending} . "_" . $status{severity}} .= $html;
280 push @rawsort, $html if $common_raw_sort;
285 if ($common_raw_sort) {
286 $result .= "<UL>\n" . join("", @rawsort ) . "</UL>\n";
288 foreach my $pending (qw(pending forwarded pending-fixed fixed done)) {
289 foreach my $severity(@debbugs::gSeverityList) {
290 $severity = $debbugs::gDefaultSeverity if ($severity eq '');
291 next unless defined $section{${pending} . "_" . ${severity}};
292 $result .= "<HR><H2>$debbugs::gSeverityDisplay{$severity} - $displayshowpending{$pending}</H2>\n";
293 #$result .= "(A list of <a href=\"http://${debbugs::gWebDomain}/db/si/$pending$severity\">all such bugs</a> is available).\n";
294 $result .= "(A list of all such bugs used to be available).\n";
296 $result .= $section{$pending . "_" . $severity};
297 $result .= "</UL>\n";
298 $anydone = 1 if ($pending eq "done");
303 $result .= $debbugs::gHTMLExpireNote if ($anydone);
309 if ($common_archive) {
310 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
312 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
318 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
319 my $x = $bugfunc->(pkg => $1, bug => $2, status => $4,
320 submitter => $5, severity => $6, tags => $7);
334 if (!$common_archive && defined $opt &&
335 -e "$debbugs::gSpoolDir/by-$opt.idx")
338 print STDERR "optimized\n" if ($debug);
339 tie %lookup, DB_File => "$debbugs::gSpoolDir/by-$opt.idx", O_RDONLY
340 or die "$0: can't open $debbugs::gSpoolDir/by-$opt.idx ($!)\n";
341 while ($key = shift) {
342 my $bugs = $lookup{$key};
344 push @result, (unpack 'N*', $bugs);
348 print STDERR "done optimized\n" if ($debug);
350 if ( $common_archive ) {
351 open I, "<$debbugs::gSpoolDir/index.archive"
352 or &quit("bugindex: $!");
354 open I, "<$debbugs::gSpoolDir/index.db"
355 or &quit("bugindex: $!");
358 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
359 if ($bugfunc->(pkg => $1, bug => $2, status => $4,
360 submitter => $5, severity => $6, tags => $7))
368 @result = sort {$a <=> $b} @result;
372 sub emailfromrfc822 {
374 $email =~ s/\s*\(.*\)\s*//;
375 $email = $1 if ($email =~ m/<(.*)>/);
383 while ($input =~ m/\W/) {
384 $encoded.=$`.sprintf("-%02x_",unpack("C",$&));
389 $encoded =~ s/-2e_/\./g;
390 $encoded =~ s/^([^,]+)-20_-3c_(.*)-40_(.*)-3e_/$1,$2,$3,/;
391 $encoded =~ s/^(.*)-40_(.*)-20_-28_([^,]+)-29_$/,$1,$2,$3/;
392 $encoded =~ s/-20_/_/g;
393 $encoded =~ s/-([^_]+)_-/-$1/g;
399 return $_maintainer if $_maintainer;
402 open(MM,"$gMaintainerFile") or &quit("open $gMaintainerFile: $!");
404 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
410 open(MM,"$gMaintainerFileOverride") or &quit("open $gMaintainerFileOverride: $!");
412 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
418 $_maintainer = \%maintainer;
424 return $_pkgsrc if $_pkgsrc;
427 open(MM,"$gPackageSource") or &quit("open $gPackageSource: $!");
429 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
440 my ( $bugnum, $ext ) = @_;
441 my $archdir = sprintf "%02d", $bugnum % 100;
442 foreach ( ( "$gSpoolDir/db-h/$archdir", "$gSpoolDir/db", "$gSpoolDir/archive/$archdir" ) ) {
443 return $_ if ( -r "$_/$bugnum.$ext" );
453 my $dir = getbugdir( $bugnum, "status" );
454 return {} if ( !$dir );
455 open S, "< $dir/$bugnum.status";
456 my @lines = qw(originator date subject msgid package tags done
457 forwarded mergedwith severity);
460 $status{shift @lines} = $_;
463 $status{shift @lines} = '' while(@lines);
465 $status{"package"} =~ s/\s*$//;
466 $status{"package"} = 'unknown' if ($status{"package"} eq '');
467 $status{"severity"} = 'normal' if ($status{"severity"} eq '');
469 $status{"pending"} = 'pending';
470 $status{"pending"} = 'forwarded' if (length($status{"forwarded"}));
471 $status{"pending"} = 'fixed' if ($status{"tags"} =~ /\bfixed\b/);
472 $status{"pending"} = 'pending-fixed' if ($status{"tags"} =~ /\bpending\b/);
473 $status{"pending"} = 'done' if (length($status{"done"}));
481 my %pkgsrc = %{getpkgsrc()};
483 foreach ( keys %pkgsrc ) {
484 push @pkgs, $_ if $pkgsrc{$_} eq $src;
492 my $dir = getbugdir( $bugnum, "log" );
493 return "" if ( !$dir );
494 return "$dir/$bugnum.log";