use warnings;
use Cwd ();
-use List::Util qw/reduce/;
+use List::Util qw<reduce>;
use File::Copy ();
use File::Path ();
use File::Spec;
use CPANPLUS::Error ();
-use base qw/CPANPLUS::Dist::Base/;
+use base qw<CPANPLUS::Dist::Base>;
use CPANPLUS::Dist::Gentoo::Atom;
use CPANPLUS::Dist::Gentoo::Guard;
=item *
Use the perl overlay located at L<http://git.overlays.gentoo.org/gitweb/?p=proj/perl-overlay.git>.
-It contains an ebuild for L<CPANPLUS::Dist::Gentoo>.
+It contains an ebuild for L<CPANPLUS::Dist::Gentoo> which will most likely be up-to-date given the reactivity of Gentoo's Perl herd.
=item *
Bootstrap an ebuild for L<CPANPLUS::Dist::Gentoo> using itself.
-Note that if your Gentoo system C<perl> is C<5.8.x>, L<CPANPLUS> and its dependencies are not installed and not even available in the main portage tree.
-So you need to bootstrap them as well.
-First, fetch tarballs for L<CPANPLUS> and L<CPANPLUS::Dist::Gentoo> :
+First, make sure your system C<perl> is C<5.10> or greater, so that the L<CPANPLUS> toolchain is available.
- $ cd /tmp
- $ wget http://search.cpan.org/CPAN/authors/id/B/BI/BINGOS/CPANPLUS-0.9003.tar.gz
- $ wget http://search.cpan.org/CPAN/authors/id/V/VP/VPIT/CPANPLUS-Dist-Gentoo-0.10.tar.gz
-
-Log in as root and unpack them in e.g. your home directory :
-
- # cd
- # tar xzf /tmp/CPANPLUS-0.9003.tar.gz
- # tar xzf /tmp/CPANPLUS-Dist-Gentoo-0.10.tar.gz
-
-Set up environment variables so that the toolchain is temporarily available :
-
- # export OLDPATH=$PATH
- # export PATH=/root/CPANPLUS-0.9003/bin:$PATH
- # export PERL5LIB=/root/CPANPLUS-Dist-Gentoo-0.10/blib/lib:/root/CPANPLUS-0.9003/lib:/root/CPANPLUS-0.9003/inc/bundle
+ $ perl -v
+ This is perl 5, version 12, subversion 2 (v5.12.2) built for x86_64-linux
+ ...
-Make sure you don't have an old C<.cpanplus> configuration visible :
+C<perl> C<5.12> is the current stable Perl version in Gentoo.
+If you still have C<perl> C<5.8.x>, you can upgrade it by running the following commands as root :
- # [ -d /root/.cpanplus ] && mv /root/.cpanplus{,.bak}
+ # emerge -tv ">=dev-lang/perl-5.10"
+ # perl-cleaner --all
-Bootstrap L<CPANPLUS> :
+Then, fetch the L<CPANPLUS::Dist::Gentoo> tarball :
- # cd /root/CPANPLUS-Dist-Gentoo-0.10
- # samples/g-cpanp CPANPLUS
-
-Reset the environment :
-
- # export PATH=$OLDPATH
- # unset PERL5LIB OLDPATH
-
-Emerge L<CPANPLUS> with the ebuilds you've just generated :
+ $ cd /tmp
+ $ wget http://search.cpan.org/CPAN/authors/id/V/VP/VPIT/CPANPLUS-Dist-Gentoo-0.10.tar.gz
- # emerge -tv CPANPLUS
+Log in as root and unpack it in e.g. your home directory :
-As of september 2009, C<podlators> and C<ExtUtils-MakeMaker> may fail to emerge due to collisions.
-You can work around this by disabling the C<protect-owned> C<FEATURE> for them :
+ # cd
+ # tar xzf /tmp/CPANPLUS-Dist-Gentoo-0.10.tar.gz
+ # cd CPANPLUS-Dist-Gentoo-0.10
- # FEATURES="-protect-owned" emerge podlators
- # FEATURES="-protect-owned" emerge ExtUtils-MakeMaker
+Bootstrap L<CPANPLUS::Dist::Gentoo> using the bundled shell script C<g-cpanp> :
-You may need to run each of these commands two times for them to succeed.
+ # PERL5LIB=blib/lib samples/g-cpanp CPANPLUS::Dist::Gentoo
-At this point, you can bootstrap L<CPANPLUS::Dist::Gentoo> using the system L<CPANPLUS> :
+Finally, emerge the C<CPANPLUS-Dist-Gentoo> ebuild you've just generated :
- # PERL5LIB=/root/CPANPLUS-Dist-Gentoo-0.10/blib/lib samples/g-cpanp CPANPLUS::Dist::Gentoo
# emerge -tv CPANPLUS-Dist-Gentoo
=back
my $default_distdir;
my $main_portdir;
+my %dependencies;
my %forced;
my $unquote = sub {
sub format_available {
return $format_available if defined $format_available;
- for my $prog (qw/emerge ebuild/) {
+ for my $prog (qw<emerge ebuild>) {
unless (IPC::Cmd::can_run($prog)) {
__PACKAGE__->_abort("$prog is required to write ebuilds");
return $format_available = 0;
if (IPC::Cmd->can_capture_buffer) {
my $buffers;
my ($success, $errmsg) = IPC::Cmd::run(
- command => [ qw/emerge --info/ ],
+ command => [ qw<emerge --info> ],
verbose => 0,
buffer => \$buffers,
);
}
} else {
__PACKAGE__->_abort($errmsg);
+ return $format_available = 0;
}
}
my $stat = $self->status;
my $conf = $self->parent->parent->configure_object;
- $stat->mk_accessors(qw/name version author distribution desc uri src license
- meta min_perl
- fetched_arch requires configure_requires
- ebuild_name ebuild_version ebuild_dir ebuild_file
- portdir_overlay
- overlay distdir keywords do_manifest header footer
- force verbose/);
+ $stat->mk_accessors(qw<
+ name version author distribution desc uri src license
+ meta min_perl
+ fetched_arch
+ requires configure_requires recursive_requires
+ ebuild_name ebuild_version ebuild_dir ebuild_file
+ portdir_overlay overlay distdir keywords do_manifest header footer
+ force verbose
+ >);
$stat->force($conf->get_conf('force'));
$stat->verbose($conf->get_conf('verbose'));
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(
my $extract_dir = $mod->status->extract;
- for my $name (qw/META.json META.yml/) {
+ for my $name (qw<META.json META.yml>) {
my $meta_file = File::Spec->catdir($extract_dir, $name);
next unless -e $meta_file;
=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;
my @portdirs = ($main_portdir, @{$self->status->portdir_overlay});
- for my $category (qw/virtual perl-core dev-perl perl-gcpan/, CATEGORY) {
+ for my $category (qw<virtual perl-core dev-perl perl-gcpan>, CATEGORY) {
my $name = ($category eq 'virtual' ? 'perl-' : '') . $name;
for my $portdir (@portdirs) {