1 package CPANPLUS::Dist::Gentoo::Maps;
8 CPANPLUS::Dist::Gentoo::Maps - Map CPAN distribution names, version numbers and license identifiers to their Gentoo counterparts.
16 our $VERSION = '0.11';
20 This is an helper package to L<CPANPLUS::Dist::Gentoo>.
26 /^\s*([\w-]+)\s+([\w-]+)\s*$/ and $name_mismatch{$1} = $2 while <DATA>;
32 =head2 C<name_c2g $name>
34 Maps a CPAN distribution name to the corresponding Gentoo package name.
40 return $name_mismatch{$name} || $name;
43 =head2 C<license_c2g @licenses>
45 Maps F<META.yml> C<license> tag values to the corresponding list of Gentoo license identifiers.
46 Duplicates are stripped off.
48 The included data was gathered from L<Module::Install> and L<Software::License>.
53 apache => [ 'Apache-2.0' ],
54 artistic => [ 'Artistic' ],
55 artistic_2 => [ 'Artistic-2' ],
60 lgpl => [ 'LGPL-2.1' ],
61 lgpl2 => [ 'LGPL-2.1' ],
62 lgpl3 => [ 'LGPL-3' ],
64 mozilla => [ 'MPL-1.1' ],
65 perl => [ 'Artistic', 'GPL-2' ],
72 map @{$licenses{+lc} || []},
77 =head2 C<version_c2g $name, $version>
79 Converts the C<$version> of a CPAN distribution C<$name> to a Gentoo version number.
83 my $default_mapping = sub {
91 $v =~ s/([._])[._]*/$1/g;
93 ($v, my $patch) = split /_/, $v, 2;
102 my $insert_dot_at = sub {
103 my ($v, $pos, $all) = @_;
105 my ($int, $frac) = split /\./, $v, 2;
106 return $v unless defined $frac;
109 push @p, $-[0] while $frac =~ /[0-9]/g;
110 my %digit = map { $_ => 1 } @p;
113 for (my $i = $pos; $i < @p; $i += $pos) {
115 substr($frac, $i + $shift, 0) = '.';
124 my $insert_dot_at_1 = sub { $insert_dot_at->($_[0], 1, 0) },
125 my $insert_dot_at_all_1 = sub { $insert_dot_at->($_[0], 1, 1) },
126 my $insert_dot_at_2 = sub { $insert_dot_at->($_[0], 2, 0) },
127 my $insert_dot_at_all_2 = sub { $insert_dot_at->($_[0], 2, 1) },
128 my $insert_dot_at_all_3 = sub { $insert_dot_at->($_[0], 3, 1) },
130 my $pad_decimals_to = sub {
133 my ($int, $frac) = split /\./, $v, 2;
134 return $v unless defined $v;
136 my $l = length $frac;
138 $frac .= '0' x ($n - $l);
144 my $pad_decimals_to_2 = sub { $pad_decimals_to->($_[0], 2) };
145 my $pad_decimals_to_4 = sub { $pad_decimals_to->($_[0], 4) };
147 my $correct_suffixes = sub {
150 $v = $default_mapping->($v);
151 $v =~ s/(?<!_)((?:alpha|beta|pre|rc|p)\d*)\b/_$1/g;
156 my $strip_letters = sub {
159 $v = $default_mapping->($v);
160 $v =~ s/(?<=\d)[a-z]+//g;
165 my $letters_as_suffix = sub {
168 $v = $default_mapping->($v);
169 $v =~ s/(?<=\d)b(?=\d)/_beta/g;
174 my %version_mismatch;
176 $version_mismatch{$_} = $insert_dot_at_1 for qw<
180 $version_mismatch{$_} = $insert_dot_at_all_1 for qw<
192 $version_mismatch{$_} = $insert_dot_at_2 for qw<
196 $version_mismatch{$_} = $insert_dot_at_all_2 for qw<
211 Mail-Mbox-MessageParser
221 $version_mismatch{$_} = $insert_dot_at_all_3 for qw<
226 $version_mismatch{$_} = $pad_decimals_to_2 for qw<
231 $version_mismatch{$_} = $pad_decimals_to_4 for qw<
235 $version_mismatch{$_} = $correct_suffixes for qw<
240 $version_mismatch{$_} = $strip_letters for qw<
245 $version_mismatch{$_} = $letters_as_suffix for qw<
252 return unless defined $v;
255 $handler = $version_mismatch{$n} if defined $n;
256 $handler = $default_mapping unless defined $handler;
258 return $handler->($v);
261 =head2 C<perl_version_c2g $version>
263 Converts a perl version number as you can find it in CPAN prerequisites to a Gentoo version number.
267 sub perl_version_c2g {
270 return unless defined $v and $v =~ /^[0-9\.]+$/;
273 if (my ($version, $subversion) = $v =~ /^([0-9]+)\.(0[^\.]+)$/) {
274 my $len = length $subversion;
275 if (my $pad = $len % 3) {
276 $subversion .= '0' x (3 - $pad);
278 @parts = ($version, $subversion =~ /(.{1,3})/g);
280 @parts = split /\./, $v;
283 return join '.', map int, @parts;
288 L<CPANPLUS::Dist::Gentoo>.
292 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
294 You can contact me by mail or on C<irc.perl.org> (vincent).
298 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>.
299 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
303 You can find documentation for this module with the perldoc command.
305 perldoc CPANPLUS::Dist::Gentoo
307 =head1 COPYRIGHT & LICENSE
309 Copyright 2009,2010 Vincent Pit, all rights reserved.
311 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
315 1; # End of CPANPLUS::Dist::Gentoo::Maps
318 ANSIColor Term-ANSIColor
320 CGI-Simple Cgi-Simple
321 CGI-SpeedyCGI SpeedyCGI
322 CPAN-Mini-Phalanx100 CPAN-Mini-Phalanx
323 Cache-Mmap cache-mmap
324 Class-Loader class-loader
325 Class-ReturnValue class-returnvalue
326 Config-General config-general
327 Convert-ASCII-Armour convert-ascii-armour
328 Convert-PEM convert-pem
330 Crypt-DES_EDE3 crypt-des-ede3
333 Crypt-IDEA crypt-idea
334 Crypt-Primes crypt-primes
336 Crypt-Random crypt-random
337 DBIx-SearchBuilder dbix-searchbuilder
338 Data-Buffer data-buffer
341 Digest-BubbleBabble digest-bubblebabble
342 Digest-MD2 digest-md2
343 ExtUtils-Depends extutils-depends
344 ExtUtils-PkgConfig extutils-pkgconfig
345 Frontier-RPC frontier-rpc
349 Gnome2-Canvas gnome2-canvas
350 Gnome2-GConf gnome2-gconf
351 Gnome2-Print gnome2-print
352 Gnome2-VFS gnome2-vfs-perl
353 Gnome2-Wnck gnome2-wnck
355 Gtk2-Ex-FormFactory gtk2-ex-formfactory
356 Gtk2-GladeXML gtk2-gladexml
357 Gtk2-Spell gtk2-spell
358 Gtk2-TrayIcon gtk2-trayicon
359 Gtk2-TrayManager gtk2-traymanager
361 I18N-LangTags i18n-langtags
364 Inline-Files inline-files
365 Locale-Maketext locale-maketext
366 Locale-Maketext-Fuzzy locale-maketext-fuzzy
367 Locale-Maketext-Lexicon locale-maketext-lexicon
368 Log-Dispatch log-dispatch
370 Module-Info module-info
371 MogileFS-Server mogilefs-server
375 Net-SSH-Perl net-ssh-perl
376 Net-Server net-server
377 OLE-Storage_Lite OLE-StorageLite
378 Ogg-Vorbis-Header ogg-vorbis-header
382 Regexp-Common regexp-common
384 Set-Scalar set-scalar
385 String-CRC32 string-crc32
386 Text-Autoformat text-autoformat
387 Text-Reform text-reform
388 Text-Template text-template
389 Text-Wrapper text-wrapper
390 Tie-EncryptedHash tie-encryptedhash
393 XML-Sablotron XML-Sablot
395 gettext Locale-gettext