From: Vincent Pit Date: Wed, 15 Dec 2010 23:20:01 +0000 (+0100) Subject: Put recursive dependencies into PDEPEND sections X-Git-Tag: v0.11~8 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=4a91012c4ecca558dfb145019d834b4c53746f51;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git Put recursive dependencies into PDEPEND sections --- diff --git a/lib/CPANPLUS/Dist/Gentoo.pm b/lib/CPANPLUS/Dist/Gentoo.pm index a1fe7b6..cc57cbd 100644 --- a/lib/CPANPLUS/Dist/Gentoo.pm +++ b/lib/CPANPLUS/Dist/Gentoo.pm @@ -136,6 +136,7 @@ my $default_keywords; my $default_distdir; my $main_portdir; +my %dependencies; my %forced; my $unquote = sub { @@ -195,7 +196,8 @@ sub init { $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 @@ -368,6 +370,9 @@ sub prepare { 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( @@ -554,19 +559,58 @@ Returns the source of the ebuild for the current dist object, or C when o =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( @@ -603,7 +647,9 @@ sub ebuild_source { $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;