my $default_distdir;
my $main_portdir;
+my %dependencies;
my %forced;
my $unquote = sub {
$stat->mk_accessors(qw/name version author distribution desc uri src license
meta min_perl
- fetched_arch requires configure_requires
+ fetched_arch
+ requires configure_requires recursive_requires
ebuild_name ebuild_version ebuild_dir ebuild_file
portdir_overlay
overlay distdir keywords do_manifest header footer
my $mstat = $mod->status;
$stat->configure_requires($int->$filter_prereqs($mstat->configure_requires));
$stat->requires($int->$filter_prereqs($mstat->requires));
+ $stat->recursive_requires([ ]);
+
+ $dependencies{$name} = [ map $_->[0], @{ $stat->requires } ];
my $meta = $self->meta;
$stat->min_perl(CPANPLUS::Dist::Gentoo::Maps::perl_version_c2g(
=cut
+my $dep_tree_contains;
+{
+ my %seen;
+
+ $dep_tree_contains = sub {
+ my ($dist, $target) = @_;
+
+ return 0 if $seen{$dist};
+ local $seen{$dist} = 1;
+
+ for my $kid (@{ $dependencies{$dist} }) {
+ return 1 if $kid eq $target
+ or $dep_tree_contains->($kid, $target);
+ }
+
+ return 0;
+ }
+}
+
sub ebuild_source {
my $self = shift;
my $stat = $self->status;
+ {
+ my $name = $stat->name;
+ my %recursive_kids = map { $_ => 1 }
+ grep $dep_tree_contains->($_, $name),
+ @{ $dependencies{$name} };
+ if (%recursive_kids) {
+ my (@requires, @recursive_requires);
+ for (@{ $stat->requires }) {
+ if ($recursive_kids{$_->[0]}) {
+ push @recursive_requires, $_;
+ } else {
+ push @requires, $_;
+ }
+ }
+ $stat->requires(\@requires);
+ $stat->recursive_requires(\@recursive_requires);
+ }
+ }
+
# We must resolve the deps now and not inside prepare because _cpan2portage
# has to see the ebuilds already generated for the dependencies of the current
# dist.
- my (@configure_requires, @requires);
+ my (@configure_requires, @requires, @recursive_requires);
my @phases = (
[ configure_requires => \@configure_requires ],
[ requires => \@requires ],
+ [ recursive_requires => \@recursive_requires ],
);
push @requires, CPANPLUS::Dist::Gentoo::Atom->new(
$d .= "SLOT=\"0\"\n";
$d .= 'LICENSE="|| ( ' . join(' ', sort @{$stat->license}) . " )\"\n";
$d .= 'KEYWORDS="' . join(' ', sort @{$stat->keywords}) . "\"\n";
- $d .= 'RDEPEND="' . join("\n", sort @requires) . "\"\n";
+ $d .= 'RDEPEND="' . join("\n", sort @requires) . "\"\n" if @requires;
+ $d .= 'PDEPEND="' . join("\n", sort @recursive_requires) . "\"\n"
+ if @recursive_requires;
$d .= 'DEPEND="' . join("\n", '${RDEPEND}', sort @configure_requires) . "\"\n";
$d .= "SRC_TEST=\"do\"\n";
$d .= $stat->footer;