X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FCPANPLUS%2FDist%2FGentoo.pm;h=ee6c6129386951200413a8c96b260e1f9fabd863;hb=1ec3b5093e827a15cfd2cf15562affc9f0c28654;hp=6c47c6ef2c1ccc10339f639fa6a95b2754f37c33;hpb=73d867f4a7ed6585f445e879617dc574491b8a81;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git diff --git a/lib/CPANPLUS/Dist/Gentoo.pm b/lib/CPANPLUS/Dist/Gentoo.pm index 6c47c6e..ee6c612 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.04 =cut -our $VERSION = '0.02_01'; +our $VERSION = '0.04'; =head1 SYNOPSIS @@ -32,13 +32,15 @@ our $VERSION = '0.02_01'; --dist-opts distdir=/usr/portage/distfiles \ --dist-opts manifest=yes \ --dist-opts keywords=x86 \ + --dist-opts header="# Copyright 1999-2008 Gentoo Foundation" \ + --dist-opts footer="# End" \ Any::Module You::Like =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 +48,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 @@ -67,9 +69,9 @@ sub init { my $stat = $self->status; my $conf = $self->parent->parent->configure_object; - $stat->mk_accessors(qw/name version dist desc uri src license deps + $stat->mk_accessors(qw/name version author dist desc uri src license deps eb_name eb_version eb_dir eb_file fetched_arch - overlay distdir keywords do_manifest + overlay distdir keywords do_manifest header footer force verbose/); $stat->force($conf->get_conf('force')); @@ -107,6 +109,23 @@ sub prepare { $manifest = 0 if $manifest =~ /^\s*no?\s*$/i; $stat->do_manifest($manifest); + my $header = delete $opts{'header'}; + if (defined $header) { + 1 while chomp $header; + $header .= "\n\n"; + } else { + $header = ''; + } + $stat->header($header); + + my $footer = delete $opts{'footer'}; + if (defined $footer) { + $footer = "\n" . $footer; + } else { + $footer = ''; + } + $stat->footer($footer); + $stat->overlay(delete($opts{'overlay'}) || '/usr/local/portage'); $stat->distdir(delete($opts{'distdir'}) || '/usr/portage/distfiles'); @@ -123,11 +142,20 @@ sub prepare { my $version = $mod->package_version; $stat->version($version); + my $author = $mod->author->cpanid; + $stat->author($author); + $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{$name} || $name); @@ -164,11 +192,12 @@ sub prepare { $stat->uri('http://search.cpan.org/dist/' . $name); - unless ($name =~ /^([^-]+)/) { - error 'Wrong distribution name -- aborting'; + unless ($author =~ /^(.)(.)/) { + error 'Wrong author name -- aborting'; return 0; } - $stat->src('mirror://cpan/modules/by-module/' . $1 . '/' . $mod->package); + $stat->src("mirror://cpan/modules/by-authors/id/$1/$1$2/$author/" + . $mod->package); $stat->license([ qw/Artistic GPL-2/ ]); @@ -225,7 +254,9 @@ sub create { } } - my $d = "# Generated by CPANPLUS::Dist::Gentoo\n\ninherit perl-module\n\n"; + my $d = $stat->header; + $d .= "# Generated by CPANPLUS::Dist::Gentoo version $VERSION\n\n"; + $d .= 'MODULE_AUTHOR="' . $stat->author . "\"\ninherit perl-module\n\n"; $d .= 'S="${WORKDIR}/' . $stat->dist . "\"\n"; $d .= 'DESCRIPTION="' . $stat->desc . "\"\n"; $d .= 'HOMEPAGE="' . $stat->uri . "\"\n"; @@ -247,6 +278,8 @@ sub create { . ' )'; } @{$stat->deps}; $d .= "\"\n"; + $d .= "SRC_TEST=\"do\"\n"; + $d .= $stat->footer; my $file = $stat->eb_file; open my $eb, '>', $file or do { @@ -353,6 +386,8 @@ You can find documentation for this module with the perldoc command. The module is to some extend cargo-culted from L and L. +Kent Fredric, for testing and suggesting improvements. + =head1 COPYRIGHT & LICENSE Copyright 2008 Vincent Pit, all rights reserved.