+sub moreinfo {
+ my %info = @_;
+
+ my $name = $info{name} or return;
+ my $env = $info{env} or return;
+ my $opts = $info{opts} or return;
+ my $page = $info{data} or return;
+ my $contents = $info{vars} or return;
+ my $is_source = $info{is_source};
+ my $suite = $opts->{suite}[0];
+
+ my $source = $page->get_src( 'package' );
+ my $source_version = $page->get_src( 'version' );
+ my $src_dir = $page->get_src('directory');
+ if ($info{sourcedownload}) {
+ $contents->{src}{url} = make_url($source,'',{source=>'source'});
+ $contents->{src}{pkg} = $source;
+
+ my @downloads;
+ my $files = $page->get_src( 'files' );
+ if (defined($files) and @$files) {
+ foreach( @$files ) {
+ my ($src_file_md5, $src_file_size, $src_file_name) = split /\s/o, $_;
+ my ($server, $path);
+ $server = $env->{lc $page->get_newest('archive')}||$env->{us};
+ $path = "/$src_dir/$src_file_name";
+ push @downloads, { name => $src_file_name, server => $server, path => $path };
+ }
+ }
+ $contents->{src}{downloads} = \@downloads;
+ }
+
+ if ($info{changesandcopy}) {
+ if ( $src_dir ) {
+ (my $src_basename = $source_version) =~ s,^\d+:,,; # strip epoche
+ $src_basename = "${source}_$src_basename";
+ $src_dir =~ s,pool/updates,pool,o;
+
+ $contents->{files}{changelog}{path} = "$src_dir/$src_basename/changelog";
+ $contents->{files}{copyright}{path} = "$src_dir/$src_basename/".( $is_source ? 'copyright' : "$name.copyright" );
+ }
+ }
+
+ if ($info{maintainers}) {
+ my $uploaders = $page->get_src( 'uploaders' );
+ if ($uploaders && @$uploaders) {
+ my @maintainers = map { { name => $_->[0], mail => $_->[1] } } @$uploaders;
+ $contents->{maintainers} = \@maintainers;
+ }
+ }
+
+}
+
+sub providers {
+ my ($suite, $entry, $also) = @_;
+ my %tmp = map { $_ => 1 } split /\s/, $entry;
+ my @provided_by = keys %tmp; # weed out duplicates
+ my %out = ( also => $also,
+ pkgs => \@provided_by );
+ return \%out;
+}
+
+sub build_deps {
+ my ( $packages, $opts, $pkg, $relations, $type, $contents) = @_;
+ my %dep_type = ('depends' => 'dep', 'recommends' => 'rec',
+ 'suggests' => 'sug', 'build-depends' => 'adep',
+ 'build-depends-indep' => 'idep' );
+ my $suite = $opts->{suite}[0];
+
+ my %out = ( id => $dep_type{$type}, terms => [] );
+
+# use Data::Dumper;
+# debug( "print_deps called:\n".Dumper( $pkg, $relations, \$type ), 3 ) if DEBUG;
+
+ foreach my $rel (@$relations) {
+ my %rel_out;
+ $rel_out{is_old_pkgs} = $rel->[0];
+ $rel_out{alternatives} = [];
+
+ foreach my $rel_alt ( @$rel ) {
+ next unless ref($rel_alt);
+ my ( $p_name, $pkg_version, $arch_neg,
+ $arch_str, $subsection, $available ) = @$rel_alt;
+
+ if ($arch_str ||= '') {
+ if ($arch_neg) {
+ $arch_str = sprintf( _g("not %s"), "$arch_str" );
+ } else {
+ $arch_str = $arch_str;
+ }
+ }
+
+ my %rel_alt_out = ( name => $p_name,
+ version => $pkg_version,
+ arch_str => $arch_str,
+ arch_neg => $arch_neg );
+
+ my @results;
+ my %entries;
+ my $entry = $entries{$p_name} ||
+ read_entry_simple( $packages, $p_name, $opts->{h_archives}, $suite);
+ my $short_desc = $entry->[-1];
+ my $desc_md5 = $entry->[-2];
+ my $arch = $entry->[3];
+ my $archive = $entry->[1];
+ my $p_suite = $entry->[2];
+ if ( $short_desc ) {
+ $rel_alt_out{desc} = $short_desc;
+ my $trans_desc = $desctrans{$desc_md5};
+ if ($trans_desc) {
+ my %trans_desc = split /\000|\001/, $trans_desc;
+ my %sdescs;
+ while (my ($l, $d) = each %trans_desc) {
+ $d =~ s/\n.*//os;
+
+ $sdescs{$l} = $d;
+ }
+ $rel_alt_out{trans_desc} = \%sdescs;
+ }
+ $rel_alt_out{suite} = $p_suite;
+ if ( $rel_out{is_old_pkgs} ) {
+ } elsif (defined $entry->[1]) {
+ $entries{$p_name} ||= $entry;
+ $rel_alt_out{providers} = providers( $p_suite,
+ $entry->[0],
+ 1 ) if defined $entry->[0];
+ } elsif (defined $entry->[0]) {
+ $rel_alt_out{desc} = undef;
+ $rel_alt_out{providers} = providers( $p_suite,
+ $entry->[0] );
+ #FIXME: we don't handle virtual packages from
+ # the fallback suite correctly here
+ $rel_alt_out{suite} = $suite;
+ }
+ } elsif ( $rel_out{is_old_pkgs} ) {
+ } else {
+ $rel_alt_out{desc} = _g( "Package not available" );
+ $rel_alt_out{suite} = '';
+ }
+ push @{$rel_out{alternatives}}, \%rel_alt_out;
+ }
+
+ push @{$out{terms}}, \%rel_out;
+ }
+
+ $contents->{relations} ||= [];
+ push @{$contents->{relations}}, \%out if @{$out{terms}};
+} # end print_deps
+
+sub pkg_list {
+ my ( $packages, $opts, $pkgs, $lang, $list ) = @_;
+ my $suite = $opts->{suite}[0];
+
+ foreach my $p ( sort @$pkgs ) {
+
+ # we don't deal with virtual packages here because for the
+ # current uses of this function this isn't needed
+ my $data = read_entry_simple( $packages, $p, $opts->{h_archives}, $suite);
+ my ($desc_md5, $short_desc) = ($data->[-2],$data->[-1]);
+
+ if ( $short_desc ) {
+ my $trans_desc = $desctrans{$desc_md5};
+ my %sdescs;
+ if ($trans_desc) {
+ my %trans_desc = split /\000|\001/, $trans_desc;
+ while (my ($l, $d) = each %trans_desc) {
+ $d =~ s/\n.*//os;
+
+ $sdescs{$l} = $d;
+ }
+ }
+ push @$list, { name => $p, desc => $short_desc,
+ trans_desc => \%sdescs, available => 1 };
+ } else {
+ push @$list, { name => $p, desc => _g("Not available") };
+ }
+ }
+}
+
+