#!/usr/bin/perl -wT package debbugs; use strict; use POSIX qw(strftime tzset nice); #require '/usr/lib/debbugs/errorlib'; require './common.pl'; require '/etc/debbugs/config'; require '/etc/debbugs/text'; nice(5); my %param = readparse(); my $indexon = $param{'indexon'} || 'pkg'; if ($indexon !~ m/^(pkg|src|maint|submitter|tag)$/) { 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 %maintainers = %{&getmaintainers()}; my %strings = (); $ENV{"TZ"} = 'UTC'; tzset(); my $dtime = strftime "%a, %e %b %Y %T UTC", localtime; my $tail_html = $debbugs::gHTMLTail; $tail_html = $debbugs::gHTMLTail; $tail_html =~ s/SUBSTITUTE_DTIME/$dtime/; set_option("repeatmerged", $repeatmerged); set_option("archive", $archive); #set_option("include", { map {($_,1)} (split /[\s,]+/, $include) }) # if ($include); #set_option("exclude", { map {($_,1)} (split /[\s,]+/, $exclude) }) # if ($exclude); my %count; my $tag; my $note; my %htmldescrip = (); my %sortkey = (); if ($indexon eq "pkg") { $tag = "package"; %count = countbugs(sub {my %d=@_; return splitpackages($d{"pkg"})}); $note = "

Note that with multi-binary packages there may be other\n"; $note .= "reports filed under the different binary package names.

\n"; foreach my $pkg (keys %count) { $sortkey{$pkg} = lc $pkg; $htmldescrip{$pkg} = sprintf('%s (%s)', pkgurl($pkg), htmlsanit($pkg), htmlmaintlinks(sub { $_[0] == 1 ? 'maintainer: ' : 'maintainers: ' }, $maintainers{$pkg})); } } 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('%s (%s)', srcurl($src), htmlsanit($src), htmlmaintlinks(sub { $_[0] == 1 ? 'maintainer: ' : 'maintainers: ' }, $maintainers{$src})); } } elsif ($indexon eq "maint") { $tag = "maintainer"; my %email2maint = (); %count = countbugs(sub {my %d=@_; return map { my @me = getparsedaddrs($maintainers{$_}); foreach my $addr (@me) { $email2maint{$addr->address} = $addr->format unless exists $email2maint{$addr->address}; } map { $_->address } @me; } splitpackages($d{"pkg"}); }); $note = "

Note that maintainers may use different Maintainer fields for\n"; $note .= "different packages, so there may be other reports filed under\n"; $note .= "different addresses.

\n"; foreach my $maint (keys %count) { $sortkey{$maint} = lc $email2maint{$maint} || "(unknown)"; $htmldescrip{$maint} = htmlmaintlinks('', $email2maint{$maint}); } } elsif ($indexon eq "submitter") { $tag = "submitter"; my %fullname = (); %count = countbugs(sub {my %d=@_; my $f = $d{"submitter"} || ""; my $em = emailfromrfc822($f); $fullname{$em} = $f if (!defined $fullname{$em}); return $em; }); foreach my $sub (keys %count) { $sortkey{$sub} = lc $fullname{$sub}; $htmldescrip{$sub} = sprintf('%s', submitterurl($sub), htmlsanit($fullname{$sub})); } $note = "

Note that people may use different email accounts for\n"; $note .= "different bugs, so there may be other reports filed under\n"; $note .= "different addresses.

\n"; } elsif ($indexon eq "tag") { $tag = "tag"; %count = countbugs(sub {my %d=@_; return split ' ', $d{tags}; }); $note = ""; foreach my $keyword (keys %count) { $sortkey{$keyword} = lc $keyword; $htmldescrip{$keyword} = sprintf('%s', tagurl($keyword), htmlsanit($keyword)); } } my $result = "\n"; print "Content-Type: text/html\n\n"; print "\n"; print "\n" . "$debbugs::gProject$Archived $debbugs::gBug reports by $tag\n" . "\n" . '' . "\n"; print "

" . "$debbugs::gProject$Archived $debbugs::gBug report logs by $tag" . "

\n"; print $note; print $result; print "
\n"; print "$tail_html"; print "\n";