From: Vincent Pit Date: Sat, 31 Jan 2009 15:01:02 +0000 (+0100) Subject: Move the gentooisms to a new CPANPLUS::Dist::Gentoo::Maps X-Git-Tag: v0.06~5 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=7e2aca98057c17b7728aa3028a07dacd2fdd0d62;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git Move the gentooisms to a new CPANPLUS::Dist::Gentoo::Maps This new helper module is meant to handle all the CPAN <-> Gentoo mapping logic. Also make samples/gengentooisms fill the __DATA__ of lib/CPANPLUS/Dist/Gentoo/Maps.pm and add a few basic tests. --- diff --git a/MANIFEST b/MANIFEST index a588b58..2cd9e88 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3,9 +3,11 @@ MANIFEST Makefile.PL README lib/CPANPLUS/Dist/Gentoo.pm +lib/CPANPLUS/Dist/Gentoo/Maps.pm samples/g-cpanp samples/gengentooisms t/00-load.t +t/11-maps-name.t t/90-boilerplate.t t/91-pod.t t/92-pod-coverage.t diff --git a/lib/CPANPLUS/Dist/Gentoo.pm b/lib/CPANPLUS/Dist/Gentoo.pm index 67428ed..84ed792 100644 --- a/lib/CPANPLUS/Dist/Gentoo.pm +++ b/lib/CPANPLUS/Dist/Gentoo.pm @@ -15,6 +15,8 @@ use CPANPLUS::Error; use base qw/CPANPLUS::Dist::Base/; +use CPANPLUS::Dist::Gentoo::Maps; + =head1 NAME CPANPLUS::Dist::Gentoo - CPANPLUS backend generating Gentoo ebuilds. @@ -128,80 +130,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; @@ -290,7 +218,7 @@ sub prepare { } $stat->eb_version($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)); @@ -449,7 +377,7 @@ 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; diff --git a/lib/CPANPLUS/Dist/Gentoo/Maps.pm b/lib/CPANPLUS/Dist/Gentoo/Maps.pm new file mode 100644 index 0000000..d118edc --- /dev/null +++ b/lib/CPANPLUS/Dist/Gentoo/Maps.pm @@ -0,0 +1,144 @@ +package CPANPLUS::Dist::Gentoo::Maps; + +use strict; +use warnings; + +=head1 NAME + +CPANPLUS::Dist::Gentoo::Maps - Map CPAN objects to Gentoo and vice versa. + +=head1 VERSION + +Version 0.05 + +=cut + +our $VERSION = '0.05'; + +=head1 DESCRPITON + +This is an helper package to L. + +=cut + +our %gentooisms; + +/^\s*([\w-]+)\s+([\w-]+)\s*$/ and $gentooisms{$1} = $2 while ; + +close DATA; + +=head1 FUNCTIONS + +=head2 C + +Maps a CPAN distribution name to its Gentoo counterpart. + +=cut + +sub name_c2g { + my ($name) = @_; + return $gentooisms{$name} || $name; +} + +=head1 SEE ALSO + +L. + +=head1 AUTHOR + +Vincent Pit, C<< >>, L. + +You can contact me by mail or on C (vincent). + +=head1 BUGS + +Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. + +=head1 SUPPORT + +You can find documentation for this module with the perldoc command. + + perldoc CPANPLUS::Dist::Gentoo + +=head1 COPYRIGHT & LICENSE + +Copyright 2009 Vincent Pit, all rights reserved. + +This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. + +=cut + +1; # End of CPANPLUS::Dist::Gentoo::Maps + +__DATA__ +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 diff --git a/samples/gengentooisms b/samples/gengentooisms index d7659ef..ca69b23 100755 --- a/samples/gengentooisms +++ b/samples/gengentooisms @@ -8,9 +8,13 @@ use strict; use warnings; use Fatal; +use Cwd qw/cwd/; use List::Util qw/max/; +use File::Copy qw/copy/; use constant PORTAGE => '/usr/portage'; +use constant TARGET => 'lib/CPANPLUS/Dist/Gentoo/Maps.pm'; +use constant BACKUP => TARGET . '.bak'; my %gentooism; @@ -25,6 +29,8 @@ my %where = ( 'PDF-Create' => 0, ); +my $cwd = cwd(); + for my $category (qw/perl-core dev-perl/) { my $dir = PORTAGE . '/' . $category; chdir $dir; @@ -65,11 +71,23 @@ for my $category (qw/perl-core dev-perl/) { } } +chdir $cwd; + +copy TARGET, BACKUP or die "copy failed: $!"; + +open my $src, '<', BACKUP; +open my $dst, '>', TARGET; + my $max = max map length, keys %gentooism; +SRC: while (<$src>) { + print $dst $_; + if (/^__DATA__$/) { + printf $dst "%s%s %s\n", $_, (' ' x ($max - length)), $gentooism{$_} + for sort keys %gentooism; + last SRC; + } +} + print STDERR +(keys %gentooism) . " gentooisms found\n"; -print "our %gentooism = (\n"; -printf " '%s'%s => '%s',\n", $_, (' ' x ($max - length)), $gentooism{$_} - for sort keys %gentooism; -print ");\n"; diff --git a/t/11-maps-name.t b/t/11-maps-name.t new file mode 100644 index 0000000..db03f74 --- /dev/null +++ b/t/11-maps-name.t @@ -0,0 +1,19 @@ +#!perl -T + +use strict; +use warnings; + +use Test::More tests => 4; + +use CPANPLUS::Dist::Gentoo::Maps; + +our %gentooisms; +*gentooisms = \%CPANPLUS::Dist::Gentoo::Maps::gentooisms; + +is scalar(keys %gentooisms), 71, 'gentooisms are all there'; + +is $gentooisms{PathTools}, 'File-Spec', 'gentooisms were correctly loaded'; + +is CPANPLUS::Dist::Gentoo::Maps::name_c2g('PathTools'), 'File-Spec', 'name_c2g maps gentooisms correctly'; + +is CPANPLUS::Dist::Gentoo::Maps::name_c2g('CPANPLUS-Dist-Gentoo'), 'CPANPLUS-Dist-Gentoo', 'name_c2g returns non gentooisms correctly';