X-Git-Url: http://git.vpit.fr/?a=blobdiff_plain;f=lib%2FCPANPLUS%2FDist%2FGentoo%2FMaps.pm;h=fd1cd8a1e6f0b3d4e7abe39d1fb56289872149c9;hb=761b2973c70ba26f3442b701a2d4e8d28c083f11;hp=94d2e1603234a0c85117c0a02dfa8585f5af80c8;hpb=ae79a81243e280b798ce0c7c6a482d5f4ad78df0;p=perl%2Fmodules%2FCPANPLUS-Dist-Gentoo.git diff --git a/lib/CPANPLUS/Dist/Gentoo/Maps.pm b/lib/CPANPLUS/Dist/Gentoo/Maps.pm index 94d2e16..fd1cd8a 100644 --- a/lib/CPANPLUS/Dist/Gentoo/Maps.pm +++ b/lib/CPANPLUS/Dist/Gentoo/Maps.pm @@ -5,25 +5,25 @@ use warnings; =head1 NAME -CPANPLUS::Dist::Gentoo::Maps - Map CPAN objects to Gentoo and vice versa. +CPANPLUS::Dist::Gentoo::Maps - Map CPAN distribution names, version numbers and license identifiers to their Gentoo counterparts. =head1 VERSION -Version 0.07 +Version 0.11 =cut -our $VERSION = '0.07'; +our $VERSION = '0.11'; -=head1 DESCRPITON +=head1 DESCRIPTION This is an helper package to L. =cut -our %gentooisms; +my %name_mismatch; -/^\s*([\w-]+)\s+([\w-]+)\s*$/ and $gentooisms{$1} = $2 while ; +/^\s*([\w-]+)\s+([\w-]+)\s*$/ and $name_mismatch{$1} = $2 while ; close DATA; @@ -31,74 +31,285 @@ close DATA; =head2 C -Maps a CPAN distribution name to its Gentoo counterpart. +Maps a CPAN distribution name to the corresponding Gentoo package name. =cut sub name_c2g { my ($name) = @_; - return $gentooisms{$name} || $name; + return $name_mismatch{$name} || $name; } -=head2 C +=head2 C -Converts a CPAN version to a Gentoo version. +Maps F C tag values to the corresponding list of Gentoo license identifiers. +Duplicates are stripped off. -=cut +The included data was gathered from L and L. -sub version_c2g { - my ($v) = @_; +=cut - $v =~ y/-/_/; - $v =~ y/0-9._//cd; +my %licenses = ( + apache => [ 'Apache-2.0' ], + artistic => [ 'Artistic' ], + artistic_2 => [ 'Artistic-2' ], + bsd => [ 'BSD' ], + gpl => [ 'GPL-1' ], + gpl2 => [ 'GPL-2' ], + gpl3 => [ 'GPL-3' ], + lgpl => [ 'LGPL-2.1' ], + lgpl2 => [ 'LGPL-2.1' ], + lgpl3 => [ 'LGPL-3' ], + mit => [ 'MIT' ], + mozilla => [ 'MPL-1.1' ], + perl => [ 'Artistic', 'GPL-2' ], +); + +sub license_c2g { + my %seen; + + grep !$seen{$_}++, + map @{$licenses{+lc} || []}, + grep defined, + @_; +} - $v =~ s/^[._]*//; - $v =~ s/[._]*$//; - $v =~ s/([._])[._]*/$1/g; +=head2 C - ($v, my $patch, my @rest) = split /_/, $v; - $v .= '_p' . $patch if defined $patch; - $v .= join('.', '', @rest) if @rest; +Converts the C<$version> of a CPAN distribution C<$name> to a Gentoo version number. - return $v; -} +=cut -=head2 C +my $default_mapping = sub { + my ($version, @no_strip) = @_; -Compares two Gentoo versions. + my $is_dev = $version =~ /_/; + my $has_v = $version =~ s/^v//; -=cut + for ($version) { + y/_-//d; + s/^\.*//; + s/\.*\z//; + s/\.+/./g; + } -sub version_gcmp { - my ($a, $b) = map { defined() ? $_ : 0 } @_; - - for ($a, $b) { - s/^[._]+//g; - s/[._]+$//g; - if (/^([\d.]*\d)\.*(?:_p\.*(\d[\d.]*))?\.*(?:-r(\d+))?$/) { - $_ = { - v => [ split /\.+/, $1 ], - p => [ split /\.+/, $2 || 0 ], - r => [ $3 || 0 ], - }; + my $dots = $version =~ y/\.//; + + my @parts; + if ($has_v or $dots >= 2) { + @parts = split /\./, $version; + } else { + ($parts[0], my $subversion) = split /\./, $version, 2; + $subversion = '0' unless defined $subversion; + my $sublen = length $subversion; + if ($sublen < 6) { + $subversion .= '0' x (6 - $sublen); } else { - require Carp; - Carp::croak("Couldn't parse version string '$_'"); + my $pad = $sublen % 3; + $subversion .= '0' x (3 - $pad) if $pad; } + push @parts, $subversion =~ /(...)/g; + } + + for my $i (0 .. $#parts) { + next if $no_strip[$i]; + $parts[$i] =~ s/^0+([^0]|0\z)/$1/; + } + $version = join '.', @parts; + + $version .= '_rc' if $is_dev; + + return $version; +}; + +my $default_but_ignore_v = sub { + my ($version) = @_; + + $version =~ s/^v//; + + return $default_mapping->($version); +}; + +my $default_but_no_strip_1 = sub { + return $default_mapping->($_[0], 0, 1); +}; + +my $default_but_no_strip_2 = sub { + return $default_mapping->($_[0], 0, 1, 1); +}; + +my $insert_dot_every = sub { + my ($version, $step) = @_; + + my $is_dev = $version =~ /_/; + + for ($version) { + s/^v//; + y/_-//d; + s/^\.*//; + s/\.*\z//; + s/\.+/./g; } - for my $k (qw/v p r/) { - my $xa = $a->{$k}; - my $xb = $b->{$k}; - while (@$xa or @$xb) { - my $na = shift(@$xa) || 0; - my $nb = shift(@$xb) || 0; - my $c = $na <=> $nb; - return $c if $c; + my @parts; + ($parts[0], my $subversion) = split /\./, $version, 2; + $subversion =~ s/\.//g; + my $pat = sprintf '.{1,%d}', $step || 1; + push @parts, $subversion =~ /($pat)/g; + + s/^0+([^0]|0\z)/$1/ for @parts; + $version = join '.', @parts; + + $version .= '_rc' if $is_dev; + + return $version; +}; + +my $simple_cleanup = sub { + my ($version) = @_; + + my $is_dev = $version =~ /_/; + + for ($version) { + s/^v//; + y/_-//d; + s/^\.*//; + s/\.*\z//; + s/\.+/./g; + } + + $version .= '_rc' if $is_dev; + + return $version; +}; + +my $simple_and_correct_suffixes = sub { + my ($version) = @_; + + $version = $simple_cleanup->($version); + $version =~ s/(?($version); + $version =~ s/(?<=\d)[a-z]+//g; + + return $version; +}; + +my $simple_and_letters_as_suffix = sub { + my ($version) = @_; + + $version = $simple_cleanup->($version); + $version =~ s/(?<=\d)b(?=\d)/_beta/g; + + return $version; +}; + +my %version_mismatch; + +$version_mismatch{$_} = $default_but_ignore_v for qw< + Net-DNS-Resolver-Programmable +>; + +$version_mismatch{$_} = $default_but_no_strip_1 for qw< + Crypt-RC4 + File-Grep + MogileFS-Client-Async + MogileFS-Network +>; + +$version_mismatch{$_} = $default_but_no_strip_2 for qw< + Net-IMAP-Simple +>; + +$version_mismatch{$_} = sub { $insert_dot_every->($_[0], 1) } for qw< + HTTP-Cookies + HTTP-Negotiate +>; + +$version_mismatch{$_} = sub { $insert_dot_every->($_[0], 3) } for qw< + POE-Component-IKC +>; + +$version_mismatch{$_} = $simple_cleanup for qw< + Alien-SDL + CGI-SpeedyCGI + Class-ISA + Data-Uniqid + ExtUtils-Install + File-Path + Getopt-GUI-Long + Gtk2-Notify + HTML-Table + I18N-LangTags + IO + IPC-System-Simple + Log-TraceMessages + MusicBrainz-DiscID + Net-IRC + Net-Ping + SDL + SOAP-WSDL + TeX-Encode + Tie-Simple + Time-Piece + WattsUp-Daemon +>; + +$version_mismatch{$_} = $simple_and_correct_suffixes for qw< + Gimp + XML-Grove +>; + +$version_mismatch{$_} = $simple_and_strip_letters for qw< + DelimMatch + SGMLSpm +>; + +$version_mismatch{$_} = $simple_and_letters_as_suffix for qw< + Frontier-RPC +>; + +sub version_c2g { + my ($n, $v) = @_; + + return unless defined $v; + + my $handler; + $handler = $version_mismatch{$n} if defined $n; + $handler = $default_mapping unless defined $handler; + + return $handler->($v); +} + +=head2 C + +Converts a perl version number as you can find it in CPAN prerequisites to a Gentoo version number. + +=cut + +sub perl_version_c2g { + my ($v) = @_; + + return unless defined $v and $v =~ /^[0-9\.]+$/; + + my @parts; + if (my ($version, $subversion) = $v =~ /^([0-9]+)\.(0[^\.]+)$/) { + my $len = length $subversion; + if (my $pad = $len % 3) { + $subversion .= '0' x (3 - $pad); } + @parts = ($version, $subversion =~ /(.{1,3})/g); + } else { + @parts = split /\./, $v; } - return 0; + return join '.', map int, @parts; } =head1 SEE ALSO @@ -113,7 +324,8 @@ You can contact me by mail or on C (vincent). =head1 BUGS -Please report any bugs or feature requests to C, or through the web interface at L. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. +Please report any bugs or feature requests to C, or through the web interface at L. +I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. =head1 SUPPORT @@ -123,7 +335,7 @@ You can find documentation for this module with the perldoc command. =head1 COPYRIGHT & LICENSE -Copyright 2009 Vincent Pit, all rights reserved. +Copyright 2009,2010,2011 Vincent Pit, all rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. @@ -132,10 +344,10 @@ This program is free software; you can redistribute it and/or modify it under th 1; # End of CPANPLUS::Dist::Gentoo::Maps __DATA__ -ANSIColor Term-ANSIColor AcePerl Ace -Audio-CD Audio-CD-disc-cover CGI-Simple Cgi-Simple +CGI-SpeedyCGI SpeedyCGI +CPAN-Mini-Phalanx100 CPAN-Mini-Phalanx Cache-Mmap cache-mmap Class-Loader class-loader Class-ReturnValue class-returnvalue @@ -152,6 +364,7 @@ Crypt-RSA crypt-rsa Crypt-Random crypt-random DBIx-SearchBuilder dbix-searchbuilder Data-Buffer data-buffer +Date-Manip DateManip Digest digest-base Digest-BubbleBabble digest-bubblebabble Digest-MD2 digest-md2 @@ -160,9 +373,9 @@ ExtUtils-PkgConfig extutils-pkgconfig Frontier-RPC frontier-rpc Gimp gimp-perl Glib glib-perl +Gnome2 gnome2-perl Gnome2-Canvas gnome2-canvas Gnome2-GConf gnome2-gconf -Gnome2-Print gnome2-print Gnome2-VFS gnome2-vfs-perl Gnome2-Wnck gnome2-wnck Gtk2 gtk2-perl @@ -182,6 +395,8 @@ Locale-Maketext-Lexicon locale-maketext-lexicon Log-Dispatch log-dispatch Math-Pari math-pari Module-Info module-info +MogileFS-Server mogilefs-server +NTLM Authen-NTLM Net-Ping net-ping Net-SFTP net-sftp Net-SSH-Perl net-ssh-perl @@ -192,7 +407,6 @@ PathTools File-Spec Perl-Tidy perltidy Pod-Parser PodParser Regexp-Common regexp-common -SDL_Perl sdl-perl Set-Scalar set-scalar String-CRC32 string-crc32 Text-Autoformat text-autoformat @@ -200,8 +414,10 @@ Text-Reform text-reform Text-Template text-template Text-Wrapper text-wrapper Tie-EncryptedHash tie-encryptedhash +Time-Period Period Tk perl-tk Wx wxperl +XML-Sablotron XML-Sablot YAML yaml gettext Locale-gettext txt2html TextToHTML