-my %displayshowpending = ('pending','outstanding',
- 'done','resolved',
- 'forwarded','forwarded to upstream software authors');
-
-my $dtime=`date -u '+%H:%M:%S GMT %a %d %h'`;
-chomp($dtime);
-my $tail_html = $debbugs::gHTMLTail;
-$tail_html =~ s/SUBSTITUTE_DTIME/$dtime/;
-
-
-print header;
-if( $archive )
-{ print start_html("$debbugs::gProject Archived $debbugs::gBug report logs: package $pkg");
- print h1("$debbugs::gProject Archived $debbugs::gBug report logs: package $pkg");
-} else
-{ print start_html("$debbugs::gProject $debbugs::gBug report logs: package $pkg");
- print h1("$debbugs::gProject $debbugs::gBug report logs: package $pkg");
-}
-
-#if (defined $maintainer{$pkg}) {
-# print "<p>Maintainer for $pkg is <a href=\""
-# . mainturl($maintainer{$pkg}) . "\">"
-# . htmlsanit($maintainer{$pkg}) . "</a>.</p>\n";
-#}
-
-print "<p>Note that with multi-binary packages there may be other reports\n";
-print "filed under the different binary package names.</p>\n";
-
-if ( $pkg ne 'ALL' )
-{ %strings = pkgbugs($pkg, $archive);
- foreach my $bug ( keys %strings )
- { $this .= " <LI><A href=\"" . bugurl($bug, "archive=$archive") . "\">". $strings{ $bug } ."</A>\n"; }
-} else
-{ %strings = pkgbugsindex( $archive );
- my @bugs = ();
- foreach my $bug ( keys %strings ) { push @bugs, $bug; }
- @bugs = sort { $a cmp $b } @bugs;
- foreach my $bug ( @bugs )
- { $this .= " <LI><A HREF=\"http://cgi.debian.org/cgi-bin/pkgreport.cgi?pkg=". $bug ."&archive=$arc\">". $bug . "\n"; }
-}
-
-if ( length( $this ) )
-{ print "<UL>\n";
- print $this;
- print "</UL>\n";
-} else
-{ print "No archived reports found\n"; }
-
-print hr;
-print "$tail_html";
-
-print end_html;
+my @bugs;
+
+# addusers for source and binary packages being searched for
+my $pkgsrc = getpkgsrc();
+my $srcpkg = getsrcpkgs();
+for my $package (# For binary packages, add the binary package
+ # and corresponding source package
+ make_list($param{package}||[]),
+ (map {defined $pkgsrc->{$_}?($pkgsrc->{$_}):()}
+ make_list($param{package}||[]),
+ ),
+ # For source packages, add the source package
+ # and corresponding binary packages
+ make_list($param{src}||[]),
+ (map {defined $srcpkg->{$_}?($srcpkg->{$_}):()}
+ make_list($param{src}||[]),
+ ),
+ ) {
+ next unless defined $package;
+ add_user($package.'@'.$config{usertag_package_domain},
+ \%ut,\%bugusertags,\%seen_users,\%cats,\%hidden)
+ if defined $config{usertag_package_domain};
+}
+
+
+# walk through the keys and make the right get_bugs query.
+
+my $form_option_variables = {};
+$form_option_variables->{search_key_order} = [@package_search_key_order];
+
+# Set the title sanely and clean up parameters
+my @title;
+my @temp = @package_search_key_order;
+while (my ($key,$value) = splice @temp, 0, 2) {
+ next unless exists $param{$key};
+ my @entries = ();
+ for my $entry (make_list($param{$key})) {
+ # we'll handle newest below
+ next if $key eq 'newest';
+ my $extra = '';
+ if (exists $param{dist} and ($key eq 'package' or $key eq 'src')) {
+ my %versions = get_versions(package => $entry,
+ (exists $param{dist}?(dist => $param{dist}):()),
+ (exists $param{arch}?(arch => $param{arch}):(arch => $config{default_architectures})),
+ ($key eq 'src'?(arch => q(source)):()),
+ no_source_arch => 1,
+ return_archs => 1,
+ );
+ my $verdesc;
+ if (keys %versions > 1) {
+ $verdesc = 'versions '. join(', ',
+ map { $_ .' ['.join(', ',
+ sort @{$versions{$_}}
+ ).']';
+ } keys %versions);
+ }
+ else {
+ $verdesc = 'version '.join(', ',
+ keys %versions
+ );
+ }
+ $extra= " ($verdesc)" if keys %versions;
+ }
+ if ($key eq 'maint' and $entry eq '') {
+ push @entries, "no one (packages without maintainers)"
+ }
+ else {
+ push @entries, $entry.$extra;
+ }
+ }
+ push @title,$value.' '.join(' or ', @entries) if @entries;
+}
+if (defined $param{newest}) {
+ my $newest_bug = newest_bug();
+ @bugs = ($newest_bug - $param{newest} + 1) .. $newest_bug;
+ push @title, 'in '.@bugs.' newest reports';
+ $param{bugs} = [exists $param{bugs}?make_list($param{bugs}):(),
+ @bugs,
+ ];
+}
+
+my $title = $gBugs.' '.join(' and ', map {/ or /?"($_)":$_} @title);
+@title = ();
+
+#yeah for magick!
+@bugs = get_bugs((map {exists $param{$_}?($_,$param{$_}):()}
+ grep {$_ ne 'newest'}
+ keys %package_search_keys, 'archive'),
+ usertags => \%ut,
+ );
+
+# shove in bugs which affect this package if there is a package or a
+# source given (by default), but no affects options given
+if (not exists $param{affects} and not exists $param{noaffects} and
+ (exists $param{src} or
+ exists $param{package})) {
+ push @bugs, get_bugs((map {my $key = $_;
+ exists $param{$key}?($key =~ /^(?:package|src)$/?'affects':$key,
+ ($key eq 'src'?[map {"src:$_"}make_list($param{$key})]:$param{$_})):()}
+ grep {$_ ne 'newest'}
+ keys %package_search_keys, 'archive'),
+ usertags => \%ut,
+ );
+}
+
+# filter out included or excluded bugs
+
+
+if (defined $param{version}) {
+ $title .= " at version $param{version}";
+}
+elsif (defined $param{dist}) {
+ $title .= " in $param{dist}";
+}
+
+$title = html_escape($title);
+
+my @names; my @prior; my @order;
+determine_ordering(cats => \%cats,
+ param => \%param,
+ ordering => \$ordering,
+ names => \@names,
+ prior => \@prior,
+ title => \@title,
+ order => \@order,
+ );
+
+# strip out duplicate bugs
+my %bugs;
+@bugs{@bugs} = @bugs;
+@bugs = keys %bugs;
+
+my $result = pkg_htmlizebugs(bugs => \@bugs,
+ names => \@names,
+ title => \@title,
+ order => \@order,
+ prior => \@prior,
+ ordering => $ordering,
+ bugusertags => \%bugusertags,
+ bug_rev => $bug_rev,
+ bug_order => $bug_order,
+ repeatmerged => $param{repeatmerged},
+ include => $include,
+ exclude => $exclude,
+ this => $this,
+ options => \%param,
+ (exists $param{dist})?(dist => $param{dist}):(),
+ );
+
+print "Cache-Control: public, max-age=300\n";
+print "Content-Type: text/html; charset=utf-8\n\n";
+
+print "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
+print "<HTML><HEAD>\n" .
+ "<TITLE>$title -- $gProject$Archived $gBug report logs</TITLE>\n" .
+ qq(<link rel="stylesheet" href="$gWebHostBugDir/css/bugs.css" type="text/css">) .
+ "</HEAD>\n" .
+ '<BODY onload="pagemain();">' .
+ "\n";
+print qq(<DIV id="status_mask"></DIV>\n);
+print "<H1>" . "$gProject$Archived $gBug report logs: $title" .
+ "</H1>\n";
+
+my $showresult = 1;
+
+my $pkg = $param{package} if defined $param{package};
+my $src = $param{src} if defined $param{src};
+
+my $pseudodesc = getpseudodesc();
+if (defined $pseudodesc and defined $pkg and exists $pseudodesc->{$pkg}) {
+ delete $param{dist};
+}
+
+# output information about the packages
+
+for my $package (make_list($param{package}||[])) {
+ print generate_package_info(binary => 1,
+ package => $package,
+ options => \%param,
+ bugs => \@bugs,
+ );
+}
+for my $package (make_list($param{src}||[])) {
+ print generate_package_info(binary => 0,
+ package => $package,
+ options => \%param,
+ bugs => \@bugs,
+ );
+}
+
+if (exists $param{maint} or exists $param{maintenc}) {
+ print "<p>Note that maintainers may use different Maintainer fields for\n";
+ print "different packages, so there may be other reports filed under\n";
+ print "different addresses.\n";
+}
+if (exists $param{submitter}) {
+ print "<p>Note that people may use different email accounts for\n";
+ print "different bugs, so there may be other reports filed under\n";
+ print "different addresses.\n";
+}
+
+print $result;
+
+print fill_in_template(template=>'cgi/pkgreport_javascript');
+
+print qq(<h2 class="outstanding"><!--<a class="options" href="javascript:toggle(1)">-->Options<!--</a>--></h2>\n);
+
+$param{orderings} =
+ [uniq((grep {!$hidden{$_}} keys %cats),
+ $param{ordering})];
+print option_form(template => 'cgi/pkgreport_options',
+ param => \%param,
+ form_options => $form_options,
+ variables => $form_option_variables,
+ );
+
+print "<hr>\n";
+print fill_in_template(template=>'html/html_tail',
+ hole_var => {'&strftime' => \&POSIX::strftime,
+ },
+ );
+print "</body></html>\n";
+