]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blob - lib/CPANPLUS/Dist/Gentoo/Maps.pm
1aa7d85458442f641dcf21d7fa48e466778a853e
[perl/modules/CPANPLUS-Dist-Gentoo.git] / lib / CPANPLUS / Dist / Gentoo / Maps.pm
1 package CPANPLUS::Dist::Gentoo::Maps;
2
3 use strict;
4 use warnings;
5
6 =head1 NAME
7
8 CPANPLUS::Dist::Gentoo::Maps - Map CPAN objects to Gentoo and vice versa.
9
10 =head1 VERSION
11
12 Version 0.10
13
14 =cut
15
16 our $VERSION = '0.10';
17
18 =head1 DESCRPITON
19
20 This is an helper package to L<CPANPLUS::Dist::Gentoo>.
21
22 =cut
23
24 our %gentooisms;
25
26 /^\s*([\w-]+)\s+([\w-]+)\s*$/ and $gentooisms{$1} = $2 while <DATA>;
27
28 close DATA;
29
30 =head1 FUNCTIONS
31
32 =head2 C<name_c2g $name>
33
34 Maps a CPAN distribution name to its Gentoo counterpart.
35
36 =cut
37
38 sub name_c2g {
39  my ($name) = @_;
40  return $gentooisms{$name} || $name;
41 }
42
43 =head2 C<license_c2g @licenses>
44
45 Maps F<META.yml> C<license> tag values to the corresponding list of Gentoo licenses identifiers.
46 Duplicates are stripped off.
47
48 The included data was gathered from L<Module::Install> and L<Software::License>.
49
50 =cut
51
52 my %licenses = (
53  apache     => [ 'Apache-2.0' ],
54  artistic   => [ 'Artistic' ],
55  artistic_2 => [ 'Artistic-2' ],
56  bsd        => [ 'BSD' ],
57  gpl        => [ 'GPL-1' ],
58  gpl2       => [ 'GPL-2' ],
59  gpl3       => [ 'GPL-3' ],
60  lgpl       => [ 'LGPL-2.1' ],
61  lgpl2      => [ 'LGPL-2.1' ],
62  lgpl3      => [ 'LGPL-3' ],
63  mit        => [ 'MIT' ],
64  mozilla    => [ 'MPL-1.1' ],
65  perl       => [ 'Artistic', 'GPL-2' ],
66 );
67
68 sub license_c2g {
69  my %seen;
70  grep !$seen{$_}++, map @{$licenses{+lc} || []}, @_;
71 }
72
73 =head2 C<version_c2g $version>
74
75 Converts a CPAN version to a Gentoo version.
76
77 =cut
78
79 sub version_c2g {
80  my ($v) = @_;
81
82  return unless defined $v;
83
84  $v =~ y/-/_/;
85  $v =~ y/0-9._//cd;
86
87  $v =~ s/^[._]*//;
88  $v =~ s/[._]*$//;
89  $v =~ s/([._])[._]*/$1/g;
90
91  ($v, my $patch, my @rest) = split /_/, $v;
92  $v .= '_p' . $patch if defined $patch;
93  $v .= join('.', '', @rest) if @rest;
94
95  return $v;
96 }
97
98 =head2 C<perl_version_c2g $version>
99
100 Converts a perl version as you can find it in prerequisites to a Gentoo version number.
101
102 =cut
103
104 sub perl_version_c2g {
105  my ($v) = @_;
106
107  return unless defined $v and $v =~ /^[0-9\.]+$/;
108
109  my @parts;
110  if (my ($version, $subversion) = $v =~ /^([0-9]+)\.(0[^\.]+)$/) {
111   my $len = length $subversion;
112   if (my $pad = $len % 3) {
113    $subversion .= '0' x (3 - $pad);
114   }
115   @parts = ($version, $subversion =~ /(.{1,3})/g);
116  } else {
117   @parts = split /\./, $v;
118  }
119
120  return join '.', map int, @parts;
121 }
122
123 =head1 SEE ALSO
124
125 L<CPANPLUS::Dist::Gentoo>.
126
127 =head1 AUTHOR
128
129 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
130
131 You can contact me by mail or on C<irc.perl.org> (vincent).
132
133 =head1 BUGS
134
135 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>.
136 I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
137
138 =head1 SUPPORT
139
140 You can find documentation for this module with the perldoc command.
141
142     perldoc CPANPLUS::Dist::Gentoo
143
144 =head1 COPYRIGHT & LICENSE
145
146 Copyright 2009,2010 Vincent Pit, all rights reserved.
147
148 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
149
150 =cut
151
152 1; # End of CPANPLUS::Dist::Gentoo::Maps
153
154 __DATA__
155 ANSIColor               Term-ANSIColor
156 AcePerl                 Ace
157 Audio-CD                Audio-CD-disc-cover
158 CGI-Simple              Cgi-Simple
159 Cache-Mmap              cache-mmap
160 Class-Loader            class-loader
161 Class-ReturnValue       class-returnvalue
162 Config-General          config-general
163 Convert-ASCII-Armour    convert-ascii-armour
164 Convert-PEM             convert-pem
165 Crypt-CBC               crypt-cbc
166 Crypt-DES_EDE3          crypt-des-ede3
167 Crypt-DH                crypt-dh
168 Crypt-DSA               crypt-dsa
169 Crypt-IDEA              crypt-idea
170 Crypt-Primes            crypt-primes
171 Crypt-RSA               crypt-rsa
172 Crypt-Random            crypt-random
173 DBIx-SearchBuilder      dbix-searchbuilder
174 Data-Buffer             data-buffer
175 Date-Manip              DateManip
176 Digest                  digest-base
177 Digest-BubbleBabble     digest-bubblebabble
178 Digest-MD2              digest-md2
179 ExtUtils-Depends        extutils-depends
180 ExtUtils-PkgConfig      extutils-pkgconfig
181 Frontier-RPC            frontier-rpc
182 Gimp                    gimp-perl
183 Glib                    glib-perl
184 Gnome2-Canvas           gnome2-canvas
185 Gnome2-GConf            gnome2-gconf
186 Gnome2-Print            gnome2-print
187 Gnome2-VFS              gnome2-vfs-perl
188 Gnome2-Wnck             gnome2-wnck
189 Gtk2                    gtk2-perl
190 Gtk2-Ex-FormFactory     gtk2-ex-formfactory
191 Gtk2-GladeXML           gtk2-gladexml
192 Gtk2-Spell              gtk2-spell
193 Gtk2-TrayIcon           gtk2-trayicon
194 Gtk2-TrayManager        gtk2-traymanager
195 Gtk2Fu                  gtk2-fu
196 I18N-LangTags           i18n-langtags
197 Image-Info              ImageInfo
198 Image-Size              ImageSize
199 Inline-Files            inline-files
200 Locale-Maketext         locale-maketext
201 Locale-Maketext-Fuzzy   locale-maketext-fuzzy
202 Locale-Maketext-Lexicon locale-maketext-lexicon
203 Log-Dispatch            log-dispatch
204 Math-Pari               math-pari
205 Module-Info             module-info
206 NTLM                    Authen-NTLM
207 Net-Ping                net-ping
208 Net-SFTP                net-sftp
209 Net-SSH-Perl            net-ssh-perl
210 Net-Server              net-server
211 OLE-Storage_Lite        OLE-StorageLite
212 Ogg-Vorbis-Header       ogg-vorbis-header
213 PathTools               File-Spec
214 Perl-Tidy               perltidy
215 Pod-Parser              PodParser
216 Regexp-Common           regexp-common
217 SDL_Perl                sdl-perl
218 Set-Scalar              set-scalar
219 String-CRC32            string-crc32
220 Text-Autoformat         text-autoformat
221 Text-Reform             text-reform
222 Text-Template           text-template
223 Text-Wrapper            text-wrapper
224 Tie-EncryptedHash       tie-encryptedhash
225 Tk                      perl-tk
226 Wx                      wxperl
227 XML-Sablotron           XML-Sablot
228 YAML                    yaml
229 gettext                 Locale-gettext
230 txt2html                TextToHTML