From: Vincent Pit Date: Thu, 3 Sep 2009 19:55:17 +0000 (+0200) Subject: Write the ebuild only after the dependencies were handled X-Git-Tag: v0.08~5 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git;a=commitdiff_plain;h=c029d40b0c63792791c19dac415438772577816e Write the ebuild only after the dependencies were handled But, to prevent endless recursion, create a placeholder ebuild before. This effectively reverts 6ea8cf92ee3ae046edc579f391c7874d1d871595. --- diff --git a/lib/CPANPLUS/Dist/Gentoo.pm b/lib/CPANPLUS/Dist/Gentoo.pm index 67d5832..49de892 100644 --- a/lib/CPANPLUS/Dist/Gentoo.pm +++ b/lib/CPANPLUS/Dist/Gentoo.pm @@ -337,8 +337,23 @@ sub create { my $self = shift; my $stat = $self->status; - my $OK = sub { $stat->created(1); $stat->dist($stat->ebuild_file); 1 }; - my $FAIL = sub { $stat->created(0); $stat->dist(undef); $self->_abort(@_) if @_; 0 }; + my $file; + + my $OK = sub { + $stat->created(1); + $stat->dist($file); + 1; + }; + + my $FAIL = sub { + $stat->created(0); + $stat->dist(undef); + $self->_abort(@_) if @_; + if ($file and -f $file) { + 1 while unlink $file; + } + 0; + }; unless ($stat->prepared) { return $FAIL->( @@ -357,26 +372,28 @@ sub create { return $FAIL->("mkpath($dir): $@") if $@; } - my $file = $stat->ebuild_file; - open my $eb, '>', $file or return $FAIL->("open($file): $!"); - print $eb $self->ebuild_source; - close $eb; + $file = $stat->ebuild_file; + + # Create a placeholder ebuild to prevent recursion with circular dependencies. + { + open my $eb, '>', $file or return $FAIL->("open($file): $!"); + print $eb "PLACEHOLDER\n"; + } $stat->created(0); $stat->dist(undef); $self->SUPER::create(@_); - unless ($stat->created) { - 1 while unlink $file; - return $FAIL->(); - } + return $FAIL->() unless $stat->created; - if ($stat->do_manifest and not $self->update_manifest) { - 1 while unlink $file; - return $FAIL->(); + { + open my $eb, '>', $file or return $FAIL->("open($file): $!"); + print $eb $self->ebuild_source; } + return $FAIL->() if $stat->do_manifest and not $self->update_manifest; + return $OK->(); }