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 ();
=head1 VERSION
-Version 0.08
+Version 0.09
=cut
-our $VERSION = '0.08';
+our $VERSION = '0.09';
=head1 SYNOPSIS
First, fetch tarballs for L<CPANPLUS> and L<CPANPLUS::Dist::Gentoo> :
$ cd /tmp
- $ wget http://search.cpan.org/CPAN/authors/id/K/KA/KANE/CPANPLUS-0.88.tar.gz
- $ wget http://search.cpan.org/CPAN/authors/id/V/VP/VPIT/CPANPLUS-Dist-Gentoo-0.08.tar.gz
+ $ 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.09.tar.gz
Log in as root and unpack them in e.g. your home directory :
# cd
- # tar xzf /tmp/CPANPLUS-0.88.tar.gz
- # tar xzf /tmp/CPANPLUS-Dist-Gentoo-0.08.tar.gz
+ # tar xzf /tmp/CPANPLUS-0.9003.tar.gz
+ # tar xzf /tmp/CPANPLUS-Dist-Gentoo-0.09.tar.gz
Set up environment variables so that the toolchain is temporarily available :
# export OLDPATH=$PATH
- # export PATH=/root/CPANPLUS-0.88/bin:$PATH
- # export PERL5LIB=/root/CPANPLUS-Dist-Gentoo-0.08/blib/lib:/root/CPANPLUS-0.88/lib:/root/CPANPLUS-0.88/inc/bundle
+ # export PATH=/root/CPANPLUS-0.9003/bin:$PATH
+ # export PERL5LIB=/root/CPANPLUS-Dist-Gentoo-0.09/blib/lib:/root/CPANPLUS-0.9003/lib:/root/CPANPLUS-0.9003/inc/bundle
Make sure you don't have an old C<.cpanplus> configuration visible :
Bootstrap L<CPANPLUS> :
- # cd /root/CPANPLUS-Dist-Gentoo-0.08
+ # cd /root/CPANPLUS-Dist-Gentoo-0.09
# samples/g-cpanp CPANPLUS
Reset the environment :
At this point, you can bootstrap L<CPANPLUS::Dist::Gentoo> using the system L<CPANPLUS> :
- # PERL5LIB=/root/CPANPLUS-Dist-Gentoo-0.08/blib/lib samples/g-cpanp CPANPLUS::Dist::Gentoo
+ # PERL5LIB=/root/CPANPLUS-Dist-Gentoo-0.09/blib/lib samples/g-cpanp CPANPLUS::Dist::Gentoo
# emerge -tv CPANPLUS-Dist-Gentoo
=back
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;
}
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);
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
$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;
$stat->prepared(0);
- $self->SUPER::prepare(%opts);
+ $self->SUPER::prepare(@_);
return $FAIL->() unless $stat->prepared;
return $OK->();
}
+=head2 C<meta>
+
+Returns the contents of the F<META.yml> or F<META.json> files as parsed by L<Parse::CPAN::Meta>.
+
+=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<intuit_license>
Returns an array reference to a list of Gentoo licences identifiers under which the current distribution is released.
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') ];
"$name-*.ebuild",
) or next;
- my @atoms = map CPANPLUS::Dist::Gentoo::Atom->new(
- defined $version ? (
- ebuild => $_,
- range => '>=',
- ) : (
- category => $category,
- name => $name,
- ),
- ), @ebuilds;
+ my $last = reduce { $a < $b ? $b : $a } # handles overloading
+ map CPANPLUS::Dist::Gentoo::Atom->new_from_ebuild($_),
+ @ebuilds;
+ next if defined $version and $last < $version;
- my $atom = reduce { $a < $b ? $b : $a } @atoms; # handles overloading
- next if defined $version and $atom < $version;
-
- return $atom;
+ return CPANPLUS::Dist::Gentoo::Atom->new(
+ category => $last->category,
+ name => $last->name,
+ (defined $version ? (version => $version, range => '>=') : ()),
+ ebuild => $last->ebuild,
+ );
}
}
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) {
=head1 COPYRIGHT & LICENSE
-Copyright 2008-2009 Vincent Pit, all rights reserved.
+Copyright 2008,2009,2010 Vincent Pit, all rights reserved.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.