]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blobdiff - lib/CPANPLUS/Dist/Gentoo.pm
Move all the "command running" logic into a _run private method
[perl/modules/CPANPLUS-Dist-Gentoo.git] / lib / CPANPLUS / Dist / Gentoo.pm
index 86a9d0c5215686d811998e21ac6704d66cbf608c..d7c1a7ff9924d733d680e8612dec7453456ed49f 100644 (file)
@@ -40,6 +40,10 @@ This module is a CPANPLUS backend that recursively generates Gentoo ebuilds for
 
 The generated ebuilds are placed into the section C<perl-gcpanp>. They favour depending on C<perl-core> or C<dev-perl> rather than C<perl-gcpanp>.
 
+=head1 INSTALLATION
+
+After installing this module, you should append C<perl-gcpanp> to your F</etc/portage/categories> file.
+
 =head1 METHODS
 
 All the methods are inherited from L<CPANPLUS::Dist::Base>. Please refer to its perldoc for precise information on what's done at each step.
@@ -61,19 +65,26 @@ sub format_available {
 sub init {
  my ($self) = @_;
  my $stat = $self->status;
+ my $conf = $self->parent->parent->configure_object;
+
  $stat->mk_accessors(qw/name version dist desc uri src license deps
                         eb_name eb_version eb_dir eb_file distdir fetched_arch
-                        keywords do_manifest/);
+                        keywords do_manifest
+                        verbose/);
+
+ $stat->verbose($conf->get_conf('verbose'));
 
  return 1;
 }
 
 my %gentooism = (
- 'Digest'          => 'digest-base',
- 'Locale-Maketext' => 'locale-maketext',
- 'Net-Ping'        => 'net-ping',
- 'PathTools'       => 'File-Spec',
- 'PodParser'       => 'Pod-Parser',
+ 'Digest'            => 'digest-base',
+ 'Locale-Maketext'   => 'locale-maketext',
+ 'Net-Ping'          => 'net-ping',
+ 'PathTools'         => 'File-Spec',
+ 'PodParser'         => 'Pod-Parser',
+ 'Set-Scalar'        => 'set-scalar',
+ 'Tie-EncryptedHash' => 'tie-encryptedhash',
 );
 
 sub prepare {
@@ -141,8 +152,10 @@ sub prepare {
  $stat->license([ qw/Artistic GPL-2/ ]);
 
  my $prereqs = $mod->status->prereqs;
+ $prereqs = { map { ($gentooism{$_} || $_) => $prereqs->{$_} } keys %$prereqs };
  my @depends;
  for my $prereq (sort keys %$prereqs) {
+  next if $prereq =~ /^perl(?:-|\z)/;
   my $obj = $int->module_tree($prereq);
   unless ($obj) {
    error 'Wrong module object -- aborting';
@@ -230,8 +243,7 @@ sub create {
   }
 
   msg 'Adding Manifest entry for ' . $stat->dist;
-  unless (scalar run command => [ 'ebuild', $file, 'manifest' ], verbose => 0) {
-   error 'ebuild manifest failed -- aborting';
+  unless ($self->_run([ 'ebuild', $file, 'manifest' ], 0)) {
    1 while unlink $file;
    return 0;
   }
@@ -249,12 +261,7 @@ sub install {
  my @cmd = ('emerge', '=' . $stat->eb_name . '-' . $stat->eb_version);
  unshift @cmd, $sudo if $sudo;
 
- unless (run command => \@cmd, verbose => 1) {
-  error 'emerge failed -- aborting';
-  return 0;
- }
-
- return 1;
+ return $self->_run(\@cmd, 1);
 }
 
 sub uninstall {
@@ -266,12 +273,23 @@ sub uninstall {
  my @cmd = ('emerge', '-C', '=' . $stat->eb_name . '-' . $stat->eb_version);
  unshift @cmd, $sudo if $sudo;
 
- unless (run command => \@cmd, verbose => 1) {
-  error 'emerge -C failed -- aborting';
-  return 0;
+ return $self->_run(\@cmd, 1);
+}
+
+sub _run {
+ my ($self, $cmd, $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) {
+   my $msg = join '', @$output;
+   1 while chomp $msg;
+   error $msg;
+  }
  }
 
- return 1;
+ return $success;
 }
 
 =head1 DEPENDENCIES
@@ -292,6 +310,8 @@ L<CPANPLUS::Dist::Base>, L<CPANPLUS::Dist::Deb>, L<CPANPLUS::Dist::Mdv>.
 
 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
 
+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.