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->(
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->();
}