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;
11 my $common_bug_reverse = 0;
12 my $common_pending_reverse = 0;
13 my $common_severity_reverse = 0;
15 my @common_pending_include = ();
16 my @common_pending_exclude = ();
17 my @common_severity_include = ();
18 my @common_severity_exclude = ();
24 if ($opt eq "archive") { $common_archive = $val; }
25 if ($opt eq "repeatmerged") { $common_repeatmerged = $val; }
26 if ($opt eq "exclude") { %common_exclude = %{$val}; }
27 if ($opt eq "include") { %common_include = %{$val}; }
28 if ($opt eq "raw") { $common_raw_sort = $val; }
29 if ($opt eq "bug-rev") { $common_bug_reverse = $val; }
30 if ($opt eq "pend-rev") { $common_pending_reverse = $val; }
31 if ($opt eq "sev-rev") { $common_severity_reverse = $val; }
32 if ($opt eq "pend-exc") {
34 @vals = ( $val ) if (ref($val) eq "" && $val );
35 @vals = ( $$val ) if (ref($val) eq "SCALAR" && $$val );
36 @vals = @{$val} if (ref($val) eq "ARRAY" );
37 @common_pending_exclude = @vals if (@vals);
39 if ($opt eq "pend-inc") {
41 @vals = ( $val, ) if (ref($val) eq "" && $val );
42 @vals = ( $$val, ) if (ref($val) eq "SCALAR" && $$val );
43 @vals = @{$val} if (ref($val) eq "ARRAY" );
44 @common_pending_include = @vals if (@vals);
46 if ($opt eq "sev-exc") {
48 @vals = ( $val ) if (ref($val) eq "" && $val );
49 @vals = ( $$val ) if (ref($val) eq "SCALAR" && $$val );
50 @vals = @{$val} if (ref($val) eq "ARRAY" );
51 @common_severity_exclude = @vals if (@vals);
53 if ($opt eq "sev-inc") {
55 @vals = ( $val ) if (ref($val) eq "" && $val );
56 @vals = ( $$val ) if (ref($val) eq "SCALAR" && $$val );
57 @vals = @{$val} if (ref($val) eq "ARRAY" );
58 @common_severity_include = @vals if (@vals);
63 my ($in, $key, $val, %ret);
64 if (defined $ENV{"QUERY_STRING"} && $ENV{"QUERY_STRING"} ne "") {
65 $in=$ENV{QUERY_STRING};
66 } elsif(defined $ENV{"REQUEST_METHOD"}
67 && $ENV{"REQUEST_METHOD"} eq "POST")
69 read(STDIN,$in,$ENV{CONTENT_LENGTH});
73 foreach (split(/[&;]/,$in)) {
75 ($key, $val) = split(/=/,$_,2);
76 $key=~s/%(..)/pack("c",hex($1))/ge;
77 $val=~s/%(..)/pack("c",hex($1))/ge;
78 if ( exists $ret{$key} ) {
79 if ( !exists $ret{"&$key"} ) {
80 $ret{"&$key"} = [ $ret{$key} ];
82 push @{$ret{"&$key"}},$val;
86 $debug = 1 if (defined $ret{"debug"} && $ret{"debug"} eq "aj");
92 print "Content-Type: text/html\n\n";
93 print "<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\n";
94 print "An error occurred. Dammit.\n";
95 print "Error was: $msg.\n";
96 print "</BODY></HTML>\n";
102 # my $Archive = $common_archive ? "archive" : "";
103 # print header . start_html("Sorry");
104 # print "Sorry bug #$msg doesn't seem to be in the $Archive database.\n";
109 # Split a package string from the status file into a list of package names.
112 return unless defined $pkgs;
113 return split /[ \t?,()]+/, $pkgs;
116 # Generate a comma-separated list of HTML links to each package given in
117 # $pkgs. $pkgs may be empty, in which case an empty string is returned, or
118 # it may be a comma-separated list of package names.
119 sub htmlpackagelinks {
121 return unless defined $pkgs and $pkgs ne '';
123 my @pkglist = splitpackages($pkgs);
125 my $openstrong = $strong ? '<strong>' : '';
126 my $closestrong = $strong ? '</strong>' : '';
128 return 'Package' . (@pkglist > 1 ? 's' : '') . ': ' .
131 '<a href="' . pkgurl($_) . '">' .
132 $openstrong . htmlsanit($_) . $closestrong . '</a>'
139 my %status = %{getbugstatus($ref)};
140 return htmlindexentrystatus(%status) if (%status);
144 sub htmlindexentrystatus {
150 if ($status{severity} eq 'normal') {
152 } elsif (grep($status{severity} eq $_, @debbugs::gStrongSeverities)) {
153 $showseverity = "<strong>Severity: $status{severity}</strong>;\n";
155 $showseverity = "Severity: <em>$status{severity}</em>;\n";
158 $result .= htmlpackagelinks($status{"package"}, 1);
159 $result .= $showseverity;
160 $result .= "Reported by: <a href=\"" . submitterurl($status{originator})
161 . "\">" . htmlsanit($status{originator}) . "</a>";
162 $result .= ";\nTags: <strong>"
163 . htmlsanit(join(", ", sort(split(/\s+/, $status{tags}))))
165 if (length($status{tags}));
167 my @merged= split(/ /,$status{mergedwith});
168 my $mseparator= ";\nmerged with ";
169 for my $m (@merged) {
170 $result .= $mseparator."<A href=\"" . bugurl($m) . "\">#$m</A>";
174 if (length($status{done})) {
175 $result .= ";\n<strong>Done:</strong> " . htmlsanit($status{done});
176 } elsif (length($status{forwarded})) {
177 $result .= ";\n<strong>Forwarded</strong> to "
178 . htmlsanit($status{forwarded});
180 my $daysold = int((time - $status{date}) / 86400); # seconds to days
184 $font = "em" if ($daysold > 30);
185 $font = "strong" if ($daysold > 60);
186 $efont = "</$font>" if ($font);
187 $font = "<$font>" if ($font);
189 my $yearsold = int($daysold / 364);
190 $daysold = $daysold - $yearsold * 364;
192 $result .= ";\n $font";
194 push @age, "1 year" if ($yearsold == 1);
195 push @age, "$yearsold years" if ($yearsold > 1);
196 push @age, "1 day" if ($daysold == 1);
197 push @age, "$daysold days" if ($daysold > 1);
198 $result .= join(" and ", @age);
199 $result .= " old$efont";
209 my $ref = shift || "";
210 my $params = "submitter=" . emailfromrfc822($ref);
211 $params .= "&archive=yes" if ($common_archive);
212 $params .= "&repeatmerged=no" unless ($common_repeatmerged);
213 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . $params);
217 my $ref = shift || "";
218 my $params = "maint=" . emailfromrfc822($ref);
219 $params .= "&archive=yes" if ($common_archive);
220 $params .= "&repeatmerged=no" unless ($common_repeatmerged);
221 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . $params);
226 my $params = "pkg=$ref";
227 $params .= "&archive=yes" if ($common_archive);
228 $params .= "&repeatmerged=no" unless ($common_repeatmerged);
230 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . "$params");
235 my $params = "src=$ref";
236 $params .= "&archive=yes" if ($common_archive);
237 $params .= "&repeatmerged=no" unless ($common_repeatmerged);
238 return urlsanit($debbugs::gCGIDomain . "pkgreport.cgi" . "?" . "$params");
245 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
246 $url =~ s/([<>&"])/\&$saniarray{$1};/g;
251 my %saniarray = ('<','lt', '>','gt', '&','amp', '"','quot');
252 my $in = shift || "";
253 $in =~ s/([<>&"])/\&$saniarray{$1};/g;
259 my $params = "bug=$ref";
260 foreach my $val (@_) {
261 $params .= "\&msg=$1" if ($val =~ /^msg=([0-9]+)/);
262 $params .= "\&archive=yes" if (!$common_archive && $val =~ /^archive.*$/);
264 $params .= "&archive=yes" if ($common_archive);
265 $params .= "&repeatmerged=no" unless ($common_repeatmerged);
267 return urlsanit($debbugs::gCGIDomain . "bugreport.cgi" . "?" . "$params");
272 my $params = "bug=$ref";
274 foreach my $val (@_) {
275 $params .= "\&$1=$2" if ($val =~ /^(msg|att)=([0-9]+)/);
276 $filename = $1 if ($val =~ /^filename=(.*)$/);
278 $params .= "&archive=yes" if ($common_archive);
280 return urlsanit($debbugs::gCGIDomain . "bugreport.cgi/$filename?$params");
285 return urlsanit($debbugs::gCGIDomain . "bugreport.cgi" . "?" . "bug=$ref&mbox=yes");
291 opendir(D, "$debbugs::gSpoolDir/db") or &quit("opendir db: $!");
292 @bugs = sort {$a<=>$b} grep s/\.status$//,
293 (grep m/^[0-9]+\.status$/,
307 my %displayshowpending = ("pending", "outstanding",
308 "pending-fixed", "pending upload",
309 "fixed", "fixed in NMU",
311 "forwarded", "forwarded to upstream software authors");
314 return "<HR><H2>No reports found!</H2></HR>\n";
317 if ( $common_bug_reverse ) {
318 @bugs = sort {$b<=>$a} @bugs;
320 @bugs = sort {$a<=>$b} @bugs;
322 foreach my $bug (@bugs) {
323 my %status = %{getbugstatus($bug)};
325 my @merged = sort {$a<=>$b} ($bug, split(/ /, $status{mergedwith}));
326 next unless ($common_repeatmerged || $bug == $merged[0]);
327 if (%common_include) {
329 foreach my $t (split /\s+/, $status{tags}) {
330 $okay = 1, last if (defined $common_include{$t});
332 if (defined $common_include{subj}) {
333 if (index($status{subject}, $common_include{subj}) > -1) {
339 if (%common_exclude) {
341 foreach my $t (split /\s+/, $status{tags}) {
342 $okay = 0, last if (defined $common_exclude{$t});
344 if (defined $common_exclude{subj}) {
345 if (index($status{subject}, $common_exclude{subj}) > -1) {
351 next if @common_pending_include and
352 not grep { $_ eq $status{pending} } @common_pending_include;
353 next if @common_severity_include and
354 not grep { $_ eq $status{severity} } @common_severity_include;
355 next if grep { $_ eq $status{pending} } @common_pending_exclude;
356 next if grep { $_ eq $status{severity} } @common_severity_exclude;
358 my $html = sprintf "<li><a href=\"%s\">#%d: %s</a>\n<br>",
359 bugurl($bug), $bug, htmlsanit($status{subject});
360 $html .= htmlindexentrystatus(\%status) . "\n";
361 $section{$status{pending} . "_" . $status{severity}} .= $html;
362 push @rawsort, $html if $common_raw_sort;
367 if ($common_raw_sort) {
368 $result .= "<UL>\n" . join("", @rawsort ) . "</UL>\n";
370 my @pendingList = qw(pending forwarded pending-fixed fixed done);
371 @pendingList = reverse @pendingList if $common_pending_reverse;
372 #print STDERR join(",",@pendingList)."\n";
373 #print STDERR join(",",@common_pending_include).":$#common_pending_include\n";
374 foreach my $pending (@pendingList) {
375 my @severityList = @debbugs::gSeverityList;
376 @severityList = reverse @severityList if $common_severity_reverse;
377 #print STDERR join(",",@severityList)."\n";
379 # foreach my $severity(@debbugs::gSeverityList) {
380 foreach my $severity(@severityList) {
381 $severity = $debbugs::gDefaultSeverity if ($severity eq '');
382 next unless defined $section{${pending} . "_" . ${severity}};
383 $result .= "<HR><H2>$debbugs::gSeverityDisplay{$severity} - $displayshowpending{$pending}</H2>\n";
384 #$result .= "(A list of <a href=\"http://${debbugs::gWebDomain}/db/si/$pending$severity\">all such bugs</a> is available).\n";
385 $result .= "(A list of all such bugs used to be available).\n";
387 $result .= $section{$pending . "_" . $severity};
388 $result .= "</UL>\n";
389 $anydone = 1 if ($pending eq "done");
394 $result .= $debbugs::gHTMLExpireNote if ($anydone);
400 if ($common_archive) {
401 open I, "<$debbugs::gSpoolDir/index.archive" or &quit("bugindex: $!");
403 open I, "<$debbugs::gSpoolDir/index.db" or &quit("bugindex: $!");
409 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
410 my $x = $bugfunc->(pkg => $1, bug => $2, status => $4,
411 submitter => $5, severity => $6, tags => $7);
425 if (!$common_archive && defined $opt &&
426 -e "$debbugs::gSpoolDir/by-$opt.idx")
429 print STDERR "optimized\n" if ($debug);
430 tie %lookup, DB_File => "$debbugs::gSpoolDir/by-$opt.idx", O_RDONLY
431 or die "$0: can't open $debbugs::gSpoolDir/by-$opt.idx ($!)\n";
432 while ($key = shift) {
433 my $bugs = $lookup{$key};
435 push @result, (unpack 'N*', $bugs);
439 print STDERR "done optimized\n" if ($debug);
441 if ( $common_archive ) {
442 open I, "<$debbugs::gSpoolDir/index.archive"
443 or &quit("bugindex: $!");
445 open I, "<$debbugs::gSpoolDir/index.db"
446 or &quit("bugindex: $!");
449 if (m/^(\S+)\s+(\d+)\s+(\d+)\s+(\S+)\s+\[\s*([^]]*)\s*\]\s+(\w+)\s+(.*)$/) {
450 if ($bugfunc->(pkg => $1, bug => $2, status => $4,
451 submitter => $5, severity => $6, tags => $7))
459 @result = sort {$a <=> $b} @result;
463 sub emailfromrfc822 {
465 $email =~ s/\s*\(.*\)\s*//;
466 $email = $1 if ($email =~ m/<(.*)>/);
474 while ($input =~ m/\W/) {
475 $encoded.=$`.sprintf("-%02x_",unpack("C",$&));
480 $encoded =~ s/-2e_/\./g;
481 $encoded =~ s/^([^,]+)-20_-3c_(.*)-40_(.*)-3e_/$1,$2,$3,/;
482 $encoded =~ s/^(.*)-40_(.*)-20_-28_([^,]+)-29_$/,$1,$2,$3/;
483 $encoded =~ s/-20_/_/g;
484 $encoded =~ s/-([^_]+)_-/-$1/g;
490 return $_maintainer if $_maintainer;
493 open(MM,"$gMaintainerFile") or &quit("open $gMaintainerFile: $!");
495 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
501 open(MM,"$gMaintainerFileOverride") or &quit("open $gMaintainerFileOverride: $!");
503 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
509 $_maintainer = \%maintainer;
516 return $_pkgsrc if $_pkgsrc;
520 open(MM,"$gPackageSource") or &quit("open $gPackageSource: $!");
522 next unless m/^(\S+)\s+(\S+)\s+(\S.*\S)\s*$/;
523 ($a,$b,$c)=($1,$2,$3);
526 $pkgcomponent{$a}= $b;
530 $_pkgcomponent = \%pkgcomponent;
534 sub getpkgcomponent {
535 return $_pkgcomponent if $_pkgcomponent;
537 return $_pkgcomponent;
542 return $_pseudodesc if $_pseudodesc;
545 open(PSEUDO, "< $gPseudoDescFile") or &quit("open $gPseudoDescFile: $!");
547 next unless m/^(\S+)\s+(\S.*\S)\s*$/;
548 $pseudodesc{lc $1} = $2;
551 $_pseudodesc = \%pseudodesc;
556 my ( $bugnum, $ext ) = @_;
557 my $archdir = sprintf "%02d", $bugnum % 100;
558 foreach ( ( "$gSpoolDir/db-h/$archdir", "$gSpoolDir/db", "$gSpoolDir/archive/$archdir", "/debian/home/joeyh/tmp/infomagic-95/$archdir" ) ) {
559 return $_ if ( -r "$_/$bugnum.$ext" );
569 my $dir = getbugdir( $bugnum, "status" );
570 return {} if ( !$dir );
571 open S, "< $dir/$bugnum.status";
572 my @lines = qw(originator date subject msgid package tags done
573 forwarded mergedwith severity);
576 $status{shift @lines} = $_;
579 $status{shift @lines} = '' while(@lines);
581 $status{"package"} =~ s/\s*$//;
582 $status{"package"} = 'unknown' if ($status{"package"} eq '');
583 $status{"severity"} = 'normal' if ($status{"severity"} eq '');
585 $status{"pending"} = 'pending';
586 $status{"pending"} = 'forwarded' if (length($status{"forwarded"}));
587 $status{"pending"} = 'pending-fixed' if ($status{"tags"} =~ /\bpending\b/);
588 $status{"pending"} = 'fixed' if ($status{"tags"} =~ /\bfixed\b/);
589 $status{"pending"} = 'done' if (length($status{"done"}));
597 my %pkgsrc = %{getpkgsrc()};
599 foreach ( keys %pkgsrc ) {
600 push @pkgs, $_ if $pkgsrc{$_} eq $src;
608 my $dir = getbugdir( $bugnum, "log" );
609 return "" if ( !$dir );
610 return "$dir/$bugnum.log";