1 package CPANPLUS::Dist::Gentoo::Maps;
11 CPANPLUS::Dist::Gentoo::Maps - Map CPAN distribution names, version numbers and license identifiers to their Gentoo counterparts.
19 our $VERSION = '0.12';
23 This is an helper package to L<CPANPLUS::Dist::Gentoo>.
29 /^\s*([\w-]+)\s+([\w-]+)\s*$/ and $name_mismatch{$1} = $2 while <DATA>;
35 =head2 C<name_c2g $name>
37 Maps a CPAN distribution name to the corresponding Gentoo package name.
43 return $name_mismatch{$name} || $name;
46 =head2 C<license_c2g @licenses>
48 Maps F<META.yml> C<license> tag values to the corresponding list of Gentoo license identifiers.
49 Duplicates are stripped off.
51 The included data was gathered from L<Module::Install> and L<Software::License>.
56 apache => [ 'Apache-2.0' ],
57 artistic => [ 'Artistic' ],
58 artistic_2 => [ 'Artistic-2' ],
63 lgpl => [ 'LGPL-2.1' ],
64 lgpl2 => [ 'LGPL-2.1' ],
65 lgpl3 => [ 'LGPL-3' ],
67 mozilla => [ 'MPL-1.1' ],
68 perl => [ 'Artistic', 'GPL-2' ],
75 map @{$licenses{+lc} || []},
80 =head2 C<version_c2g $name, $version>
82 Converts the C<$version> of a CPAN distribution C<$name> to a Gentoo version number.
86 my $default_mapping = sub {
87 my ($version, @no_strip) = @_;
89 my $is_dev = $version =~ /_/;
90 my $has_v = $version =~ s/^v//;
99 my $dots = $version =~ y/\.//;
102 if ($has_v or $dots >= 2) {
103 @parts = split /\./, $version;
105 ($parts[0], my $subversion) = split /\./, $version, 2;
106 $subversion = '0' unless defined $subversion;
107 my $sublen = length $subversion;
109 $subversion .= '0' x (6 - $sublen);
111 my $pad = $sublen % 3;
112 $subversion .= '0' x (3 - $pad) if $pad;
114 push @parts, $subversion =~ /(...)/g;
117 for my $i (0 .. $#parts) {
118 next if $no_strip[$i];
119 $parts[$i] =~ s/^0+([^0]|0\z)/$1/;
121 $version = join '.', @parts;
123 $version .= '_rc' if $is_dev;
128 my $default_but_ignore_v = sub {
133 return $default_mapping->($version);
136 my $default_but_no_strip_1 = sub {
137 return $default_mapping->($_[0], 0, 1);
140 my $default_but_no_strip_2 = sub {
141 return $default_mapping->($_[0], 0, 1, 1);
144 my $insert_dot_every = sub {
145 my ($version, $step, $strip) = @_;
147 my $is_dev = $version =~ /_/;
158 ($parts[0], my $subversion) = split /\./, $version, 2;
159 $subversion =~ s/\.//g;
160 my $pat = sprintf '.{1,%d}', $step || 1;
161 push @parts, $subversion =~ /($pat)/g;
164 s/^0+([^0]|0\z)/$1/ for @parts;
166 $version = join '.', @parts;
168 $version .= '_rc' if $is_dev;
173 my $simple_cleanup = sub {
176 my $is_dev = $version =~ /_/;
186 $version .= '_rc' if $is_dev;
191 my $simple_and_correct_suffixes = sub {
194 $version = $simple_cleanup->($version);
195 $version =~ s/(?<!_)((?:alpha|beta|pre|rc|p)\d*)\b/_$1/g;
200 my $simple_and_strip_letters = sub {
203 $version = $simple_cleanup->($version);
204 $version =~ s/(?<=\d)[a-z]+//g;
209 my $simple_and_letters_as_suffix = sub {
212 $version = $simple_cleanup->($version);
213 $version =~ s/(?<=\d)b(?=\d)/_beta/g;
218 my %version_mismatch;
220 $version_mismatch{$_} = $default_but_ignore_v for qw<
221 Net-DNS-Resolver-Programmable
224 $version_mismatch{$_} = $default_but_no_strip_1 for qw<
228 MogileFS-Client-Async
234 $version_mismatch{$_} = sub { $insert_dot_every->($_[0], 1) } for qw<
239 $version_mismatch{$_} = sub { $insert_dot_every->($_[0], 3) } for qw<
243 $version_mismatch{$_} = $simple_cleanup for qw<
258 TAP-Parser-SourceHandler-pgTAP
265 $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;
315 =head2 C<get_portage_timestamp $portage>
317 Get the numerical timestamp associated with the portage tree located at C<$portage>.
318 Requires L<POSIX::strptime>, and returns C<undef> if it is not available.
322 sub get_portage_timestamp {
327 eval { require POSIX::strptime } or return;
330 my $file = File::Spec->catfile($portage, 'metadata', 'timestamp.chk');
331 return unless -e $file;
334 open my $fh, '<', $file or return;
338 s/^\s*//, s/\s*$// for $timestamp;
341 if ($timestamp =~ s/\s+([+-])([0-9]{2})([0-9]{2})$//) {
342 $shift = ($2 * 60 + $3) * 60;
343 $shift = -$shift if $1 eq '-';
346 my $old_lc_all = POSIX::setlocale(POSIX::LC_ALL());
347 POSIX::setlocale(POSIX::LC_ALL(), 'C');
348 $timestamp = POSIX::mktime(
349 POSIX::strptime($timestamp, '%a, %d %b %Y %H:%M:%S')
351 POSIX::setlocale(POSIX::LC_ALL(), $old_lc_all);
352 $timestamp += $shift;
359 Numerical timestamp associated with the revision of the portage tree that was used for generating the corrections to the natural cpan-to-gentoo mapping listed in this module.
363 sub TIMESTAMP () { 1367759701 }
367 L<CPANPLUS::Dist::Gentoo>.
371 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
373 You can contact me by mail or on C<irc.perl.org> (vincent).
377 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>.
378 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
382 You can find documentation for this module with the perldoc command.
384 perldoc CPANPLUS::Dist::Gentoo
386 =head1 COPYRIGHT & LICENSE
388 Copyright 2009,2010,2011,2012 Vincent Pit, all rights reserved.
390 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
394 1; # End of CPANPLUS::Dist::Gentoo::Maps
398 CGI-Simple Cgi-Simple
399 CGI-SpeedyCGI SpeedyCGI
400 Cache-Mmap cache-mmap
401 Class-Loader class-loader
402 Class-ReturnValue class-returnvalue
403 Config-General config-general
404 Convert-ASCII-Armour convert-ascii-armour
405 Convert-PEM convert-pem
407 Crypt-DES_EDE3 crypt-des-ede3
410 Crypt-IDEA crypt-idea
411 Crypt-Primes crypt-primes
413 Crypt-Random crypt-random
414 DBIx-SearchBuilder dbix-searchbuilder
415 Data-Buffer data-buffer
418 Digest-BubbleBabble digest-bubblebabble
419 Digest-MD2 digest-md2
420 ExtUtils-Depends extutils-depends
421 ExtUtils-PkgConfig extutils-pkgconfig
422 Frontier-RPC frontier-rpc
425 Gnome2-Canvas gnome2-canvas
426 Gnome2-GConf gnome2-gconf
427 Gnome2-VFS gnome2-vfs-perl
428 Gnome2-Wnck gnome2-wnck
430 Gtk2-Ex-FormFactory gtk2-ex-formfactory
431 Gtk2-GladeXML gtk2-gladexml
432 Gtk2-Spell gtk2-spell
433 Gtk2-TrayIcon gtk2-trayicon
434 Gtk2-TrayManager gtk2-traymanager
436 I18N-LangTags i18n-langtags
439 Inline-Files inline-files
440 Locale-Maketext locale-maketext
441 Locale-Maketext-Fuzzy locale-maketext-fuzzy
442 Locale-Maketext-Lexicon locale-maketext-lexicon
443 Log-Dispatch log-dispatch
445 Module-Info module-info
446 MogileFS-Server mogilefs-server
450 Net-SSH-Perl net-ssh-perl
451 Net-Server net-server
452 OLE-Storage_Lite OLE-StorageLite
453 Ogg-Vorbis-Header ogg-vorbis-header
457 Regexp-Common regexp-common
458 Set-Scalar set-scalar
459 String-CRC32 string-crc32
460 Template-Plugin-Latex Template-Latex
461 Text-Autoformat text-autoformat
462 Text-Reform text-reform
463 Text-Template text-template
464 Text-Wrapper text-wrapper
465 Tie-EncryptedHash tie-encryptedhash
470 gettext Locale-gettext