]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blobdiff - lib/CPANPLUS/Dist/Gentoo.pm
POD cleanups
[perl/modules/CPANPLUS-Dist-Gentoo.git] / lib / CPANPLUS / Dist / Gentoo.pm
index af542eed5f6858177d1ba180674f78595ad7ab55..243253e227f33b9c6cc3c14b9bb64332a5d19134 100644 (file)
@@ -41,9 +41,12 @@ our $VERSION = '0.07';
 
 =head1 DESCRPITON
 
-This module is a CPANPLUS backend that recursively generates Gentoo ebuilds for a given package in the specified overlay (defaults to F</usr/local/portage>), 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</usr/portage/distfiles>). The valid C<KEYWORDS> for the generated ebuilds are by default those given in C<ACCEPT_KEYWORDS>, but you can specify your own with the C<keywords> dist-option.
+This module is a CPANPLUS backend that recursively generates Gentoo ebuilds for a given package in the specified overlay (defaults to F</usr/local/portage>), 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</usr/portage/distfiles>).
+The valid C<KEYWORDS> for the generated ebuilds are by default those given in C<ACCEPT_KEYWORDS>, but you can specify your own with the C<keywords> dist-option.
 
-The generated ebuilds are placed into the C<perl-gcpanp> category. They favour depending on a C<virtual>, on C<perl-core>, C<dev-perl> or C<perl-gcpan> (in that order) rather than C<perl-gcpanp>.
+The generated ebuilds are placed into the C<perl-gcpanp> category.
+They favour depending on a C<virtual>, on C<perl-core>, C<dev-perl> or C<perl-gcpan> (in that order) rather than C<perl-gcpanp>.
 
 =head1 INSTALLATION
 
@@ -51,7 +54,8 @@ After installing this module, you should append C<perl-gcpanp> to your F</etc/po
 
 =head1 METHODS
 
-All the methods are inherited from L<CPANPLUS::Dist::Base>. Please refer to its documentation for precise information on what's done at each step.
+This module inherits all the methods from L<CPANPLUS::Dist::Base>.
+Please refer to its documentation for precise information on what's done at each step.
 
 =cut
 
@@ -118,7 +122,8 @@ sub init {
  my $conf = $self->parent->parent->configure_object;
 
  $stat->mk_accessors(qw/name version author distribution desc uri src license
-                        deps eb_name eb_version eb_dir eb_file fetched_arch
+                        fetched_arch deps
+                        ebuild_name ebuild_version ebuild_dir ebuild_file
                         portdir_overlay
                         overlay distdir keywords do_manifest header footer
                         force verbose/);
@@ -206,21 +211,21 @@ sub prepare {
 
  $stat->distribution($name . '-' . $version);
 
- $stat->eb_version(CPANPLUS::Dist::Gentoo::Maps::version_c2g($version));
+ $stat->ebuild_version(CPANPLUS::Dist::Gentoo::Maps::version_c2g($version));
 
- $stat->eb_name(CPANPLUS::Dist::Gentoo::Maps::name_c2g($name));
+ $stat->ebuild_name(CPANPLUS::Dist::Gentoo::Maps::name_c2g($name));
 
- $stat->eb_dir(File::Spec->catdir(
+ $stat->ebuild_dir(File::Spec->catdir(
   $stat->overlay,
   CATEGORY,
-  $stat->eb_name,
+  $stat->ebuild_name,
  ));
 
  my $file = File::Spec->catfile(
-  $stat->eb_dir,
-  $stat->eb_name . '-' . $stat->eb_version . '.ebuild',
+  $stat->ebuild_dir,
+  $stat->ebuild_name . '-' . $stat->ebuild_version . '.ebuild',
  );
- $stat->eb_file($file);
+ $stat->ebuild_file($file);
 
  if (-e $file) {
   my $skip = 1;
@@ -289,7 +294,7 @@ sub create {
  my $self = shift;
  my $stat = $self->status;
 
- my $OK   = sub { $stat->created(1); $stat->dist($stat->eb_file); 1 };
+ my $OK   = sub { $stat->created(1); $stat->dist($stat->ebuild_file); 1 };
  my $FAIL = sub { $stat->created(0); $stat->dist(undef); $self->_abort(@_) if @_; 0 };
 
  unless ($stat->prepared) {
@@ -303,34 +308,15 @@ sub create {
   return $OK->();
  }
 
- my $dir = $stat->eb_dir;
+ my $dir = $stat->ebuild_dir;
  unless (-d $dir) {
   eval { File::Path::mkpath($dir) };
   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;
+ my $file = $stat->ebuild_file;
  open my $eb, '>', $file or return $FAIL->("open($file): $!");
- print $eb $d;
+ print $eb $self->ebuild_source;
  close $eb;
 
  $stat->created(0);
@@ -348,7 +334,7 @@ sub create {
 
 =head2 C<update_manifest>
 
-Update the F<Manifest> file for the ebuild associated to the current dist object.
+Updates the F<Manifest> file for the ebuild associated to the current dist object.
 
 =cut
 
@@ -356,7 +342,7 @@ sub update_manifest {
  my $self = shift;
  my $stat = $self->status;
 
- my $file = $stat->eb_file;
+ my $file = $stat->ebuild_file;
  unless ($file and -e $file) {
   return $self->_abort('The ebuild file is invalid or does not exist');
  }
@@ -367,7 +353,43 @@ sub update_manifest {
 
  $self->_notify('Adding Manifest entry for', $stat->distribution);
 
- return $self->_run([ 'ebuild', $stat->eb_file, 'manifest' ], 0);
+ return $self->_run([ 'ebuild', $stat->ebuild_file, 'manifest' ], 0);
+}
+
+=head2 C<ebuild_source>
+
+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 {
@@ -418,7 +440,7 @@ sub install {
  my $conf = $self->parent->parent->configure_object;
 
  my $sudo = $conf->get_program('sudo');
- my @cmd = ('emerge', '=' . $stat->eb_name . '-' . $stat->eb_version);
+ my @cmd = ('emerge', '=' . $stat->ebuild_name . '-' . $stat->ebuild_version);
  unshift @cmd, $sudo if $sudo;
 
  my $success = $self->_run(\@cmd, 1);
@@ -433,7 +455,7 @@ sub uninstall {
  my $conf = $self->parent->parent->configure_object;
 
  my $sudo = $conf->get_program('sudo');
- my @cmd = ('emerge', '-C', '=' . $stat->eb_name . '-' . $stat->eb_version);
+ my @cmd = ('emerge', '-C', '=' . $stat->ebuild_name . '-' . $stat->ebuild_version);
  unshift @cmd, $sudo if $sudo;
 
  my $success = $self->_run(\@cmd, 1);
@@ -504,7 +526,8 @@ You can contact me by mail or on C<irc.perl.org> (vincent).
 
 =head1 BUGS
 
-Please report any bugs or feature requests to C<bug-cpanplus-dist-gentoo at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPANPLUS-Dist-Gentoo>.  I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
+Please report any bugs or feature requests to C<bug-cpanplus-dist-gentoo at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=CPANPLUS-Dist-Gentoo>.
+I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
 
 =head1 SUPPORT
 
@@ -514,7 +537,7 @@ You can find documentation for this module with the perldoc command.
 
 =head1 ACKNOWLEDGEMENTS
 
-The module is to some extend cargo-culted from L<CPANPLUS::Dist::Deb> and L<CPANPLUS::Dist::Mdv>.
+The module was inspired by L<CPANPLUS::Dist::Deb> and L<CPANPLUS::Dist::Mdv>.
 
 Kent Fredric, for testing and suggesting improvements.