X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;ds=sidebyside;f=lib%2FCPANPLUS%2FDist%2FGentoo.pm;h=0003b36992ae0dff913006b9419cf720fdae86cb;hb=77110d525f6b966b8f87c11669f177127e6930d9;hp=5f7545f99581049312c7ec5795124051aee564db;hpb=eefbd51540c659904876258e2b74dbbcfda37072;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git diff --git a/lib/CPANPLUS/Dist/Gentoo.pm b/lib/CPANPLUS/Dist/Gentoo.pm index 5f7545f..0003b36 100644 --- a/lib/CPANPLUS/Dist/Gentoo.pm +++ b/lib/CPANPLUS/Dist/Gentoo.pm @@ -17,6 +17,7 @@ use CPANPLUS::Error (); use base qw/CPANPLUS::Dist::Base/; use CPANPLUS::Dist::Gentoo::Atom; +use CPANPLUS::Dist::Gentoo::Guard; use CPANPLUS::Dist::Gentoo::Maps; =head1 NAME @@ -25,11 +26,11 @@ CPANPLUS::Dist::Gentoo - CPANPLUS backend generating Gentoo ebuilds. =head1 VERSION -Version 0.09 +Version 0.10 =cut -our $VERSION = '0.09'; +our $VERSION = '0.10'; =head1 SYNOPSIS @@ -74,19 +75,19 @@ First, fetch tarballs for L and L : $ 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.09.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.09.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.09/blib/lib:/root/CPANPLUS-0.9003/lib:/root/CPANPLUS-0.9003/inc/bundle + # export PERL5LIB=/root/CPANPLUS-Dist-Gentoo-0.10/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 : @@ -94,7 +95,7 @@ Make sure you don't have an old C<.cpanplus> configuration visible : Bootstrap L : - # cd /root/CPANPLUS-Dist-Gentoo-0.09 + # cd /root/CPANPLUS-Dist-Gentoo-0.10 # samples/g-cpanp CPANPLUS Reset the environment : @@ -116,7 +117,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.09/blib/lib samples/g-cpanp CPANPLUS::Dist::Gentoo + # PERL5LIB=/root/CPANPLUS-Dist-Gentoo-0.10/blib/lib samples/g-cpanp CPANPLUS::Dist::Gentoo # emerge -tv CPANPLUS-Dist-Gentoo =back @@ -193,7 +194,7 @@ sub init { my $conf = $self->parent->parent->configure_object; $stat->mk_accessors(qw/name version author distribution desc uri src license - meta + meta min_perl fetched_arch requires ebuild_name ebuild_version ebuild_dir ebuild_file portdir_overlay @@ -363,6 +364,10 @@ sub prepare { } $stat->requires(\@requires); + $stat->min_perl(CPANPLUS::Dist::Gentoo::Maps::perl_version_c2g( + eval { $self->meta->{requires}->{perl} } + )); + return $OK->(); } @@ -436,7 +441,24 @@ sub create { my $file; + my $guard = CPANPLUS::Dist::Gentoo::Guard->new(sub { + if (defined $file and -e $file and -w _) { + 1 while unlink $file; + } + }); + + my $SIG_INT = $SIG{INT}; + local $SIG{INT} = sub { + if ($SIG_INT) { + local $@; + eval { $SIG_INT->() }; + die $@ if $@; + } + die 'Caught SIGINT'; + }; + my $OK = sub { + $guard->unarm; $stat->created(1); $stat->dist($file) if defined $file; 1; @@ -446,9 +468,6 @@ sub create { $stat->created(0); $stat->dist(undef); $self->_abort(@_) if @_; - if (defined $file and -f $file) { - 1 while unlink $file; - } 0; }; @@ -546,10 +565,13 @@ sub ebuild_source { push @requires, $atom; } + my $min_perl = $stat->min_perl; my $perl = CPANPLUS::Dist::Gentoo::Atom->new( category => 'dev-lang', name => 'perl', + (defined $min_perl ? (version => $min_perl, range => '>=') : ()), ); + @requires = CPANPLUS::Dist::Gentoo::Atom->fold($perl, @requires); my $d = $stat->header;