]> git.donarmstrong.com Git - debbugs.git/blob - cgi/pkgindex.cgi
[project @ 2000-11-17 11:46:07 by ajt]
[debbugs.git] / cgi / pkgindex.cgi
1 #!/usr/bin/perl -wT
2
3 package debbugs;
4
5 use strict;
6 use POSIX qw(strftime tzset nice);
7
8 #require '/usr/lib/debbugs/errorlib';
9 #require '/usr/lib/debbugs/common.pl';
10 require '/debian/home/ajt/newajbug/common.pl';
11
12 require '/etc/debbugs/config';
13 require '/etc/debbugs/text';
14
15 nice(5);
16
17 my %param = readparse();
18
19 my $indexon = $param{'indexon'} || 'pkg';
20 if ($indexon !~ m/^(pkg|maint|submitter)/) {
21     quit("You have to choose something to index on");
22 }
23
24 my $repeatmerged = ($param{'repeatmerged'} || "yes") eq "yes";
25 my $archive = ($param{'archive'} || "no") eq "yes";
26 #my $include = $param{'include'} || "";
27 #my $exclude = $param{'exclude'} || "";
28
29 my $Archived = $archive ? "Archived" : "";
30
31 my %maintainers = &getmaintainers();
32 my %strings = ();
33
34 $ENV{"TZ"} = 'UTC';
35 tzset();
36
37 my $dtime = strftime "%a, %e %b %Y %T UTC", localtime;
38 my $tail_html = $debbugs::gHTMLTail;
39 $tail_html = $debbugs::gHTMLTail;
40 $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/;
41
42 set_option("repeatmerged", $repeatmerged);
43 set_option("archive", $archive);
44 #set_option("include", { map {($_,1)} (split /[\s,]+/, $include) })
45 #       if ($include);
46 #set_option("exclude", { map {($_,1)} (split /[\s,]+/, $exclude) })
47 #       if ($exclude);
48
49 my %count;
50 my $tag;
51 my $note;
52 my %htmldescrip = ();
53 my %sortkey = ();
54 if ($indexon eq "pkg") {
55   $tag = "package";
56   %count = countbugs(sub {my %d=@_; return $d{"pkg"}});
57   $note = "<p>Note that with multi-binary packages there may be other\n";
58   $note .= "reports filed under the different binary package names.</p>\n";
59   foreach my $pkg (keys %count) {
60     $sortkey{$pkg} = lc $pkg;
61     $htmldescrip{$pkg} = sprintf('<a href="%s">%s</a> ' 
62                            . '(maintainer: <a href="%s">%s</a>)',
63                            pkgurl($pkg),
64                            htmlsanit($pkg),
65                            mainturl($maintainers{$pkg}),
66                            htmlsanit($maintainers{$pkg} || "(unknown)"));
67   }
68 } elsif ($indexon eq "maint") {
69   $tag = "maintainer";
70   %count = countbugs(sub {my %d=@_; 
71                           return emailfromrfc822($maintainers{$d{"pkg"}} || "");
72                          });
73   $note = "<p>Note that maintainers may use different Maintainer fields for\n";
74   $note .= "different packages, so there may be other reports filed under\n";
75   $note .= "different addresses.</p>\n";
76   my %email2maint = ();
77   for my $x (values %maintainers) {
78     my $y = emailfromrfc822($x);
79     $email2maint{$y} = $x unless (defined $email2maint{$y});
80   }
81   foreach my $maint (keys %count) {
82     $sortkey{$maint} = lc $email2maint{$maint} || "(unknown)";
83     $htmldescrip{$maint} = sprintf('<a href="%s">%s</a>',
84                            mainturl($maint),
85                            htmlsanit($email2maint{$maint}) || "(unknown)")
86   }
87 } elsif ($indexon eq "submitter") {
88   $tag = "submitter";
89   my %fullname = ();
90   %count = countbugs(sub {my %d=@_; my $f = $d{"submitter"} || "";
91                           my $em = emailfromrfc822($f);
92                           $fullname{$em} = $f if (!defined $fullname{$em});
93                           return $em;
94                         });
95   foreach my $sub (keys %count) {
96     $sortkey{$sub} = lc $fullname{$sub};
97     $htmldescrip{$sub} = sprintf('<a href="%s">%s</a>',
98                            submitterurl($sub),
99                            htmlsanit($fullname{$sub}));
100   }
101   $note = "<p>Note that people may use different email accounts for\n";
102   $note .= "different bugs, so there may be other reports filed under\n";
103   $note .= "different addresses.</p>\n";
104 }
105
106 my $result = "<ul>\n";
107 foreach my $x (sort { $sortkey{$a} cmp $sortkey{$b} } keys %count) {
108   $result .= "<li>" . $htmldescrip{$x} . " has $count{$x} bugs</li>\n";
109 }
110 $result .= "</ul>\n";
111
112 print "Content-Type: text/html\n\n";
113
114 print "<HTML><HEAD><TITLE>\n" . 
115     "$debbugs::gProject $Archived $debbugs::gBug reports by $tag\n" .
116     "</TITLE></HEAD>\n" .
117     '<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#800080">' .
118     "\n";
119 print "<H1>" . "$debbugs::gProject $Archived $debbugs::gBug report logs by $tag" .
120       "</H1>\n";
121
122 print $note;
123 print $result;
124
125 print "<hr>\n";
126 print "$tail_html";
127
128 print "</body></html>\n";