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) = @_;
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;
163 s/^0+([^0]|0\z)/$1/ for @parts;
164 $version = join '.', @parts;
166 $version .= '_rc' if $is_dev;
171 my $simple_cleanup = sub {
174 my $is_dev = $version =~ /_/;
184 $version .= '_rc' if $is_dev;
189 my $simple_and_correct_suffixes = sub {
192 $version = $simple_cleanup->($version);
193 $version =~ s/(?<!_)((?:alpha|beta|pre|rc|p)\d*)\b/_$1/g;
198 my $simple_and_strip_letters = sub {
201 $version = $simple_cleanup->($version);
202 $version =~ s/(?<=\d)[a-z]+//g;
207 my $simple_and_letters_as_suffix = sub {
210 $version = $simple_cleanup->($version);
211 $version =~ s/(?<=\d)b(?=\d)/_beta/g;
216 my %version_mismatch;
218 $version_mismatch{$_} = $default_but_ignore_v for qw<
219 Net-DNS-Resolver-Programmable
222 $version_mismatch{$_} = $default_but_no_strip_1 for qw<
225 MogileFS-Client-Async
229 $version_mismatch{$_} = $default_but_no_strip_2 for qw<
233 $version_mismatch{$_} = sub { $insert_dot_every->($_[0], 1) } for qw<
238 $version_mismatch{$_} = sub { $insert_dot_every->($_[0], 3) } for qw<
242 $version_mismatch{$_} = $simple_cleanup for qw<
268 $version_mismatch{$_} = $simple_and_correct_suffixes for qw<
273 $version_mismatch{$_} = $simple_and_strip_letters for qw<
278 $version_mismatch{$_} = $simple_and_letters_as_suffix for qw<
285 return unless defined $v;
288 $handler = $version_mismatch{$n} if defined $n;
289 $handler = $default_mapping unless defined $handler;
291 return $handler->($v);
294 =head2 C<perl_version_c2g $version>
296 Converts a perl version number as you can find it in CPAN prerequisites to a Gentoo version number.
300 sub perl_version_c2g {
303 return unless defined $v and $v =~ /^[0-9\.]+$/;
306 if (my ($version, $subversion) = $v =~ /^([0-9]+)\.(0[^\.]+)$/) {
307 my $len = length $subversion;
308 if (my $pad = $len % 3) {
309 $subversion .= '0' x (3 - $pad);
311 @parts = ($version, $subversion =~ /(.{1,3})/g);
313 @parts = split /\./, $v;
316 return join '.', map int, @parts;
319 =head2 C<get_portage_timestamp $portage>
321 Get the numerical timestamp associated with the portage tree located at C<$portage>.
322 Requires L<POSIX::strptime>, and returns C<undef> if it is not available.
326 sub get_portage_timestamp {
331 eval { require POSIX::strptime } or return;
334 my $file = File::Spec->catfile($portage, 'metadata', 'timestamp.chk');
335 return unless -e $file;
338 open my $fh, '<', $file or return;
342 s/^\s*//, s/\s*$// for $timestamp;
345 if ($timestamp =~ s/\s+([+-])([0-9]{2})([0-9]{2})$//) {
346 $shift = ($2 * 60 + $3) * 60;
347 $shift = -$shift if $1 eq '-';
350 my $old_lc_all = POSIX::setlocale(POSIX::LC_ALL());
351 POSIX::setlocale(POSIX::LC_ALL(), 'C');
352 $timestamp = POSIX::mktime(
353 POSIX::strptime($timestamp, '%a, %d %b %Y %H:%M:%S')
355 POSIX::setlocale(POSIX::LC_ALL(), $old_lc_all);
356 $timestamp += $shift;
363 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.
367 sub TIMESTAMP () { 1343034901 }
371 L<CPANPLUS::Dist::Gentoo>.
375 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
377 You can contact me by mail or on C<irc.perl.org> (vincent).
381 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>.
382 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
386 You can find documentation for this module with the perldoc command.
388 perldoc CPANPLUS::Dist::Gentoo
390 =head1 COPYRIGHT & LICENSE
392 Copyright 2009,2010,2011,2012 Vincent Pit, all rights reserved.
394 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
398 1; # End of CPANPLUS::Dist::Gentoo::Maps
402 CGI-Simple Cgi-Simple
403 CGI-SpeedyCGI SpeedyCGI
404 Cache-Mmap cache-mmap
405 Class-Loader class-loader
406 Class-ReturnValue class-returnvalue
407 Config-General config-general
408 Convert-ASCII-Armour convert-ascii-armour
409 Convert-PEM convert-pem
411 Crypt-DES_EDE3 crypt-des-ede3
414 Crypt-IDEA crypt-idea
415 Crypt-Primes crypt-primes
417 Crypt-Random crypt-random
418 DBIx-SearchBuilder dbix-searchbuilder
419 Data-Buffer data-buffer
422 Digest-BubbleBabble digest-bubblebabble
423 Digest-MD2 digest-md2
424 ExtUtils-Depends extutils-depends
425 ExtUtils-PkgConfig extutils-pkgconfig
426 Frontier-RPC frontier-rpc
429 Gnome2-Canvas gnome2-canvas
430 Gnome2-GConf gnome2-gconf
431 Gnome2-VFS gnome2-vfs-perl
432 Gnome2-Wnck gnome2-wnck
434 Gtk2-Ex-FormFactory gtk2-ex-formfactory
435 Gtk2-GladeXML gtk2-gladexml
436 Gtk2-Spell gtk2-spell
437 Gtk2-TrayIcon gtk2-trayicon
438 Gtk2-TrayManager gtk2-traymanager
440 I18N-LangTags i18n-langtags
443 Inline-Files inline-files
444 Locale-Maketext locale-maketext
445 Locale-Maketext-Fuzzy locale-maketext-fuzzy
446 Locale-Maketext-Lexicon locale-maketext-lexicon
447 Log-Dispatch log-dispatch
449 Module-Info module-info
450 MogileFS-Server mogilefs-server
454 Net-SSH-Perl net-ssh-perl
455 Net-Server net-server
456 OLE-Storage_Lite OLE-StorageLite
457 Ogg-Vorbis-Header ogg-vorbis-header
461 Regexp-Common regexp-common
462 Set-Scalar set-scalar
463 String-CRC32 string-crc32
464 Template-Plugin-Latex Template-Latex
465 Text-Autoformat text-autoformat
466 Text-Reform text-reform
467 Text-Template text-template
468 Text-Wrapper text-wrapper
469 Tie-EncryptedHash tie-encryptedhash
474 gettext Locale-gettext