From: Vincent Pit Date: Sat, 29 Nov 2008 17:55:59 +0000 (+0100) Subject: --force should regenerate ebuilds when possible X-Git-Tag: v0.03~5 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=0033ad2c4e2e6b1bde6ccf8e3873d76f0574b7fd;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git --force should regenerate ebuilds when possible --- diff --git a/lib/CPANPLUS/Dist/Gentoo.pm b/lib/CPANPLUS/Dist/Gentoo.pm index 786308b..54ccae0 100644 --- a/lib/CPANPLUS/Dist/Gentoo.pm +++ b/lib/CPANPLUS/Dist/Gentoo.pm @@ -131,13 +131,28 @@ sub prepare { $stat->eb_name($gentooism{$stat->name} || $stat->name); $stat->eb_dir(catdir($overlay, $stat->eb_name)); - $stat->eb_file(catfile($stat->eb_dir, - $stat->eb_name . '-' . $stat->eb_version . '.ebuild')); - if (-r $stat->eb_file) { - msg 'Ebuild already generated for ' . $stat->dist . ' -- skipping'; - $stat->prepared(1); - $stat->created(1); - return 1; + + my $file = catfile($stat->eb_dir, + $stat->eb_name . '-' . $stat->eb_version . '.ebuild'); + $stat->eb_file($file); + + if (-e $file) { + my $skip = 1; + if ($stat->force) { + if (-w $file) { + 1 while unlink $file; + $skip = 0; + } else { + error "Can't force rewriting of $file -- skipping"; + } + } else { + msg 'Ebuild already generated for ' . $stat->dist . ' -- skipping'; + } + if ($skip) { + $stat->prepared(1); + $stat->created(1); + return 1; + } } $self->SUPER::prepare(%opts);