+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 $cat = $opts->{cat};
+
+ 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 = $cat->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} = $cat->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, $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 => $opts->{cat}->g("Not available") };
+ }
+ }
+}
+
+