]> git.vpit.fr Git - perl/modules/CPANPLUS-Dist-Gentoo.git/blob - lib/CPANPLUS/Dist/Gentoo/Maps.pm
This is 0.06
[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.05
13
14 =cut
15
16 our $VERSION = '0.05';
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 Audio-CD                Audio-CD-disc-cover
137 CGI-Simple              Cgi-Simple
138 Cache-Mmap              cache-mmap
139 Class-Loader            class-loader
140 Class-ReturnValue       class-returnvalue
141 Config-General          config-general
142 Convert-ASCII-Armour    convert-ascii-armour
143 Convert-PEM             convert-pem
144 Crypt-CBC               crypt-cbc
145 Crypt-DES_EDE3          crypt-des-ede3
146 Crypt-DH                crypt-dh
147 Crypt-DSA               crypt-dsa
148 Crypt-IDEA              crypt-idea
149 Crypt-Primes            crypt-primes
150 Crypt-RSA               crypt-rsa
151 Crypt-Random            crypt-random
152 DBIx-SearchBuilder      dbix-searchbuilder
153 Data-Buffer             data-buffer
154 Digest                  digest-base
155 Digest-BubbleBabble     digest-bubblebabble
156 Digest-MD2              digest-md2
157 ExtUtils-Depends        extutils-depends
158 ExtUtils-PkgConfig      extutils-pkgconfig
159 Frontier-RPC            frontier-rpc
160 Gimp                    gimp-perl
161 Glib                    glib-perl
162 Gnome2-Canvas           gnome2-canvas
163 Gnome2-GConf            gnome2-gconf
164 Gnome2-Print            gnome2-print
165 Gnome2-VFS              gnome2-vfs-perl
166 Gnome2-Wnck             gnome2-wnck
167 Gtk2                    gtk2-perl
168 Gtk2-Ex-FormFactory     gtk2-ex-formfactory
169 Gtk2-GladeXML           gtk2-gladexml
170 Gtk2-Spell              gtk2-spell
171 Gtk2-TrayIcon           gtk2-trayicon
172 Gtk2-TrayManager        gtk2-traymanager
173 Gtk2Fu                  gtk2-fu
174 I18N-LangTags           i18n-langtags
175 Image-Info              ImageInfo
176 Image-Size              ImageSize
177 Inline-Files            inline-files
178 Locale-Maketext         locale-maketext
179 Locale-Maketext-Fuzzy   locale-maketext-fuzzy
180 Locale-Maketext-Lexicon locale-maketext-lexicon
181 Log-Dispatch            log-dispatch
182 Math-Pari               math-pari
183 Module-Info             module-info
184 Net-Ping                net-ping
185 Net-SFTP                net-sftp
186 Net-SSH-Perl            net-ssh-perl
187 Net-Server              net-server
188 OLE-Storage_Lite        OLE-StorageLite
189 Ogg-Vorbis-Header       ogg-vorbis-header
190 PathTools               File-Spec
191 Pod-Parser              PodParser
192 Regexp-Common           regexp-common
193 SDL_Perl                sdl-perl
194 Set-Scalar              set-scalar
195 String-CRC32            string-crc32
196 Text-Autoformat         text-autoformat
197 Text-Reform             text-reform
198 Text-Template           text-template
199 Text-Wrapper            text-wrapper
200 Tie-EncryptedHash       tie-encryptedhash
201 Tk                      perl-tk
202 Wx                      wxperl
203 YAML                    yaml
204 gettext                 Locale-gettext
205 txt2html                TextToHTML