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