X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FCPANPLUS%2FDist%2FGentoo.pm;h=55a51cf3115ad688b4eca9c1f1a15d6fcc705ad1;hb=ba772ef86983b0403d1aa6de8cfd47935e5bc6b2;hp=a6b773407e4320fa3c55c3e342bc6709e636f526;hpb=0d54c05d27e53e16bc97eb47d63f11fc85e34f74;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git diff --git a/lib/CPANPLUS/Dist/Gentoo.pm b/lib/CPANPLUS/Dist/Gentoo.pm index a6b7734..55a51cf 100644 --- a/lib/CPANPLUS/Dist/Gentoo.pm +++ b/lib/CPANPLUS/Dist/Gentoo.pm @@ -16,6 +16,7 @@ use CPANPLUS::Error (); use base qw/CPANPLUS::Dist::Base/; +use CPANPLUS::Dist::Gentoo::Atom; use CPANPLUS::Dist::Gentoo::Maps; =head1 NAME @@ -24,11 +25,11 @@ CPANPLUS::Dist::Gentoo - CPANPLUS backend generating Gentoo ebuilds. =head1 VERSION -Version 0.08 +Version 0.09 =cut -our $VERSION = '0.08'; +our $VERSION = '0.09'; =head1 SYNOPSIS @@ -72,20 +73,20 @@ So you need to bootstrap them as well. First, fetch tarballs for L and L : $ 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-Dist-Gentoo-0.08/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 : @@ -93,7 +94,7 @@ Make sure you don't have an old C<.cpanplus> configuration visible : Bootstrap L : - # cd /root/CPANPLUS-Dist-Gentoo-0.08 + # cd /root/CPANPLUS-Dist-Gentoo-0.09 # samples/g-cpanp CPANPLUS Reset the environment : @@ -115,7 +116,7 @@ You may need to run each of these commands two times for them to succeed. At this point, you can bootstrap L using the system L : - # 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 @@ -315,15 +316,15 @@ sub prepare { 1 while unlink $file; } } else { - if (my @match = $self->_cpan2portage($name, $version)) { - $stat->dist($match[1]); + if (my $atom = $self->_cpan2portage($name, $version)) { + $stat->dist($atom->ebuild); return $SKIP->('Ebuild already generated for', $stat->distribution); } } $stat->prepared(0); - $self->SUPER::prepare(%opts); + $self->SUPER::prepare(@_); return $FAIL->() unless $stat->prepared; @@ -512,17 +513,21 @@ sub ebuild_source { # dist. my @requires; for (@{$stat->requires}) { - my $dep = $self->_cpan2portage(@$_); - unless (defined $dep) { + my $atom = $self->_cpan2portage(@$_); + unless (defined $atom) { $self->_abort( "Couldn't find an appropriate ebuild for $_->[0] in the portage tree" ); return; } - push @requires, $dep; + push @requires, $atom; } - @requires = do { my %seen; sort grep !$seen{$_}++, 'dev-lang/perl',@requires }; + my $perl = CPANPLUS::Dist::Gentoo::Atom->new( + category => 'dev-lang', + name => 'perl', + ); + @requires = CPANPLUS::Dist::Gentoo::Atom->fold($perl, @requires); my $d = $stat->header; $d .= "# Generated by CPANPLUS::Dist::Gentoo version $VERSION\n\n"; @@ -534,7 +539,7 @@ 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", @requires) . "\"\n"; + $d .= 'RDEPEND="' . join("\n", sort @requires) . "\"\n"; $d .= "DEPEND=\"\${RDEPEND}\"\n"; $d .= "SRC_TEST=\"do\"\n"; $d .= $stat->footer; @@ -545,37 +550,33 @@ sub ebuild_source { sub _cpan2portage { my ($self, $name, $version) = @_; - $name = CPANPLUS::Dist::Gentoo::Maps::name_c2g($name); - my $ver; - $ver = CPANPLUS::Dist::Gentoo::Maps::version_c2g($version) if defined $version; + $name = CPANPLUS::Dist::Gentoo::Maps::name_c2g($name); + $version = CPANPLUS::Dist::Gentoo::Maps::version_c2g($version); my @portdirs = ($main_portdir, @{$self->status->portdir_overlay}); for my $category (qw/virtual perl-core dev-perl perl-gcpan/, CATEGORY) { - my $atom = ($category eq 'virtual' ? 'perl-' : '') . $name; + my $name = ($category eq 'virtual' ? 'perl-' : '') . $name; for my $portdir (@portdirs) { my @ebuilds = glob File::Spec->catfile( $portdir, $category, - $atom, - "$atom-*.ebuild", + $name, + "$name-*.ebuild", ) or next; - my $last = reduce { - CPANPLUS::Dist::Gentoo::Maps::version_gcmp($b->[1], $a->[1]) >= 0 ? $b : $a - } map [ $_, /\Q$atom\E-v?([\d._pr-]+).*?\.ebuild$/ ? $1 : 0 ], @ebuilds; - - my $dep; - if (defined $ver) { # implies that $version is defined - next unless - CPANPLUS::Dist::Gentoo::Maps::version_gcmp($last->[1], $ver) >= 0; - $dep = ">=$category/$atom-$ver"; - } else { - $dep = "$category/$atom"; - } + 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; - return wantarray ? ($dep, $last->[0]) : $dep; + return CPANPLUS::Dist::Gentoo::Atom->new( + category => $last->category, + name => $last->name, + (defined $version ? (version => $version, range => '>=') : ()), + ebuild => $last->ebuild, + ); } } @@ -692,7 +693,7 @@ Kent Fredric, for testing and suggesting improvements. =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.