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<
264 $version_mismatch{$_} = $simple_and_correct_suffixes for qw<
269 $version_mismatch{$_} = $simple_and_strip_letters for qw<
274 $version_mismatch{$_} = $simple_and_letters_as_suffix for qw<
281 return unless defined $v;
284 $handler = $version_mismatch{$n} if defined $n;
285 $handler = $default_mapping unless defined $handler;
287 return $handler->($v);
290 =head2 C<perl_version_c2g $version>
292 Converts a perl version number as you can find it in CPAN prerequisites to a Gentoo version number.
296 sub perl_version_c2g {
299 return unless defined $v and $v =~ /^[0-9\.]+$/;
302 if (my ($version, $subversion) = $v =~ /^([0-9]+)\.(0[^\.]+)$/) {
303 my $len = length $subversion;
304 if (my $pad = $len % 3) {
305 $subversion .= '0' x (3 - $pad);
307 @parts = ($version, $subversion =~ /(.{1,3})/g);
309 @parts = split /\./, $v;
312 return join '.', map int, @parts;
317 L<CPANPLUS::Dist::Gentoo>.
321 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
323 You can contact me by mail or on C<irc.perl.org> (vincent).
327 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>.
328 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
332 You can find documentation for this module with the perldoc command.
334 perldoc CPANPLUS::Dist::Gentoo
336 =head1 COPYRIGHT & LICENSE
338 Copyright 2009,2010,2011 Vincent Pit, all rights reserved.
340 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
344 1; # End of CPANPLUS::Dist::Gentoo::Maps
348 CGI-Simple Cgi-Simple
349 CGI-SpeedyCGI SpeedyCGI
350 CPAN-Mini-Phalanx100 CPAN-Mini-Phalanx
351 Cache-Mmap cache-mmap
352 Class-Loader class-loader
353 Class-ReturnValue class-returnvalue
354 Config-General config-general
355 Convert-ASCII-Armour convert-ascii-armour
356 Convert-PEM convert-pem
358 Crypt-DES_EDE3 crypt-des-ede3
361 Crypt-IDEA crypt-idea
362 Crypt-Primes crypt-primes
364 Crypt-Random crypt-random
365 DBIx-SearchBuilder dbix-searchbuilder
366 Data-Buffer data-buffer
369 Digest-BubbleBabble digest-bubblebabble
370 Digest-MD2 digest-md2
371 ExtUtils-Depends extutils-depends
372 ExtUtils-PkgConfig extutils-pkgconfig
373 Frontier-RPC frontier-rpc
377 Gnome2-Canvas gnome2-canvas
378 Gnome2-GConf gnome2-gconf
379 Gnome2-VFS gnome2-vfs-perl
380 Gnome2-Wnck gnome2-wnck
382 Gtk2-Ex-FormFactory gtk2-ex-formfactory
383 Gtk2-GladeXML gtk2-gladexml
384 Gtk2-Spell gtk2-spell
385 Gtk2-TrayIcon gtk2-trayicon
386 Gtk2-TrayManager gtk2-traymanager
388 I18N-LangTags i18n-langtags
391 Inline-Files inline-files
392 Locale-Maketext locale-maketext
393 Locale-Maketext-Fuzzy locale-maketext-fuzzy
394 Locale-Maketext-Lexicon locale-maketext-lexicon
395 Log-Dispatch log-dispatch
397 Module-Info module-info
398 MogileFS-Server mogilefs-server
402 Net-SSH-Perl net-ssh-perl
403 Net-Server net-server
404 OLE-Storage_Lite OLE-StorageLite
405 Ogg-Vorbis-Header ogg-vorbis-header
409 Regexp-Common regexp-common
410 Set-Scalar set-scalar
411 String-CRC32 string-crc32
412 Text-Autoformat text-autoformat
413 Text-Reform text-reform
414 Text-Template text-template
415 Text-Wrapper text-wrapper
416 Tie-EncryptedHash tie-encryptedhash
420 XML-Sablotron XML-Sablot
422 gettext Locale-gettext