]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blobdiff - lib/CPANPLUS/Dist/Gentoo.pm
Make sure the ebuild placeholder gets unlinked on failure
[perl/modules/CPANPLUS-Dist-Gentoo.git] / lib / CPANPLUS / Dist / Gentoo.pm
index 5f7545f99581049312c7ec5795124051aee564db..b844c776848c9e314b3ef61354a22277e8de085c 100644 (file)
@@ -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
@@ -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;