]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blobdiff - lib/CPANPLUS/Dist/Gentoo.pm
This is 0.07
[perl/modules/CPANPLUS-Dist-Gentoo.git] / lib / CPANPLUS / Dist / Gentoo.pm
index 972fed873f08dcfacf4f0287e110b5a17dc7b009..e6dcb369b57ef8e64914f06b0491a45ca553548c 100644 (file)
@@ -9,23 +9,24 @@ use File::Path qw/mkpath/;
 use File::Spec::Functions qw/catdir catfile/;
 
 use IPC::Cmd qw/run can_run/;
-use version;
 
 use CPANPLUS::Error;
 
 use base qw/CPANPLUS::Dist::Base/;
 
+use CPANPLUS::Dist::Gentoo::Maps;
+
 =head1 NAME
 
 CPANPLUS::Dist::Gentoo - CPANPLUS backend generating Gentoo ebuilds.
 
 =head1 VERSION
 
-Version 0.05
+Version 0.07
 
 =cut
 
-our $VERSION = '0.05';
+our $VERSION = '0.07';
 
 =head1 SYNOPSIS
 
@@ -128,80 +129,6 @@ sub init {
  return 1;
 }
 
-our %gentooism = (
- 'ANSIColor'               => 'Term-ANSIColor',
- 'Audio-CD'                => 'Audio-CD-disc-cover',
- 'CGI-Simple'              => 'Cgi-Simple',
- 'Cache-Mmap'              => 'cache-mmap',
- 'Class-Loader'            => 'class-loader',
- 'Class-ReturnValue'       => 'class-returnvalue',
- 'Config-General'          => 'config-general',
- 'Convert-ASCII-Armour'    => 'convert-ascii-armour',
- 'Convert-PEM'             => 'convert-pem',
- 'Crypt-CBC'               => 'crypt-cbc',
- 'Crypt-DES_EDE3'          => 'crypt-des-ede3',
- 'Crypt-DH'                => 'crypt-dh',
- 'Crypt-DSA'               => 'crypt-dsa',
- 'Crypt-IDEA'              => 'crypt-idea',
- 'Crypt-Primes'            => 'crypt-primes',
- 'Crypt-RSA'               => 'crypt-rsa',
- 'Crypt-Random'            => 'crypt-random',
- 'DBIx-SearchBuilder'      => 'dbix-searchbuilder',
- 'Data-Buffer'             => 'data-buffer',
- 'Digest'                  => 'digest-base',
- 'Digest-BubbleBabble'     => 'digest-bubblebabble',
- 'Digest-MD2'              => 'digest-md2',
- 'ExtUtils-Depends'        => 'extutils-depends',
- 'ExtUtils-PkgConfig'      => 'extutils-pkgconfig',
- 'Frontier-RPC'            => 'frontier-rpc',
- 'Gimp'                    => 'gimp-perl',
- 'Glib'                    => 'glib-perl',
- 'Gnome2-Canvas'           => 'gnome2-canvas',
- 'Gnome2-GConf'            => 'gnome2-gconf',
- 'Gnome2-Print'            => 'gnome2-print',
- 'Gnome2-VFS'              => 'gnome2-vfs-perl',
- 'Gnome2-Wnck'             => 'gnome2-wnck',
- 'Gtk2'                    => 'gtk2-perl',
- 'Gtk2-Ex-FormFactory'     => 'gtk2-ex-formfactory',
- 'Gtk2-GladeXML'           => 'gtk2-gladexml',
- 'Gtk2-Spell'              => 'gtk2-spell',
- 'Gtk2-TrayIcon'           => 'gtk2-trayicon',
- 'Gtk2-TrayManager'        => 'gtk2-traymanager',
- 'Gtk2Fu'                  => 'gtk2-fu',
- 'I18N-LangTags'           => 'i18n-langtags',
- 'Image-Info'              => 'ImageInfo',
- 'Image-Size'              => 'ImageSize',
- 'Inline-Files'            => 'inline-files',
- 'Locale-Maketext'         => 'locale-maketext',
- 'Locale-Maketext-Fuzzy'   => 'locale-maketext-fuzzy',
- 'Locale-Maketext-Lexicon' => 'locale-maketext-lexicon',
- 'Log-Dispatch'            => 'log-dispatch',
- 'Math-Pari'               => 'math-pari',
- 'Module-Info'             => 'module-info',
- 'Net-Ping'                => 'net-ping',
- 'Net-SFTP'                => 'net-sftp',
- 'Net-SSH-Perl'            => 'net-ssh-perl',
- 'Net-Server'              => 'net-server',
- 'OLE-Storage_Lite'        => 'OLE-StorageLite',
- 'Ogg-Vorbis-Header'       => 'ogg-vorbis-header',
- 'PathTools'               => 'File-Spec',
- 'Pod-Parser'              => 'PodParser',
- 'Regexp-Common'           => 'regexp-common',
- 'SDL_Perl'                => 'sdl-perl',
- 'Set-Scalar'              => 'set-scalar',
- 'String-CRC32'            => 'string-crc32',
- 'Text-Autoformat'         => 'text-autoformat',
- 'Text-Reform'             => 'text-reform',
- 'Text-Template'           => 'text-template',
- 'Text-Wrapper'            => 'text-wrapper',
- 'Tie-EncryptedHash'       => 'tie-encryptedhash',
- 'Tk'                      => 'perl-tk',
- 'Wx'                      => 'wxperl',
- 'YAML'                    => 'yaml',
- 'gettext'                 => 'Locale-gettext',
- 'txt2html'                => 'TextToHTML',
-);
-
 sub prepare {
  my $self = shift;
  my $mod  = $self->parent;
@@ -279,18 +206,9 @@ sub prepare {
 
  $stat->distribution($name . '-' . $version);
 
- $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_version(CPANPLUS::Dist::Gentoo::Maps::version_c2g($version));
 
- $stat->eb_name($gentooism{$name} || $name);
+ $stat->eb_name(CPANPLUS::Dist::Gentoo::Maps::name_c2g($name));
 
  $stat->eb_dir(catdir($stat->overlay, CATEGORY, $stat->eb_name));
 
@@ -383,14 +301,6 @@ sub create {
   return 1;
  }
 
- $stat->created(0);
- $stat->dist(undef);
-
- $self->SUPER::create(@_);
-
- $stat->created(0);
- $stat->dist(undef);
-
  my $dir = $stat->eb_dir;
  unless (-d $dir) {
   eval { mkpath $dir };
@@ -427,6 +337,14 @@ sub create {
  print $eb $d;
  close $eb;
 
+ $stat->created(0);
+ $stat->dist(undef);
+
+ $self->SUPER::create(@_);
+
+ $stat->created(0);
+ $stat->dist(undef);
+
  if ($stat->do_manifest) {
   unless (copy $stat->fetched_arch, $stat->distdir) {
    error "Couldn\'t copy the distribution file to distdir ($!) -- aborting";
@@ -449,9 +367,9 @@ sub create {
 sub _cpan2portage {
  my ($self, $name, $version) = @_;
 
- $name = $gentooism{$name} || $name;
+ $name = CPANPLUS::Dist::Gentoo::Maps::name_c2g($name);
  my $ver;
- $ver = eval { version->new($version) } if defined $version;
+ $ver = CPANPLUS::Dist::Gentoo::Maps::version_c2g($version) if defined $version;
 
  my @portdirs = ($main_portdir, @{$self->status->portdir_overlay});
 
@@ -464,10 +382,10 @@ sub _cpan2portage {
 
    if (defined $ver) { # implies that $version is defined
     for (@ebuilds) {
-     next unless /\Q$atom\E-v?([\d._]+).*?\.ebuild$/;
-     my $eb_ver = eval { version->new($1) };
-     next unless defined $eb_ver and $eb_ver >= $ver;
-     return ">=$category/$atom-$version";
+     my ($eb_ver) = /\Q$atom\E-v?([\d._pr-]+).*?\.ebuild$/;
+     return ">=$category/$atom-$ver"
+            if  defined $eb_ver
+            and CPANPLUS::Dist::Gentoo::Maps::version_gcmp($eb_ver, $ver) > 0;
     }
    } else {
     return "$category/$atom";
@@ -523,7 +441,7 @@ sub _run {
 
  unless ($success) {
   error "$errmsg -- aborting";
-  if (not $verbose and defined $output and $self->status->verbose) {
+  if (not $verbose and defined $output and $stat->verbose) {
    my $msg = join '', @$output;
    1 while chomp $msg;
    error $msg;
@@ -537,9 +455,9 @@ sub _run {
 
 Gentoo (L<http://gentoo.org>).
 
-L<CPANPLUS>, L<IPC::Cmd> (core modules since 5.9.5), L<version> (since 5.009).
+L<CPANPLUS>, L<IPC::Cmd> (core modules since 5.9.5).
 
-L<Cwd> (since perl 5) L<File::Path> (5.001), L<File::Copy> (5.002), L<File::Spec::Functions> (5.00504).
+L<Cwd>, L<Carp> (since perl 5), L<File::Path> (5.001), L<File::Copy> (5.002), L<File::Spec::Functions> (5.00504).
 
 =head1 SEE ALSO