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>;
37 my $gentoo_pkg = name_c2g($cpan_dist);
39 Maps a CPAN distribution name to the corresponding Gentoo package name.
45 return $name_mismatch{$name} || $name;
50 my @gentoo_licenses = license_c2g(@meta_licenses);
52 Maps F<META.yml> C<license> tag values to the corresponding list of Gentoo license identifiers.
53 Duplicates are stripped off.
55 The included data was gathered from L<Module::Install> and L<Software::License>.
60 apache => [ 'Apache-2.0' ],
61 artistic => [ 'Artistic' ],
62 artistic_2 => [ 'Artistic-2' ],
67 lgpl => [ 'LGPL-2.1' ],
68 lgpl2 => [ 'LGPL-2.1' ],
69 lgpl3 => [ 'LGPL-3' ],
71 mozilla => [ 'MPL-1.1' ],
72 perl => [ 'Artistic', 'GPL-2' ],
79 map @{$licenses{+lc} || []},
86 my $gentoo_version = version_c2g($cpan_dist, $cpan_version);
88 Converts the C<$version> of a CPAN distribution C<$name> to a Gentoo version number.
92 my $default_mapping = sub {
93 my ($version, @no_strip) = @_;
95 my $is_dev = $version =~ /_/;
96 my $has_v = $version =~ s/^v//;
105 my $dots = $version =~ y/\.//;
108 if ($has_v or $dots >= 2) {
109 @parts = split /\./, $version;
111 ($parts[0], my $subversion) = split /\./, $version, 2;
112 $subversion = '0' unless defined $subversion;
113 my $sublen = length $subversion;
115 $subversion .= '0' x (6 - $sublen);
117 my $pad = $sublen % 3;
118 $subversion .= '0' x (3 - $pad) if $pad;
120 push @parts, $subversion =~ /(...)/g;
123 for my $i (0 .. $#parts) {
124 next if $no_strip[$i];
125 $parts[$i] =~ s/^0+([^0]|0\z)/$1/;
127 $version = join '.', @parts;
129 $version .= '_rc' if $is_dev;
134 my $default_but_ignore_v = sub {
139 return $default_mapping->($version);
142 my $default_but_no_strip_1 = sub {
143 return $default_mapping->($_[0], 0, 1);
146 my $default_but_no_strip_2 = sub {
147 return $default_mapping->($_[0], 0, 1, 1);
150 my $insert_dot_every = sub {
151 my ($version, $step, $strip) = @_;
153 my $is_dev = $version =~ /_/;
164 ($parts[0], my $subversion) = split /\./, $version, 2;
165 $subversion =~ s/\.//g;
166 my $pat = sprintf '.{1,%d}', $step || 1;
167 push @parts, $subversion =~ /($pat)/g;
170 s/^0+([^0]|0\z)/$1/ for @parts;
172 $version = join '.', @parts;
174 $version .= '_rc' if $is_dev;
179 my $simple_cleanup = sub {
182 my $is_dev = $version =~ /_/;
192 $version .= '_rc' if $is_dev;
197 my $simple_and_correct_suffixes = sub {
200 $version = $simple_cleanup->($version);
201 $version =~ s/(?<!_)((?:alpha|beta|pre|rc|p)\d*)\b/_$1/g;
206 my $simple_and_strip_letters = sub {
209 $version = $simple_cleanup->($version);
210 $version =~ s/(?<=\d)[a-z]+//g;
215 my $simple_and_letters_as_suffix = sub {
218 $version = $simple_cleanup->($version);
219 $version =~ s/(?<=\d)b(?=\d)/_beta/g;
224 my %version_mismatch;
226 $version_mismatch{$_} = $default_but_ignore_v for qw<
227 Net-DNS-Resolver-Programmable
230 $version_mismatch{$_} = $default_but_no_strip_1 for qw<
234 MogileFS-Client-Async
240 $version_mismatch{$_} = sub { $insert_dot_every->($_[0], 1) } for qw<
245 $version_mismatch{$_} = sub { $insert_dot_every->($_[0], 3) } for qw<
249 $version_mismatch{$_} = $simple_cleanup for qw<
264 TAP-Parser-SourceHandler-pgTAP
271 $version_mismatch{$_} = $simple_and_correct_suffixes for qw<
275 $version_mismatch{$_} = $simple_and_strip_letters for qw<
280 $version_mismatch{$_} = $simple_and_letters_as_suffix for qw<
287 return unless defined $v;
290 $handler = $version_mismatch{$n} if defined $n;
291 $handler = $default_mapping unless defined $handler;
293 return $handler->($v);
296 =head2 C<perl_version_c2g>
298 my $gentoo_version = perl_version_c2g($perl_version);
300 Converts a perl version number as you can find it in CPAN prerequisites to a Gentoo version number.
304 sub perl_version_c2g {
307 return unless defined $v and $v =~ /^[0-9\.]+$/;
310 if (my ($version, $subversion) = $v =~ /^([0-9]+)\.(0[^\.]+)$/) {
311 my $len = length $subversion;
312 if (my $pad = $len % 3) {
313 $subversion .= '0' x (3 - $pad);
315 @parts = ($version, $subversion =~ /(.{1,3})/g);
317 @parts = split /\./, $v;
320 return join '.', map int, @parts;
323 =head2 C<get_portage_timestamp>
325 my $timestamp = get_portage_timestamp($portage);
327 Get the numerical timestamp associated with the portage tree located at C<$portage>.
328 Requires L<POSIX::strptime>, and returns C<undef> if it is not available.
332 sub get_portage_timestamp {
337 eval { require POSIX::strptime } or return;
340 my $file = File::Spec->catfile($portage, 'metadata', 'timestamp.chk');
341 return unless -e $file;
344 open my $fh, '<', $file or return;
348 s/^\s*//, s/\s*$// for $timestamp;
351 if ($timestamp =~ s/\s+([+-])([0-9]{2})([0-9]{2})$//) {
352 $shift = ($2 * 60 + $3) * 60;
353 $shift = -$shift if $1 eq '-';
356 my $old_lc_all = POSIX::setlocale(POSIX::LC_ALL());
357 POSIX::setlocale(POSIX::LC_ALL(), 'C');
358 $timestamp = POSIX::mktime(
359 POSIX::strptime($timestamp, '%a, %d %b %Y %H:%M:%S')
361 POSIX::setlocale(POSIX::LC_ALL(), $old_lc_all);
362 $timestamp += $shift;
369 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.
373 sub TIMESTAMP () { 1367759701 }
377 This module does not export any symbol.
378 All its functions have to be called by their fully qualified names.
382 L<CPANPLUS::Dist::Gentoo>.
386 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
388 You can contact me by mail or on C<irc.perl.org> (vincent).
392 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>.
393 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
397 You can find documentation for this module with the perldoc command.
399 perldoc CPANPLUS::Dist::Gentoo
401 =head1 COPYRIGHT & LICENSE
403 Copyright 2009,2010,2011,2012 Vincent Pit, all rights reserved.
405 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
409 1; # End of CPANPLUS::Dist::Gentoo::Maps
413 CGI-Simple Cgi-Simple
414 CGI-SpeedyCGI SpeedyCGI
415 Cache-Mmap cache-mmap
416 Class-Loader class-loader
417 Class-ReturnValue class-returnvalue
418 Config-General config-general
419 Convert-ASCII-Armour convert-ascii-armour
420 Convert-PEM convert-pem
422 Crypt-DES_EDE3 crypt-des-ede3
425 Crypt-IDEA crypt-idea
426 Crypt-Primes crypt-primes
428 Crypt-Random crypt-random
429 DBIx-SearchBuilder dbix-searchbuilder
430 Data-Buffer data-buffer
433 Digest-BubbleBabble digest-bubblebabble
434 Digest-MD2 digest-md2
435 ExtUtils-Depends extutils-depends
436 ExtUtils-PkgConfig extutils-pkgconfig
437 Frontier-RPC frontier-rpc
440 Gnome2-Canvas gnome2-canvas
441 Gnome2-GConf gnome2-gconf
442 Gnome2-VFS gnome2-vfs-perl
443 Gnome2-Wnck gnome2-wnck
445 Gtk2-Ex-FormFactory gtk2-ex-formfactory
446 Gtk2-GladeXML gtk2-gladexml
447 Gtk2-Spell gtk2-spell
448 Gtk2-TrayIcon gtk2-trayicon
449 Gtk2-TrayManager gtk2-traymanager
451 I18N-LangTags i18n-langtags
454 Inline-Files inline-files
455 Locale-Maketext locale-maketext
456 Locale-Maketext-Fuzzy locale-maketext-fuzzy
457 Locale-Maketext-Lexicon locale-maketext-lexicon
458 Log-Dispatch log-dispatch
460 Module-Info module-info
461 MogileFS-Server mogilefs-server
465 Net-SSH-Perl net-ssh-perl
466 Net-Server net-server
467 OLE-Storage_Lite OLE-StorageLite
468 Ogg-Vorbis-Header ogg-vorbis-header
472 Regexp-Common regexp-common
473 Set-Scalar set-scalar
474 String-CRC32 string-crc32
475 Template-Plugin-Latex Template-Latex
476 Text-Autoformat text-autoformat
477 Text-Reform text-reform
478 Text-Template text-template
479 Text-Wrapper text-wrapper
480 Tie-EncryptedHash tie-encryptedhash
485 gettext Locale-gettext