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 {
84 my ($version, @no_strip) = @_;
86 my $is_dev = $version =~ /_/;
87 my $has_v = $version =~ s/^v//;
96 my $dots = $version =~ y/\.//;
99 if ($has_v or $dots >= 2) {
100 @parts = split /\./, $version;
102 ($parts[0], my $subversion) = split /\./, $version, 2;
103 $subversion = '0' unless defined $subversion;
104 my $sublen = length $subversion;
106 $subversion .= '0' x (6 - $sublen);
108 my $pad = $sublen % 3;
109 $subversion .= '0' x (3 - $pad) if $pad;
111 push @parts, $subversion =~ /(...)/g;
114 for my $i (0 .. $#parts) {
115 next if $no_strip[$i];
116 $parts[$i] =~ s/^0+([^0]|0\z)/$1/;
118 $version = join '.', @parts;
120 $version .= '_rc' if $is_dev;
125 my $default_but_ignore_v = sub {
130 return $default_mapping->($version);
133 my $default_but_no_strip_1 = sub {
134 return $default_mapping->($_[0], 0, 1);
137 my $default_but_no_strip_2 = sub {
138 return $default_mapping->($_[0], 0, 1, 1);
141 my $insert_dot_every = sub {
142 my ($version, $step) = @_;
144 my $is_dev = $version =~ /_/;
155 ($parts[0], my $subversion) = split /\./, $version, 2;
156 $subversion =~ s/\.//g;
157 my $pat = sprintf '.{1,%d}', $step || 1;
158 push @parts, $subversion =~ /($pat)/g;
160 s/^0+([^0]|0\z)/$1/ for @parts;
161 $version = join '.', @parts;
163 $version .= '_rc' if $is_dev;
168 my $simple_cleanup = sub {
171 my $is_dev = $version =~ /_/;
181 $version .= '_rc' if $is_dev;
186 my $simple_and_correct_suffixes = sub {
189 $version = $simple_cleanup->($version);
190 $version =~ s/(?<!_)((?:alpha|beta|pre|rc|p)\d*)\b/_$1/g;
195 my $simple_and_strip_letters = sub {
198 $version = $simple_cleanup->($version);
199 $version =~ s/(?<=\d)[a-z]+//g;
204 my $simple_and_letters_as_suffix = sub {
207 $version = $simple_cleanup->($version);
208 $version =~ s/(?<=\d)b(?=\d)/_beta/g;
213 my %version_mismatch;
215 $version_mismatch{$_} = $default_but_ignore_v for qw<
216 Net-DNS-Resolver-Programmable
219 $version_mismatch{$_} = $default_but_no_strip_1 for qw<
222 MogileFS-Client-Async
226 $version_mismatch{$_} = $default_but_no_strip_2 for qw<
230 $version_mismatch{$_} = sub { $insert_dot_every->($_[0], 1) } for qw<
235 $version_mismatch{$_} = sub { $insert_dot_every->($_[0], 3) } for qw<
239 $version_mismatch{$_} = $simple_cleanup for qw<
265 $version_mismatch{$_} = $simple_and_correct_suffixes for qw<
270 $version_mismatch{$_} = $simple_and_strip_letters for qw<
275 $version_mismatch{$_} = $simple_and_letters_as_suffix for qw<
282 return unless defined $v;
285 $handler = $version_mismatch{$n} if defined $n;
286 $handler = $default_mapping unless defined $handler;
288 return $handler->($v);
291 =head2 C<perl_version_c2g $version>
293 Converts a perl version number as you can find it in CPAN prerequisites to a Gentoo version number.
297 sub perl_version_c2g {
300 return unless defined $v and $v =~ /^[0-9\.]+$/;
303 if (my ($version, $subversion) = $v =~ /^([0-9]+)\.(0[^\.]+)$/) {
304 my $len = length $subversion;
305 if (my $pad = $len % 3) {
306 $subversion .= '0' x (3 - $pad);
308 @parts = ($version, $subversion =~ /(.{1,3})/g);
310 @parts = split /\./, $v;
313 return join '.', map int, @parts;
318 L<CPANPLUS::Dist::Gentoo>.
322 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
324 You can contact me by mail or on C<irc.perl.org> (vincent).
328 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>.
329 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
333 You can find documentation for this module with the perldoc command.
335 perldoc CPANPLUS::Dist::Gentoo
337 =head1 COPYRIGHT & LICENSE
339 Copyright 2009,2010,2011 Vincent Pit, all rights reserved.
341 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
345 1; # End of CPANPLUS::Dist::Gentoo::Maps
349 CGI-Simple Cgi-Simple
350 CGI-SpeedyCGI SpeedyCGI
351 CPAN-Mini-Phalanx100 CPAN-Mini-Phalanx
352 Cache-Mmap cache-mmap
353 Class-Loader class-loader
354 Class-ReturnValue class-returnvalue
355 Config-General config-general
356 Convert-ASCII-Armour convert-ascii-armour
357 Convert-PEM convert-pem
359 Crypt-DES_EDE3 crypt-des-ede3
362 Crypt-IDEA crypt-idea
363 Crypt-Primes crypt-primes
365 Crypt-Random crypt-random
366 DBIx-SearchBuilder dbix-searchbuilder
367 Data-Buffer data-buffer
370 Digest-BubbleBabble digest-bubblebabble
371 Digest-MD2 digest-md2
372 ExtUtils-Depends extutils-depends
373 ExtUtils-PkgConfig extutils-pkgconfig
374 Frontier-RPC frontier-rpc
378 Gnome2-Canvas gnome2-canvas
379 Gnome2-GConf gnome2-gconf
380 Gnome2-VFS gnome2-vfs-perl
381 Gnome2-Wnck gnome2-wnck
383 Gtk2-Ex-FormFactory gtk2-ex-formfactory
384 Gtk2-GladeXML gtk2-gladexml
385 Gtk2-Spell gtk2-spell
386 Gtk2-TrayIcon gtk2-trayicon
387 Gtk2-TrayManager gtk2-traymanager
389 I18N-LangTags i18n-langtags
392 Inline-Files inline-files
393 Locale-Maketext locale-maketext
394 Locale-Maketext-Fuzzy locale-maketext-fuzzy
395 Locale-Maketext-Lexicon locale-maketext-lexicon
396 Log-Dispatch log-dispatch
398 Module-Info module-info
399 MogileFS-Server mogilefs-server
403 Net-SSH-Perl net-ssh-perl
404 Net-Server net-server
405 OLE-Storage_Lite OLE-StorageLite
406 Ogg-Vorbis-Header ogg-vorbis-header
410 Regexp-Common regexp-common
411 Set-Scalar set-scalar
412 String-CRC32 string-crc32
413 Template-Plugin-Latex Template-Latex
414 Text-Autoformat text-autoformat
415 Text-Reform text-reform
416 Text-Template text-template
417 Text-Wrapper text-wrapper
418 Tie-EncryptedHash tie-encryptedhash
422 XML-Sablotron XML-Sablot
424 gettext Locale-gettext