From: Vincent Pit Date: Sun, 16 Aug 2009 16:32:53 +0000 (+0200) Subject: Move the formatting of the ebuild source into a new ebuild_source() method X-Git-Tag: v0.08~13 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git;a=commitdiff_plain;h=fb8cc76b1c012b97470152af280652e16b6e6cf4 Move the formatting of the ebuild source into a new ebuild_source() method --- diff --git a/lib/CPANPLUS/Dist/Gentoo.pm b/lib/CPANPLUS/Dist/Gentoo.pm index af542ee..65b9aed 100644 --- a/lib/CPANPLUS/Dist/Gentoo.pm +++ b/lib/CPANPLUS/Dist/Gentoo.pm @@ -309,28 +309,9 @@ sub create { return $FAIL->("mkpath($dir): $@") if $@; } - my %seen; - - 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->distribution . "\"\n"; - $d .= 'DESCRIPTION="' . $stat->desc . "\"\n"; - $d .= 'HOMEPAGE="' . $stat->uri . "\"\n"; - $d .= 'SRC_URI="' . $stat->src . "\"\n"; - $d .= "SLOT=\"0\"\n"; - $d .= 'LICENSE="|| ( ' . join(' ', sort @{$stat->license}) . " )\"\n"; - $d .= 'KEYWORDS="' . join(' ', sort @{$stat->keywords}) . "\"\n"; - $d .= 'DEPEND="' . join("\n", - sort grep !$seen{$_}++, 'dev-lang/perl', - map $self->_cpan2portage(@$_), @{$stat->deps} - ) . "\"\n"; - $d .= "SRC_TEST=\"do\"\n"; - $d .= $stat->footer; - my $file = $stat->eb_file; open my $eb, '>', $file or return $FAIL->("open($file): $!"); - print $eb $d; + print $eb $self->ebuild_source; close $eb; $stat->created(0); @@ -370,6 +351,42 @@ sub update_manifest { return $self->_run([ 'ebuild', $stat->eb_file, 'manifest' ], 0); } +=head2 C + +Returns the source of the ebuild for the current dist object. + +=cut + +sub ebuild_source { + my $self = shift; + my $stat = $self->status; + + # We must resolve the deps now and not inside prepare because _cpan2portage + # has to see the ebuilds already generated for the dependencies of the current + # dist. + my @deps = do { + my %seen; + sort grep !$seen{$_}++, 'dev-lang/perl', + map $self->_cpan2portage(@$_), @{$stat->deps} + }; + + 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->distribution . "\"\n"; + $d .= 'DESCRIPTION="' . $stat->desc . "\"\n"; + $d .= 'HOMEPAGE="' . $stat->uri . "\"\n"; + $d .= 'SRC_URI="' . $stat->src . "\"\n"; + $d .= "SLOT=\"0\"\n"; + $d .= 'LICENSE="|| ( ' . join(' ', sort @{$stat->license}) . " )\"\n"; + $d .= 'KEYWORDS="' . join(' ', sort @{$stat->keywords}) . "\"\n"; + $d .= 'DEPEND="' . join("\n", @deps) . "\"\n"; + $d .= "SRC_TEST=\"do\"\n"; + $d .= $stat->footer; + + return $d; +} + sub _cpan2portage { my ($self, $name, $version) = @_;