6 use POSIX qw(strftime tzset nice);
8 #require '/usr/lib/debbugs/errorlib';
11 require '/etc/debbugs/config';
12 require '/etc/debbugs/text';
16 my %param = readparse();
18 my $indexon = $param{'indexon'} || 'pkg';
19 if ($indexon !~ m/^(pkg|src|maint|submitter)$/) {
20 quitcgi("You have to choose something to index on");
23 my $repeatmerged = ($param{'repeatmerged'} || "yes") eq "yes";
24 my $archive = ($param{'archive'} || "no") eq "yes";
25 my $sortby = $param{'sortby'} || 'alpha';
26 if ($sortby !~ m/^(alpha|count)$/) {
27 quitcgi("Don't know how to sort like that");
30 #my $include = $param{'include'} || "";
31 #my $exclude = $param{'exclude'} || "";
33 my $Archived = $archive ? " Archived" : "";
35 my %maintainers = %{&getmaintainers()};
41 my $dtime = strftime "%a, %e %b %Y %T UTC", localtime;
42 my $tail_html = $debbugs::gHTMLTail;
43 $tail_html = $debbugs::gHTMLTail;
44 $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/;
46 set_option("repeatmerged", $repeatmerged);
47 set_option("archive", $archive);
48 #set_option("include", { map {($_,1)} (split /[\s,]+/, $include) })
50 #set_option("exclude", { map {($_,1)} (split /[\s,]+/, $exclude) })
58 if ($indexon eq "pkg") {
60 %count = countbugs(sub {my %d=@_; return splitpackages($d{"pkg"})});
61 $note = "<p>Note that with multi-binary packages there may be other\n";
62 $note .= "reports filed under the different binary package names.</p>\n";
63 foreach my $pkg (keys %count) {
64 $sortkey{$pkg} = lc $pkg;
65 $htmldescrip{$pkg} = sprintf('<a href="%s">%s</a> (%s)',
68 htmlmaintlinks(sub { $_[0] == 1 ? 'maintainer: '
72 } elsif ($indexon eq "src") {
73 $tag = "source package";
74 my $pkgsrc = getpkgsrc();
75 %count = countbugs(sub {my %d=@_;
78 } splitpackages($d{"pkg"});
81 foreach my $src (keys %count) {
82 $sortkey{$src} = lc $src;
83 $htmldescrip{$src} = sprintf('<a href="%s">%s</a> (%s)',
86 htmlmaintlinks(sub { $_[0] == 1 ? 'maintainer: '
90 } elsif ($indexon eq "maint") {
93 %count = countbugs(sub {my %d=@_;
95 my @me = getparsedaddrs($maintainers{$_});
96 foreach my $addr (@me) {
97 $email2maint{$addr->address} = $addr->format
98 unless exists $email2maint{$addr->address};
100 map { $_->address } @me;
101 } splitpackages($d{"pkg"});
103 $note = "<p>Note that maintainers may use different Maintainer fields for\n";
104 $note .= "different packages, so there may be other reports filed under\n";
105 $note .= "different addresses.</p>\n";
106 foreach my $maint (keys %count) {
107 $sortkey{$maint} = lc $email2maint{$maint} || "(unknown)";
108 $htmldescrip{$maint} = htmlmaintlinks('', $email2maint{$maint});
110 } elsif ($indexon eq "submitter") {
113 %count = countbugs(sub {my %d=@_; my $f = $d{"submitter"} || "";
114 my $em = emailfromrfc822($f);
115 $fullname{$em} = $f if (!defined $fullname{$em});
118 foreach my $sub (keys %count) {
119 $sortkey{$sub} = lc $fullname{$sub};
120 $htmldescrip{$sub} = sprintf('<a href="%s">%s</a>',
122 htmlsanit($fullname{$sub}));
124 $note = "<p>Note that people may use different email accounts for\n";
125 $note .= "different bugs, so there may be other reports filed under\n";
126 $note .= "different addresses.</p>\n";
129 my $result = "<ul>\n";
131 if ($sortby eq "count") {
132 @orderedentries = sort { $count{$a} <=> $count{$b} } keys %count;
133 } else { # sortby alpha
134 @orderedentries = sort { $sortkey{$a} cmp $sortkey{$b} } keys %count;
136 foreach my $x (@orderedentries) {
137 $result .= "<li>" . $htmldescrip{$x} . " has $count{$x} " .
138 ($count{$x} == 1 ? "bug" : "bugs") . "</li>\n";
140 $result .= "</ul>\n";
142 print "Content-Type: text/html\n\n";
144 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
145 print "<HTML><HEAD>\n" .
146 "<TITLE>$debbugs::gProject$Archived $debbugs::gBug reports by $tag</TITLE>\n" .
148 '<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#800080">' .
150 print "<H1>" . "$debbugs::gProject$Archived $debbugs::gBug report logs by $tag" .
159 print "</body></html>\n";