my %opts = @_;
- $stat->prepared(0);
+ my $OK = sub { $stat->prepared(1); 1 };
+ my $FAIL = sub { $stat->prepared(0); 0 };
my $keywords = delete $opts{'keywords'};
if (defined $keywords) {
if ($stat->do_manifest && !-w $stat->distdir) {
error 'distdir isn\'t writable -- aborting';
- return 0;
+ return $FAIL->();
}
$stat->fetched_arch($mod->status->fetch);
unless ($author =~ /^(.)(.)/) {
error 'Wrong author name -- aborting';
- return 0;
+ return $FAIL->();
}
$stat->src("mirror://cpan/modules/by-authors/id/$1/$1$2/$author/"
. $mod->package);
my $obj = $int->module_tree($prereq);
unless ($obj) {
error 'Wrong module object -- aborting';
- return 0;
+ return $FAIL->();
}
next if $obj->package_is_perl_core;
{
}
$stat->deps(\@depends);
- $stat->prepared(1);
- return 1;
+ return $OK->();
}
sub create {
my $self = shift;
my $stat = $self->status;
+ my $OK = sub { $stat->created(1); $stat->dist($stat->eb_file); 1 };
+ my $FAIL = sub { $stat->created(0); $stat->dist(undef); 0 };
+
unless ($stat->prepared) {
error 'Can\'t create ' . $stat->distribution . ' since it was never prepared -- aborting';
- $stat->created(0);
- $stat->dist(undef);
- return 0;
+ return $FAIL->();
}
if ($stat->created) {
msg $stat->distribution . ' was already created -- skipping';
- $stat->dist($stat->eb_file);
- return 1;
+ return $OK->();
}
my $dir = $stat->eb_dir;
eval { File::Path::mkpath($dir) };
if ($@) {
error "mkpath($dir): $@";
- return 0;
+ return $FAIL->();
}
}
my $file = $stat->eb_file;
open my $eb, '>', $file or do {
error "open($file): $! -- aborting";
- return 0;
+ return $FAIL->();
};
print $eb $d;
close $eb;
$self->SUPER::create(@_);
- $stat->created(0);
- $stat->dist(undef);
+ if ($stat->do_manifest and not $self->update_manifest) {
+ 1 while unlink $file;
+ return $FAIL->();
+ }
- if ($stat->do_manifest) {
- unless (File::Copy::copy($stat->fetched_arch => $stat->distdir)) {
- error "Couldn\'t copy the distribution file to distdir ($!) -- aborting";
- 1 while unlink $file;
- return 0;
- }
+ return $OK->();
+}
- msg 'Adding Manifest entry for ' . $stat->distribution;
- unless ($self->_run([ 'ebuild', $file, 'manifest' ], 0)) {
- 1 while unlink $file;
- return 0;
- }
+=head2 C<update_manifest>
+
+Update the F<Manifest> file for the ebuild associated to the current dist object.
+
+=cut
+
+sub update_manifest {
+ my $self = shift;
+ my $stat = $self->status;
+
+ my $file = $stat->eb_file;
+ unless ($file and -e $file) {
+ error 'The ebuild file is invalid or does not exist -- aborting';
+ return 0;
}
- $stat->created(1);
- $stat->dist($file);
- return 1;
+ unless (File::Copy::copy($stat->fetched_arch => $stat->distdir)) {
+ error "Couldn\'t copy the distribution file to distdir ($!) -- aborting";
+ return 0;
+ }
+
+ msg 'Adding Manifest entry for ' . $stat->distribution;
+ return $self->_run([ 'ebuild', $stat->eb_file, 'manifest' ], 0);
}
sub _cpan2portage {