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/
207 Mail-Mbox-MessageParser
217 $version_mismatch{$_} = $insert_dot_at_all_3 for qw/
222 $version_mismatch{$_} = $pad_decimals_to_2 for qw/
227 $version_mismatch{$_} = $pad_decimals_to_4 for qw/
231 $version_mismatch{$_} = $correct_suffixes for qw/
236 $version_mismatch{$_} = $strip_letters for qw/
241 $version_mismatch{$_} = $letters_as_suffix for qw/
248 return unless defined $v;
251 $handler = $version_mismatch{$n} if defined $n;
252 $handler = $default_mapping unless defined $handler;
254 return $handler->($v);
257 =head2 C<perl_version_c2g $version>
259 Converts a perl version as you can find it in prerequisites to a Gentoo version number.
263 sub perl_version_c2g {
266 return unless defined $v and $v =~ /^[0-9\.]+$/;
269 if (my ($version, $subversion) = $v =~ /^([0-9]+)\.(0[^\.]+)$/) {
270 my $len = length $subversion;
271 if (my $pad = $len % 3) {
272 $subversion .= '0' x (3 - $pad);
274 @parts = ($version, $subversion =~ /(.{1,3})/g);
276 @parts = split /\./, $v;
279 return join '.', map int, @parts;
284 L<CPANPLUS::Dist::Gentoo>.
288 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
290 You can contact me by mail or on C<irc.perl.org> (vincent).
294 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>.
295 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
299 You can find documentation for this module with the perldoc command.
301 perldoc CPANPLUS::Dist::Gentoo
303 =head1 COPYRIGHT & LICENSE
305 Copyright 2009,2010 Vincent Pit, all rights reserved.
307 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
311 1; # End of CPANPLUS::Dist::Gentoo::Maps
314 ANSIColor Term-ANSIColor
316 CGI-Simple Cgi-Simple
317 CGI-SpeedyCGI SpeedyCGI
318 CPAN-Mini-Phalanx100 CPAN-Mini-Phalanx
319 Cache-Mmap cache-mmap
320 Class-Loader class-loader
321 Class-ReturnValue class-returnvalue
322 Config-General config-general
323 Convert-ASCII-Armour convert-ascii-armour
324 Convert-PEM convert-pem
326 Crypt-DES_EDE3 crypt-des-ede3
329 Crypt-IDEA crypt-idea
330 Crypt-Primes crypt-primes
332 Crypt-Random crypt-random
333 DBIx-SearchBuilder dbix-searchbuilder
334 Data-Buffer data-buffer
337 Digest-BubbleBabble digest-bubblebabble
338 Digest-MD2 digest-md2
339 ExtUtils-Depends extutils-depends
340 ExtUtils-PkgConfig extutils-pkgconfig
341 Frontier-RPC frontier-rpc
345 Gnome2-Canvas gnome2-canvas
346 Gnome2-GConf gnome2-gconf
347 Gnome2-Print gnome2-print
348 Gnome2-VFS gnome2-vfs-perl
349 Gnome2-Wnck gnome2-wnck
351 Gtk2-Ex-FormFactory gtk2-ex-formfactory
352 Gtk2-GladeXML gtk2-gladexml
353 Gtk2-Spell gtk2-spell
354 Gtk2-TrayIcon gtk2-trayicon
355 Gtk2-TrayManager gtk2-traymanager
357 I18N-LangTags i18n-langtags
360 Inline-Files inline-files
361 Locale-Maketext locale-maketext
362 Locale-Maketext-Fuzzy locale-maketext-fuzzy
363 Locale-Maketext-Lexicon locale-maketext-lexicon
364 Log-Dispatch log-dispatch
366 Module-Info module-info
367 MogileFS-Server mogilefs-server
371 Net-SSH-Perl net-ssh-perl
372 Net-Server net-server
373 OLE-Storage_Lite OLE-StorageLite
374 Ogg-Vorbis-Header ogg-vorbis-header
378 Regexp-Common regexp-common
380 Set-Scalar set-scalar
381 String-CRC32 string-crc32
382 Text-Autoformat text-autoformat
383 Text-Reform text-reform
384 Text-Template text-template
385 Text-Wrapper text-wrapper
386 Tie-EncryptedHash tie-encryptedhash
389 XML-Sablotron XML-Sablot
391 gettext Locale-gettext