]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blob - lib/CPANPLUS/Dist/Gentoo/Maps.pm
5323307c5f816828ad3a6c0b337d53dab68df422
[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.08
13
14 =cut
15
16 our $VERSION = '0.08';
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  $v =~ y/-/_/;
83  $v =~ y/0-9._//cd;
84
85  $v =~ s/^[._]*//;
86  $v =~ s/[._]*$//;
87  $v =~ s/([._])[._]*/$1/g;
88
89  ($v, my $patch, my @rest) = split /_/, $v;
90  $v .= '_p' . $patch if defined $patch;
91  $v .= join('.', '', @rest) if @rest;
92
93  return $v;
94 }
95
96 =head2 C<version_gcmp $va, $vb>
97
98 Compares two Gentoo versions.
99
100 =cut
101
102 sub version_gcmp {
103  my ($a, $b) = map { defined() ? $_ : 0 } @_;
104
105  for ($a, $b) {
106   s/^[._]+//g;
107   s/[._]+$//g;
108   if (/^([\d.]*\d)\.*(?:_p\.*(\d[\d.]*))?\.*(?:-r(\d+))?$/) {
109    $_ = {
110     v => [ split /\.+/, $1 ],
111     p => [ split /\.+/, $2 || 0 ],
112     r => [ $3 || 0 ],
113    };
114   } else {
115    require Carp;
116    Carp::croak("Couldn't parse version string '$_'");
117   }
118  }
119
120  for my $k (qw/v p r/) {
121   my $xa = $a->{$k};
122   my $xb = $b->{$k};
123   while (@$xa or @$xb) {
124    my $na = shift(@$xa) || 0;
125    my $nb = shift(@$xb) || 0;
126    my $c  = $na <=> $nb;
127    return $c if $c;
128   }
129  }
130
131  return 0;
132 }
133
134 =head1 SEE ALSO
135
136 L<CPANPLUS::Dist::Gentoo>.
137
138 =head1 AUTHOR
139
140 Vincent Pit, C<< <perl at profvince.com> >>, L<http://www.profvince.com>.
141
142 You can contact me by mail or on C<irc.perl.org> (vincent).
143
144 =head1 BUGS
145
146 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>.  I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
147
148 =head1 SUPPORT
149
150 You can find documentation for this module with the perldoc command.
151
152     perldoc CPANPLUS::Dist::Gentoo
153
154 =head1 COPYRIGHT & LICENSE
155
156 Copyright 2009 Vincent Pit, all rights reserved.
157
158 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
159
160 =cut
161
162 1; # End of CPANPLUS::Dist::Gentoo::Maps
163
164 __DATA__
165 ANSIColor               Term-ANSIColor
166 AcePerl                 Ace
167 Audio-CD                Audio-CD-disc-cover
168 CGI-Simple              Cgi-Simple
169 Cache-Mmap              cache-mmap
170 Class-Loader            class-loader
171 Class-ReturnValue       class-returnvalue
172 Config-General          config-general
173 Convert-ASCII-Armour    convert-ascii-armour
174 Convert-PEM             convert-pem
175 Crypt-CBC               crypt-cbc
176 Crypt-DES_EDE3          crypt-des-ede3
177 Crypt-DH                crypt-dh
178 Crypt-DSA               crypt-dsa
179 Crypt-IDEA              crypt-idea
180 Crypt-Primes            crypt-primes
181 Crypt-RSA               crypt-rsa
182 Crypt-Random            crypt-random
183 DBIx-SearchBuilder      dbix-searchbuilder
184 Data-Buffer             data-buffer
185 Digest                  digest-base
186 Digest-BubbleBabble     digest-bubblebabble
187 Digest-MD2              digest-md2
188 ExtUtils-Depends        extutils-depends
189 ExtUtils-PkgConfig      extutils-pkgconfig
190 Frontier-RPC            frontier-rpc
191 Gimp                    gimp-perl
192 Glib                    glib-perl
193 Gnome2-Canvas           gnome2-canvas
194 Gnome2-GConf            gnome2-gconf
195 Gnome2-Print            gnome2-print
196 Gnome2-VFS              gnome2-vfs-perl
197 Gnome2-Wnck             gnome2-wnck
198 Gtk2                    gtk2-perl
199 Gtk2-Ex-FormFactory     gtk2-ex-formfactory
200 Gtk2-GladeXML           gtk2-gladexml
201 Gtk2-Spell              gtk2-spell
202 Gtk2-TrayIcon           gtk2-trayicon
203 Gtk2-TrayManager        gtk2-traymanager
204 Gtk2Fu                  gtk2-fu
205 I18N-LangTags           i18n-langtags
206 Image-Info              ImageInfo
207 Image-Size              ImageSize
208 Inline-Files            inline-files
209 Locale-Maketext         locale-maketext
210 Locale-Maketext-Fuzzy   locale-maketext-fuzzy
211 Locale-Maketext-Lexicon locale-maketext-lexicon
212 Log-Dispatch            log-dispatch
213 Math-Pari               math-pari
214 Module-Info             module-info
215 NTLM                    Authen-NTLM
216 Net-Ping                net-ping
217 Net-SFTP                net-sftp
218 Net-SSH-Perl            net-ssh-perl
219 Net-Server              net-server
220 OLE-Storage_Lite        OLE-StorageLite
221 Ogg-Vorbis-Header       ogg-vorbis-header
222 PathTools               File-Spec
223 Perl-Tidy               perltidy
224 Pod-Parser              PodParser
225 Regexp-Common           regexp-common
226 SDL_Perl                sdl-perl
227 Set-Scalar              set-scalar
228 String-CRC32            string-crc32
229 Text-Autoformat         text-autoformat
230 Text-Reform             text-reform
231 Text-Template           text-template
232 Text-Wrapper            text-wrapper
233 Tie-EncryptedHash       tie-encryptedhash
234 Tk                      perl-tk
235 Wx                      wxperl
236 YAML                    yaml
237 gettext                 Locale-gettext
238 txt2html                TextToHTML