]> git.donarmstrong.com Git - debbugs.git/blobdiff - cgi/pkgindex.cgi
[project @ 2003-05-21 20:04:42 by cjwatson]
[debbugs.git] / cgi / pkgindex.cgi
index b4e1a9d9d5e6525832e22c7f80de8f12652b7ae1..dc0af76788c45731fb2891e665f4dba144e900bc 100755 (executable)
@@ -6,8 +6,7 @@ use strict;
 use POSIX qw(strftime tzset nice);
 
 #require '/usr/lib/debbugs/errorlib';
-#require '/usr/lib/debbugs/common.pl';
-require '/debian/home/ajt/newajbug/common.pl';
+require './common.pl';
 
 require '/etc/debbugs/config';
 require '/etc/debbugs/text';
@@ -17,18 +16,23 @@ nice(5);
 my %param = readparse();
 
 my $indexon = $param{'indexon'} || 'pkg';
-if ($indexon !~ m/^(pkg|maint|submitter)/) {
-    quit("You have to choose something to index on");
+if ($indexon !~ m/^(pkg|src|maint|submitter)$/) {
+    quitcgi("You have to choose something to index on");
 }
 
 my $repeatmerged = ($param{'repeatmerged'} || "yes") eq "yes";
 my $archive = ($param{'archive'} || "no") eq "yes";
+my $sortby = $param{'sortby'} || 'alpha';
+if ($sortby !~ m/^(alpha|count)$/) {
+    quitcgi("Don't know how to sort like that");
+}
+
 #my $include = $param{'include'} || "";
 #my $exclude = $param{'exclude'} || "";
 
-my $Archived = $archive ? "Archived" : "";
+my $Archived = $archive ? " Archived" : "";
 
-my %maintainers = &getmaintainers();
+my %maintainers = %{&getmaintainers()};
 my %strings = ();
 
 $ENV{"TZ"} = 'UTC';
@@ -53,7 +57,7 @@ my %htmldescrip = ();
 my %sortkey = ();
 if ($indexon eq "pkg") {
   $tag = "package";
-  %count = countbugs(sub {my %d=@_; return $d{"pkg"}});
+  %count = countbugs(sub {my %d=@_; return splitpackages($d{"pkg"})});
   $note = "<p>Note that with multi-binary packages there may be other\n";
   $note .= "reports filed under the different binary package names.</p>\n";
   foreach my $pkg (keys %count) {
@@ -65,10 +69,30 @@ if ($indexon eq "pkg") {
                            mainturl($maintainers{$pkg}),
                           htmlsanit($maintainers{$pkg} || "(unknown)"));
   }
+} elsif ($indexon eq "src") {
+  $tag = "source package";
+  my $pkgsrc = getpkgsrc();
+  %count = countbugs(sub {my %d=@_;
+                          return map {
+                            $pkgsrc->{$_} || $_
+                          } splitpackages($d{"pkg"});
+                         });
+  $note = "";
+  foreach my $src (keys %count) {
+    $sortkey{$src} = lc $src;
+    $htmldescrip{$src} = sprintf('<a href="%s">%s</a> '
+                           . '(maintainer: <a href="%s">%s</a>)',
+                           srcurl($src),
+                           htmlsanit($src),
+                           mainturl($maintainers{$src}),
+                           htmlsanit($maintainers{$src} || "(unknown)"));
+  }
 } elsif ($indexon eq "maint") {
   $tag = "maintainer";
   %count = countbugs(sub {my %d=@_; 
-                          return emailfromrfc822($maintainers{$d{"pkg"}} || "");
+                          return map {
+                            emailfromrfc822($maintainers{$_}) || ()
+                          } splitpackages($d{"pkg"});
                         });
   $note = "<p>Note that maintainers may use different Maintainer fields for\n";
   $note .= "different packages, so there may be other reports filed under\n";
@@ -104,7 +128,13 @@ if ($indexon eq "pkg") {
 }
 
 my $result = "<ul>\n";
-foreach my $x (sort { $sortkey{$a} cmp $sortkey{$b} } keys %count) {
+my @orderedentries;
+if ($sortby eq "count") {
+  @orderedentries = sort { $count{$a} <=> $count{$b} } keys %count;
+} else { # sortby alpha
+  @orderedentries = sort { $sortkey{$a} cmp $sortkey{$b} } keys %count;
+}
+foreach my $x (@orderedentries) {
   $result .= "<li>" . $htmldescrip{$x} . " has $count{$x} " .
             ($count{$x} == 1 ? "bug" : "bugs") . "</li>\n";
 }
@@ -112,12 +142,13 @@ $result .= "</ul>\n";
 
 print "Content-Type: text/html\n\n";
 
-print "<HTML><HEAD><TITLE>\n" . 
-    "$debbugs::gProject $Archived $debbugs::gBug reports by $tag\n" .
-    "</TITLE></HEAD>\n" .
+print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
+print "<HTML><HEAD>\n" . 
+    "<TITLE>$debbugs::gProject$Archived $debbugs::gBug reports by $tag</TITLE>\n" .
+    "</HEAD>\n" .
     '<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#0000FF" VLINK="#800080">' .
     "\n";
-print "<H1>" . "$debbugs::gProject $Archived $debbugs::gBug report logs by $tag" .
+print "<H1>" . "$debbugs::gProject$Archived $debbugs::gBug report logs by $tag" .
       "</H1>\n";
 
 print $note;