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|maint|submitter)$/) {
20 quit("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 quit("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 $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> '
66 . '(maintainer: <a href="%s">%s</a>)',
69 mainturl($maintainers{$pkg}),
70 htmlsanit($maintainers{$pkg} || "(unknown)"));
72 } elsif ($indexon eq "maint") {
74 %count = countbugs(sub {my %d=@_;
75 return emailfromrfc822($maintainers{$d{"pkg"}} || "");
77 $note = "<p>Note that maintainers may use different Maintainer fields for\n";
78 $note .= "different packages, so there may be other reports filed under\n";
79 $note .= "different addresses.</p>\n";
81 for my $x (values %maintainers) {
82 my $y = emailfromrfc822($x);
83 $email2maint{$y} = $x unless (defined $email2maint{$y});
85 foreach my $maint (keys %count) {
86 $sortkey{$maint} = lc $email2maint{$maint} || "(unknown)";
87 $htmldescrip{$maint} = sprintf('<a href="%s">%s</a>',
89 htmlsanit($email2maint{$maint}) || "(unknown)")
91 } elsif ($indexon eq "submitter") {
94 %count = countbugs(sub {my %d=@_; my $f = $d{"submitter"} || "";
95 my $em = emailfromrfc822($f);
96 $fullname{$em} = $f if (!defined $fullname{$em});
99 foreach my $sub (keys %count) {
100 $sortkey{$sub} = lc $fullname{$sub};
101 $htmldescrip{$sub} = sprintf('<a href="%s">%s</a>',
103 htmlsanit($fullname{$sub}));
105 $note = "<p>Note that people may use different email accounts for\n";
106 $note .= "different bugs, so there may be other reports filed under\n";
107 $note .= "different addresses.</p>\n";
110 my $result = "<ul>\n";
112 if ($sortby eq "count") {
113 @orderedentries = sort { $count{$a} <=> $count{$b} } keys %count;
114 } else { # sortby alpha
115 @orderedentries = sort { $sortkey{$a} cmp $sortkey{$b} } keys %count;
117 foreach my $x (@orderedentries) {
118 $result .= "<li>" . $htmldescrip{$x} . " has $count{$x} " .
119 ($count{$x} == 1 ? "bug" : "bugs") . "</li>\n";
121 $result .= "</ul>\n";
123 print "Content-Type: text/html\n\n";
125 print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
126 print "<HTML><HEAD>\n" .
127 "<TITLE>$debbugs::gProject$Archived $debbugs::gBug reports by $tag</TITLE>\n" .
129 '<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#800080">' .
131 print "<H1>" . "$debbugs::gProject$Archived $debbugs::gBug report logs by $tag" .
140 print "</body></html>\n";