1 package CPANPLUS::Dist::Gentoo::Maps;
8 CPANPLUS::Dist::Gentoo::Maps - Map CPAN objects to Gentoo and vice versa.
16 our $VERSION = '0.10';
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 its Gentoo counterpart.
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 licenses 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' ],
70 grep !$seen{$_}++, map @{$licenses{+lc} || []}, @_;
73 =head2 C<version_c2g $name, $version>
75 Converts the C<$version> of a CPAN distribution C<$name> to a Gentoo version.
79 my $default_mapping = sub {
87 $v =~ s/([._])[._]*/$1/g;
89 ($v, my $patch) = split /_/, $v, 2;
98 my $insert_dot_at = sub {
99 my ($v, $pos, $all) = @_;
101 my ($int, $frac) = split /\./, $v, 2;
102 return $v unless defined $frac;
105 push @p, $-[0] while $frac =~ /[0-9]/g;
106 my %digit = map { $_ => 1 } @p;
109 for (my $i = $pos; $i < @p; $i += $pos) {
111 substr($frac, $i + $shift, 0) = '.';
120 my $insert_dot_at_1 = sub { $insert_dot_at->($_[0], 1, 0) },
121 my $insert_dot_at_all_1 = sub { $insert_dot_at->($_[0], 1, 1) },
122 my $insert_dot_at_2 = sub { $insert_dot_at->($_[0], 2, 0) },
123 my $insert_dot_at_all_2 = sub { $insert_dot_at->($_[0], 2, 1) },
124 my $insert_dot_at_all_3 = sub { $insert_dot_at->($_[0], 3, 1) },
126 my $pad_decimals_to = sub {
129 my ($int, $frac) = split /\./, $v, 2;
130 return $v unless defined $v;
132 my $l = length $frac;
134 $frac .= '0' x ($n - $l);
140 my $pad_decimals_to_2 = sub { $pad_decimals_to->($_[0], 2) };
141 my $pad_decimals_to_4 = sub { $pad_decimals_to->($_[0], 4) };
143 my $correct_suffixes = sub {
146 $v = $default_mapping->($v);
147 $v =~ s/(?<!_)((?:alpha|beta|pre|rc|p)\d*)\b/_$1/g;
152 my $strip_letters = sub {
155 $v = $default_mapping->($v);
156 $v =~ s/(?<=\d)[a-z]+//g;
161 my $letters_as_suffix = sub {
164 $v = $default_mapping->($v);
165 $v =~ s/(?<=\d)b(?=\d)/_beta/g;
170 my %version_mismatch;
172 $version_mismatch{$_} = $insert_dot_at_1 for qw/
176 $version_mismatch{$_} = $insert_dot_at_all_1 for qw/
188 $version_mismatch{$_} = $insert_dot_at_2 for qw/
192 $version_mismatch{$_} = $insert_dot_at_all_2 for qw/
206 Mail-Mbox-MessageParser
216 $version_mismatch{$_} = $insert_dot_at_all_3 for qw/
221 $version_mismatch{$_} = $pad_decimals_to_2 for qw/
226 $version_mismatch{$_} = $pad_decimals_to_4 for qw/
230 $version_mismatch{$_} = $correct_suffixes for qw/
235 $version_mismatch{$_} = $strip_letters for qw/
240 $version_mismatch{$_} = $letters_as_suffix for qw/
247 return unless defined $v;
250 $handler = $version_mismatch{$n} if defined $n;
251 $handler = $default_mapping unless defined $handler;
253 return $handler->($v);
256 =head2 C<perl_version_c2g $version>
258 Converts a perl version as you can find it in prerequisites to a Gentoo version number.
262 sub perl_version_c2g {
265 return unless defined $v and $v =~ /^[0-9\.]+$/;
268 if (my ($version, $subversion) = $v =~ /^([0-9]+)\.(0[^\.]+)$/) {
269 my $len = length $subversion;
270 if (my $pad = $len % 3) {
271 $subversion .= '0' x (3 - $pad);
273 @parts = ($version, $subversion =~ /(.{1,3})/g);
275 @parts = split /\./, $v;
278 return join '.', map int, @parts;
283 L<CPANPLUS::Dist::Gentoo>.
287 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
289 You can contact me by mail or on C<irc.perl.org> (vincent).
293 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>.
294 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
298 You can find documentation for this module with the perldoc command.
300 perldoc CPANPLUS::Dist::Gentoo
302 =head1 COPYRIGHT & LICENSE
304 Copyright 2009,2010 Vincent Pit, all rights reserved.
306 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
310 1; # End of CPANPLUS::Dist::Gentoo::Maps
313 ANSIColor Term-ANSIColor
315 CGI-Simple Cgi-Simple
316 CGI-SpeedyCGI SpeedyCGI
317 CPAN-Mini-Phalanx100 CPAN-Mini-Phalanx
318 Cache-Mmap cache-mmap
319 Class-Loader class-loader
320 Class-ReturnValue class-returnvalue
321 Config-General config-general
322 Convert-ASCII-Armour convert-ascii-armour
323 Convert-PEM convert-pem
325 Crypt-DES_EDE3 crypt-des-ede3
328 Crypt-IDEA crypt-idea
329 Crypt-Primes crypt-primes
331 Crypt-Random crypt-random
332 DBIx-SearchBuilder dbix-searchbuilder
333 Data-Buffer data-buffer
336 Digest-BubbleBabble digest-bubblebabble
337 Digest-MD2 digest-md2
338 ExtUtils-Depends extutils-depends
339 ExtUtils-PkgConfig extutils-pkgconfig
340 Frontier-RPC frontier-rpc
344 Gnome2-Canvas gnome2-canvas
345 Gnome2-GConf gnome2-gconf
346 Gnome2-Print gnome2-print
347 Gnome2-VFS gnome2-vfs-perl
348 Gnome2-Wnck gnome2-wnck
350 Gtk2-Ex-FormFactory gtk2-ex-formfactory
351 Gtk2-GladeXML gtk2-gladexml
352 Gtk2-Spell gtk2-spell
353 Gtk2-TrayIcon gtk2-trayicon
354 Gtk2-TrayManager gtk2-traymanager
356 I18N-LangTags i18n-langtags
359 Inline-Files inline-files
360 Locale-Maketext locale-maketext
361 Locale-Maketext-Fuzzy locale-maketext-fuzzy
362 Locale-Maketext-Lexicon locale-maketext-lexicon
363 Log-Dispatch log-dispatch
365 Module-Info module-info
369 Net-SSH-Perl net-ssh-perl
370 Net-Server net-server
371 OLE-Storage_Lite OLE-StorageLite
372 Ogg-Vorbis-Header ogg-vorbis-header
376 Regexp-Common regexp-common
378 Set-Scalar set-scalar
379 String-CRC32 string-crc32
380 Text-Autoformat text-autoformat
381 Text-Reform text-reform
382 Text-Template text-template
383 Text-Wrapper text-wrapper
384 Tie-EncryptedHash tie-encryptedhash
387 XML-Sablotron XML-Sablot
389 gettext Locale-gettext