X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FCPANPLUS%2FDist%2FGentoo.pm;h=7f138049d1e21dc72a317d52e20a18292c729d9a;hb=02fbb17472e55a0862fea51d8f4e530a9af9153c;hp=5705c4afd7a414c3a8e904c378ac5a3b23678d99;hpb=85a840f8ea736c5ec7736847b2638d9d60743b96;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git diff --git a/lib/CPANPLUS/Dist/Gentoo.pm b/lib/CPANPLUS/Dist/Gentoo.pm index 5705c4a..7f13804 100644 --- a/lib/CPANPLUS/Dist/Gentoo.pm +++ b/lib/CPANPLUS/Dist/Gentoo.pm @@ -55,6 +55,8 @@ All the methods are inherited from L. Please refer to its use constant CATEGORY => 'perl-gcpanp'; +my $overlays; + sub format_available { for my $prog (qw/emerge ebuild/) { unless (can_run($prog)) { @@ -62,6 +64,24 @@ sub format_available { return 0; } } + + if (IPC::Cmd->can_capture_buffer) { + my ($success, $errmsg, $output) = run command => [ qw/emerge --info/ ], + verbose => 0; + if ($success) { + for (@{$output || []}) { + if (/^PORTDIR_OVERLAY=(.*)$/m) { + my $o = $1; + $o =~ s/^["']*//; + $o =~ s/["']*$//; + $overlays = [ map abs_path($_), grep length, split /:/, $o ]; + } + } + } else { + error $errmsg; + } + } + return 1; } @@ -72,6 +92,7 @@ sub init { $stat->mk_accessors(qw/name version author distribution desc uri src license deps eb_name eb_version eb_dir eb_file fetched_arch + portdir_overlay overlay distdir keywords do_manifest header footer force verbose/); @@ -207,6 +228,18 @@ sub prepare { } $stat->fetched_arch($mod->status->fetch); + my $cur = File::Spec::Functions::curdir(); + my $portdir_overlay; + for (@$overlays) { + if ($_ eq $overlay or File::Spec::Functions::abs2rel($overlay, $_) eq $cur) { + $portdir_overlay = join ':', @$overlays; + last; + } + } + $portdir_overlay = join ':', @$overlays, $overlay + unless defined $portdir_overlay; + $stat->portdir_overlay($portdir_overlay); + my $name = $mod->package_name; $stat->name($name); @@ -235,6 +268,8 @@ sub prepare { my $file = catfile($stat->eb_dir, $stat->eb_name . '-' . $stat->eb_version . '.ebuild'); + $stat->eb_file($file); + if (-e $file) { my $skip = 1; if ($stat->force) { @@ -254,7 +289,6 @@ sub prepare { return 1; } } - $stat->eb_file($file); $self->SUPER::prepare(%opts); @@ -427,7 +461,7 @@ sub _run { my $stat = $self->status; my ($success, $errmsg, $output) = do { - local $ENV{PORTDIR_OVERLAY} = $stat->overlay; + local $ENV{PORTDIR_OVERLAY} = $stat->portdir_overlay; local $ENV{PORTAGE_RO_DISTDIRS} = $stat->distdir; run command => $cmd, verbose => $verbose; };