X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FCPANPLUS%2FDist%2FGentoo.pm;h=e5c40fb979a59ba935d60050dc8b38caa01e54a2;hb=3286fff39f46385facc4e2523166a94d981de471;hp=26703a4cce0d14718d4f1d972fd410c8dc75734c;hpb=f722064b6599dbed7fe5a6f4a3a7a935dd3f16c0;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git diff --git a/lib/CPANPLUS/Dist/Gentoo.pm b/lib/CPANPLUS/Dist/Gentoo.pm index 26703a4..e5c40fb 100644 --- a/lib/CPANPLUS/Dist/Gentoo.pm +++ b/lib/CPANPLUS/Dist/Gentoo.pm @@ -19,11 +19,11 @@ CPANPLUS::Dist::Gentoo - CPANPLUS backend generating Gentoo ebuilds. =head1 VERSION -Version 0.02_01 +Version 0.03 =cut -our $VERSION = '0.02_01'; +our $VERSION = '0.03'; =head1 SYNOPSIS @@ -36,9 +36,9 @@ our $VERSION = '0.02_01'; =head1 DESCRPITON -This module is a CPANPLUS backend that recursively generates Gentoo ebuilds for a given package in the specified overlay (defaults to C), update the manifest, and even emerge it (together with its dependencies) if the user requires it. You need write permissions on the directory where Gentoo fetches its source files (usually C). +This module is a CPANPLUS backend that recursively generates Gentoo ebuilds for a given package in the specified overlay (defaults to F), updates the manifest, and even emerges it (together with its dependencies) if the user requires it. You need write permissions on the directory where Gentoo fetches its source files (usually F). You also need to specify the correct keyword for your architecture if it differs from the default C. -The generated ebuilds are placed into the section C. They favour depending on C or C rather than C. +The generated ebuilds are placed into the C category. They favour depending on C, C or C (in that order) rather than C. =head1 INSTALLATION @@ -46,7 +46,7 @@ After installing this module, you should append C to your F. Please refer to its perldoc for precise information on what's done at each step. +All the methods are inherited from L. Please refer to its documentation for precise information on what's done at each step. =cut @@ -70,8 +70,9 @@ sub init { $stat->mk_accessors(qw/name version dist desc uri src license deps eb_name eb_version eb_dir eb_file fetched_arch overlay distdir keywords do_manifest - verbose/); + force verbose/); + $stat->force($conf->get_conf('force')); $stat->verbose($conf->get_conf('verbose')); return 1; @@ -106,11 +107,10 @@ sub prepare { $manifest = 0 if $manifest =~ /^\s*no?\s*$/i; $stat->do_manifest($manifest); - my $overlay = catdir(delete($opts{'overlay'}) || '/usr/local/portage', - CATEGORY); - $stat->overlay($overlay); + $stat->overlay(delete($opts{'overlay'}) || '/usr/local/portage'); $stat->distdir(delete($opts{'distdir'}) || '/usr/portage/distfiles'); + if ($stat->do_manifest && !-w $stat->distdir) { error 'distdir isn\'t writable -- aborting'; return 0; @@ -122,34 +122,60 @@ sub prepare { my $version = $mod->package_version; $stat->version($version); + $stat->dist($name . '-' . $version); - my $f = 1; - $version =~ s/_+/$f ? do { $f = 0; '_p' } : ''/ge; - 1 while $version =~ s/(_p[^.]*)\.+/$1/; + + $version =~ s/[^\d._]+//g; + $version =~ s/^[._]*//; + $version =~ s/[._]*$//; + $version =~ s/[._]*_[._]*/_/g; + { + ($version, my $patch, my @rest) = split /_/, $version; + $version .= '_p' . $patch if defined $patch; + $version .= join('.', '', @rest) if @rest; + } $stat->eb_version($version); - $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; + $stat->eb_name($gentooism{$name} || $name); + + $stat->eb_dir(catdir($stat->overlay, CATEGORY, $stat->eb_name)); + + my $file = catfile($stat->eb_dir, + $stat->eb_name . '-' . $stat->eb_version . '.ebuild'); + 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; + } } + $stat->eb_file($file); $self->SUPER::prepare(%opts); my $desc = $mod->description; ($desc = $name) =~ s/-+/::/g unless $desc; $stat->desc($desc); + $stat->uri('http://search.cpan.org/dist/' . $name); + unless ($name =~ /^([^-]+)/) { error 'Wrong distribution name -- aborting'; return 0; } $stat->src('mirror://cpan/modules/by-module/' . $1 . '/' . $mod->package); + $stat->license([ qw/Artistic GPL-2/ ]); my $prereqs = $mod->status->prereqs; @@ -279,8 +305,14 @@ sub uninstall { sub _run { my ($self, $cmd, $verbose) = @_; + my $stat = $self->status; + + my ($success, $errmsg, $output) = do { + local $ENV{PORTDIR_OVERLAY} = $stat->overlay; + local $ENV{PORTAGE_RO_DISTDIRS} = $stat->distdir; + run command => $cmd, verbose => $verbose; + }; - my ($success, $errmsg, $output) = run command => $cmd, verbose => $verbose; unless ($success) { error "$errmsg -- aborting"; if (not $verbose and defined $output and $self->status->verbose) {