X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FCPANPLUS%2FDist%2FGentoo.pm;h=5f7545f99581049312c7ec5795124051aee564db;hb=eefbd51540c659904876258e2b74dbbcfda37072;hp=55a51cf3115ad688b4eca9c1f1a15d6fcc705ad1;hpb=ba772ef86983b0403d1aa6de8cfd47935e5bc6b2;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git
diff --git a/lib/CPANPLUS/Dist/Gentoo.pm b/lib/CPANPLUS/Dist/Gentoo.pm
index 55a51cf..5f7545f 100644
--- a/lib/CPANPLUS/Dist/Gentoo.pm
+++ b/lib/CPANPLUS/Dist/Gentoo.pm
@@ -3,13 +3,13 @@ package CPANPLUS::Dist::Gentoo;
use strict;
use warnings;
-use Cwd qw/abs_path/;
+use Cwd ();
use List::Util qw/reduce/;
use File::Copy ();
use File::Path ();
use File::Spec;
-use IPC::Cmd qw/run can_run/;
+use IPC::Cmd ();
use Parse::CPAN::Meta ();
use CPANPLUS::Error ();
@@ -150,7 +150,7 @@ sub format_available {
return $format_available if defined $format_available;
for my $prog (qw/emerge ebuild/) {
- unless (can_run($prog)) {
+ unless (IPC::Cmd::can_run($prog)) {
__PACKAGE__->_abort("$prog is required to write ebuilds");
return $format_available = 0;
}
@@ -158,21 +158,23 @@ sub format_available {
if (IPC::Cmd->can_capture_buffer) {
my $buffers;
- my ($success, $errmsg) = run command => [ qw/emerge --info/ ],
- verbose => 0,
- buffer => \$buffers;
+ my ($success, $errmsg) = IPC::Cmd::run(
+ command => [ qw/emerge --info/ ],
+ verbose => 0,
+ buffer => \$buffers,
+ );
if ($success) {
if ($buffers =~ /^PORTDIR_OVERLAY=(.*)$/m) {
- $overlays = [ map abs_path($_), split ' ', $unquote->($1) ];
+ $overlays = [ map Cwd::abs_path($_), split ' ', $unquote->($1) ];
}
if ($buffers =~ /^ACCEPT_KEYWORDS=(.*)$/m) {
$default_keywords = [ split ' ', $unquote->($1) ];
}
if ($buffers =~ /^DISTDIR=(.*)$/m) {
- $default_distdir = abs_path($unquote->($1));
+ $default_distdir = Cwd::abs_path($unquote->($1));
}
if ($buffers =~ /^PORTDIR=(.*)$/m) {
- $main_portdir = abs_path($unquote->($1));
+ $main_portdir = Cwd::abs_path($unquote->($1));
}
} else {
__PACKAGE__->_abort($errmsg);
@@ -191,6 +193,7 @@ sub init {
my $conf = $self->parent->parent->configure_object;
$stat->mk_accessors(qw/name version author distribution desc uri src license
+ meta
fetched_arch requires
ebuild_name ebuild_version ebuild_dir ebuild_file
portdir_overlay
@@ -252,11 +255,11 @@ sub prepare {
$stat->footer($footer);
my $overlay = delete $opts{overlay};
- $overlay = (defined $overlay) ? abs_path $overlay : '/usr/local/portage';
+ $overlay = (defined $overlay) ? Cwd::abs_path($overlay) : '/usr/local/portage';
$stat->overlay($overlay);
my $distdir = delete $opts{distdir};
- $distdir = (defined $distdir) ? abs_path $distdir : $default_distdir;
+ $distdir = (defined $distdir) ? Cwd::abs_path($distdir) : $default_distdir;
$stat->distdir($distdir);
return $FAIL->("distdir isn't writable") if $stat->do_manifest && !-w $distdir;
@@ -363,6 +366,36 @@ sub prepare {
return $OK->();
}
+=head2 C
+
+Returns the contents of the F or F files as parsed by L.
+
+=cut
+
+sub meta {
+ my $self = shift;
+ my $mod = $self->parent;
+ my $stat = $self->status;
+
+ my $meta = $stat->meta;
+ return $meta if defined $meta;
+
+ my $extract_dir = $mod->status->extract;
+
+ for my $name (qw/META.json META.yml/) {
+ my $meta_file = File::Spec->catdir($extract_dir, $name);
+ next unless -e $meta_file;
+
+ my $meta = eval { Parse::CPAN::Meta::LoadFile($meta_file) };
+ if (defined $meta) {
+ $stat->meta($meta);
+ return $meta;
+ }
+ }
+
+ return;
+}
+
=head2 C
Returns an array reference to a list of Gentoo licences identifiers under which the current distribution is released.
@@ -388,20 +421,10 @@ sub intuit_license {
return \@licenses if @licenses;
}
- my $extract_dir = $mod->status->extract;
-
- for my $meta_file (qw/META.json META.yml/) {
- my $meta = eval {
- Parse::CPAN::Meta::LoadFile(File::Spec->catdir(
- $extract_dir,
- $meta_file,
- ));
- } or next;
- my $license = $meta->{license};
- if (defined $license) {
- my @licenses = CPANPLUS::Dist::Gentoo::Maps::license_c2g($license);
- return \@licenses if @licenses;
- }
+ my $license = $self->meta->{license};
+ if (defined $license) {
+ my @licenses = CPANPLUS::Dist::Gentoo::Maps::license_c2g($license);
+ return \@licenses if @licenses;
}
return [ CPANPLUS::Dist::Gentoo::Maps::license_c2g('perl') ];
@@ -621,7 +644,10 @@ sub _run {
my ($success, $errmsg, $output) = do {
local $ENV{PORTDIR_OVERLAY} = join ' ', @{$stat->portdir_overlay};
local $ENV{PORTAGE_RO_DISTDIRS} = $stat->distdir;
- run command => $cmd, verbose => $verbose;
+ IPC::Cmd::run(
+ command => $cmd,
+ verbose => $verbose,
+ );
};
unless ($success) {