File Coverage

blib/lib/PPM/Repositories.pm
Criterion Covered Total %
statement 29 35 82.8
branch 5 10 50.0
condition 4 15 26.6
subroutine 6 7 85.7
pod 3 3 100.0
total 47 70 67.1


line stmt bran cond sub pod time code
1             package PPM::Repositories;
2              
3 1     1   4246 use strict;
  1         2  
  1         32  
4 1     1   4 use warnings;
  1         2  
  1         27  
5              
6 1     1   4 use Config qw(%Config);
  1         7  
  1         1101  
7              
8             require Exporter;
9              
10             our @ISA = qw(Exporter);
11             our @EXPORT = qw(%Repositories);
12             our @EXPORT_OK = qw(get list used_archs);
13             our $VERSION = '0.20';
14              
15             my %Default = (
16             Type => 'Webpage',
17             Active => 1,
18             PerlV => [ 5.8 ],
19             PerlO => ['MSWin32'],
20             );
21              
22             our %Repositories = (
23             bioperl => {
24             location => 'http://bioperl.org/DIST/',
25             Notes => 'BioPerl - Regular Releases',
26             PerlV => [ 5.8, '5.10' ],
27             },
28             'bioperl-rc' => {
29             location => 'http://bioperl.org/DIST/RC/',
30             Notes => 'BioPerl - Releases Candidates',
31             PerlV => [ 5.8, '5.10' ],
32             },
33             bribes => {
34             location => 'http://www.bribes.org/perl/ppm/',
35             Notes => 'Bribes de Perl',
36             PerlV => [ 5.6, 5.8, '5.10', 5.12, 5.14, 5.16, 5.18 ],
37             },
38             gtk2 => {
39             location => 'http://www.lostmind.de/gtk2-perl/ppm/',
40             Notes => 'gtk2-perl bindings (check also \'voltar\' repository)',
41             },
42             'gtk2-old' => {
43             location => 'http://gtk2-perl.sourceforge.net/win32/ppm/',
44             Notes => 'Old "official" Gtk2 repository',
45             },
46             log4perl => {
47             location => 'http://log4perl.sourceforge.net/ppm',
48             Notes => 'log4perl (pure perl)',
49             PerlV => [ ],
50             PerlO => ['perl'],
51             },
52             roth => {
53             location => 'http://www.roth.net/perl/packages/',
54             Notes => 'Dave Roth\'s modules',
55             PerlV => [ 5.6, 5.8 ],
56             },
57             sisyphusion => {
58             location => 'http://www.sisyphusion.tk/ppm/',
59             Notes => 'Math, PDL, Gtk2 and other ad hoc',
60             PerlV => [ 5.6, 5.8, '5.10', 5.12, 5.14, 5.16, 5.18 ],
61             },
62             'tcool-ppm3' => {
63             location => 'http://ppm.tcool.org/server/ppmserver.cgi?urn:PPMServer',
64             Type => 'PPMServer',
65             Notes => 'Kenichi Ishigaki\'s repository (PPM3))',
66             },
67             tcool => {
68             location => 'http://ppm.tcool.org/archives/',
69             Notes => 'Kenichi Ishigaki\'s repository (PPM4)',
70             },
71             trouchelle58 => {
72             location => 'http://trouchelle.com/ppm/',
73             Notes => 'Trouchelle: 5.8',
74             },
75             trouchelle510 => {
76             location => 'http://trouchelle.com/ppm10/',
77             Notes => 'Trouchelle: 5.10',
78             PerlV => [ '5.10' ],
79             },
80             trouchelle512 => {
81             location => 'http://trouchelle.com/ppm12/',
82             Notes => 'Trouchelle: 5.12',
83             PerlV => [ 5.12 ],
84             },
85             trouchelle514 => {
86             location => 'http://trouchelle.com/ppm14/',
87             Notes => 'Trouchelle: 5.14',
88             PerlV => [ 5.14 ],
89             },
90             'uwinnipeg56-ppm3' => {
91             location => 'http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer',
92             Type => 'PPMServer',
93             Notes => 'University of Winnipeg: 5.6 (PPM3)',
94             PerlV => [ 5.6 ],
95             },
96             uwinnipeg56 => {
97             location => 'http://theoryx5.uwinnipeg.ca/ppmpackages',
98             Notes => 'University of Winnipeg: 5.6',
99             PerlV => [ 5.6 ],
100             },
101             'uwinnipeg58-ppm3' => {
102             location => 'http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer58',
103             Type => 'PPMServer',
104             Notes => 'University of Winnipeg: 5.8 (PPM3)',
105             },
106             uwinnipeg58 => {
107             location => 'http://theoryx5.uwinnipeg.ca/ppms',
108             Notes => 'University of Winnipeg: 5.8 (PPM4)',
109             Active => 0,
110             },
111             uwinnipeg510 => {
112             location => 'http://cpan.uwinnipeg.ca/PPMPackages/10xx/',
113             Notes => 'University of Winnipeg: 5.10',
114             PerlV => [ '5.10' ],
115             Active => 0,
116             },
117             uwinnipeg512 => {
118             location => 'http://cpan.uwinnipeg.ca/PPMPackages/12xx/',
119             Notes => 'University of Winnipeg: 5.12',
120             PerlV => [ 5.12 ],
121             Active => 0,
122             },
123             voltar => {
124             location => 'http://voltar.org/active/5.8/',
125             Notes => 'Paul Miller\'s Games::RolePlay::MapGen and Gtk2 repository',
126             },
127             wxperl => {
128             location => 'http://www.wxperl.co.uk/repository',
129             Notes => 'wxPerl modules',
130             PerlV => [ 5.8, '5.10', 5.12, 5.14, 5.16 ],
131             },
132             );
133              
134             for my $name (keys %Repositories) {
135             for my $key (keys %Default) {
136             next if $Repositories{$name}{$key};
137             $Repositories{$name}{$key} = $Default{$key};
138             }
139             }
140              
141             #
142             # * An undef repo URL defaults to the "packlist" value, which
143             # in turn defaults to the "home" value.
144             #
145             # * The "packlist" and "arch" keys are implementation details
146             # and are not exposed outside the module.
147             #
148             my %REPO = (
149             activestate => {
150             home => 'http://ppm.activestate.com/',
151             desc => 'Default ActivePerl repository from ActiveState',
152             arch => {
153             # filled in below
154             },
155             },
156             bioperl => {
157             home => 'http://www.bioperl.org/wiki/Installing_Bioperl_on_Windows',
158             desc => 'BioPerl - Regular Releases',
159             packlist => 'http://bioperl.org/DIST/',
160             arch => {
161             'MSWin32-x86-multi-thread-5.8' => undef,
162             'MSWin32-x86-multi-thread-5.10' => undef,
163             },
164             },
165             'bioperl-rc' => {
166             home => 'http://www.bioperl.org/wiki/Installing_Bioperl_on_Windows',
167             desc => 'BioPerl - Release Candidates',
168             packlist => 'http://bioperl.org/DIST/RC/',
169             arch => {
170             'MSWin32-x86-multi-thread-5.8' => undef,
171             'MSWin32-x86-multi-thread-5.10' => undef,
172             },
173             },
174             bribes => {
175             home => 'http://www.bribes.org/perl/ppmdir.html',
176             desc => 'Bribes de Perl',
177             packlist => 'http://www.bribes.org/perl/ppm',
178             arch => {
179             'MSWin32-x86-multi-thread' => undef,
180             'MSWin32-x86-multi-thread-5.8' => undef,
181             'MSWin32-x86-multi-thread-5.10' => undef,
182             'MSWin32-x86-multi-thread-5.12' => undef,
183             'MSWin32-x86-multi-thread-5.14' => undef,
184             'MSWin32-x86-multi-thread-5.16' => undef,
185             'MSWin32-x86-multi-thread-5.18-64int' => undef,
186             },
187             },
188             gtk2 => {
189             home => 'http://www.lostmind.de/gtk2-perl',
190             desc => 'gtk2-perl bindings (check also \'voltar\' repository)',
191             packlist => 'http://www.lostmind.de/gtk2-perl/ppm/',
192             arch => {
193             'MSWin32-x86-multi-thread-5.8' => undef,
194             },
195             },
196             log4perl => {
197             home => 'http://log4perl.sourceforge.net',
198             desc => 'log4perl',
199             packlist => 'http://log4perl.sourceforge.net/ppm',
200             arch => {
201             'noarch' => undef,
202             },
203             },
204             roth => {
205             home => 'http://www.roth.net/perl/packages/',
206             desc => 'Dave Roth\'s modules',
207             arch => {
208             'MSWin32-x86-multi-thread' => undef,
209             'MSWin32-x86-multi-thread-5.8' => undef,
210             },
211             },
212             sisyphusion => {
213             home => 'http://www.sisyphusion.tk/ppm/ppmindex.html',
214             desc => 'Math, PDL, Gtk2 and other ad hoc',
215             packlist => 'http://www.sisyphusion.tk/ppm',
216             arch => {
217             'MSWin32-x86-multi-thread' => undef,
218             'MSWin32-x86-multi-thread-5.8' => undef,
219             'MSWin32-x86-multi-thread-5.10' => undef,
220             'MSWin32-x86-multi-thread-5.12' => undef,
221             'MSWin32-x64-multi-thread-5.12' => undef,
222             'MSWin32-x86-multi-thread-5.14' => undef,
223             'MSWin32-x64-multi-thread-5.14' => undef,
224             'MSWin32-x86-multi-thread-5.16' => undef,
225             'MSWin32-x86-multi-thread-5.16-64int' => undef,
226             'MSWin32-x64-multi-thread-5.16' => undef,
227             },
228             },
229             tcool => {
230             home => 'http://ppm.tcool.org/intro/register',
231             desc => 'Kenichi Ishigaki\'s repository',
232             packlist => 'http://ppm.tcool.org/archives/',
233             arch => {
234             'MSWin32-x86-multi-thread-5.8' => undef,
235             },
236             },
237             trouchelle => {
238             home => 'http://trouchelle.com/perl/ppmrepview.pl',
239             desc => 'Trouchelle',
240             arch => {
241             'MSWin32-x86-multi-thread-5.8' =>
242             'http://trouchelle.com/ppm/',
243             'MSWin32-x86-multi-thread-5.10' =>
244             'http://trouchelle.com/ppm10/',
245             'MSWin32-x86-multi-thread-5.12' =>
246             'http://trouchelle.com/ppm12/',
247             'MSWin32-x86-multi-thread-5.14' =>
248             'http://trouchelle.com/ppm14/',
249             },
250             },
251             uwinnipeg => {
252             home => 'http://cpan.uwinnipeg.ca/',
253             desc => 'University of Winnipeg',
254             arch => {
255             'MSWin32-x86-multi-thread' =>
256             'http://theoryx5.uwinnipeg.ca/ppmpackages/',
257             'MSWin32-x86-multi-thread-5.8' =>
258             'http://theoryx5.uwinnipeg.ca/ppms/',
259             'MSWin32-x86-multi-thread-5.10' =>
260             'http://cpan.uwinnipeg.ca/PPMPackages/10xx/',
261             'MSWin32-x86-multi-thread-5.12' =>
262             'http://cpan.uwinnipeg.ca/PPMPackages/12xx/',
263             },
264             },
265             voltar => {
266             home => 'http://voltar.org/active/',
267             desc => 'Paul Miller\'s Games::RolePlay::MapGen and Gtk2 repository',
268             arch => {
269             'MSWin32-x86-multi-thread-5.8' =>
270             'http://voltar.org/active/5.8/',
271             },
272             },
273             wxperl => {
274             home => 'http://www.wxperl.co.uk/ppm.html',
275             desc => 'wxPerl modules',
276             packlist => 'http://www.wxperl.co.uk/repository',
277             arch => {
278             'MSWin32-x86-multi-thread-5.8' => undef,
279             'MSWin32-x86-multi-thread-5.10' => undef,
280             'MSWin32-x86-multi-thread-5.12' => undef,
281             'MSWin32-x86-multi-thread-5.14' => undef,
282             'MSWin32-x86-multi-thread-5.16' => undef,
283             'MSWin32-x64-multi-thread-5.10' => undef,
284             'MSWin32-x64-multi-thread-5.12' => undef,
285             'MSWin32-x64-multi-thread-5.14' => undef,
286             'MSWin32-x64-multi-thread-5.16' => undef,
287             'i686-linux-thread-multi-5.8' => undef,
288             'i686-linux-thread-multi-5.10' => undef,
289             'i686-linux-thread-multi-5.12' => undef,
290             'i686-linux-thread-multi-5.14' => undef,
291             'i686-linux-thread-multi-5.16' => undef,
292             'x86_64-linux-thread-multi-5.10' => undef,
293             'x86_64-linux-thread-multi-5.12' => undef,
294             'x86_64-linux-thread-multi-5.14' => undef,
295             'x86_64-linux-thread-multi-5.16' => undef,
296             'darwin-thread-multi-2level-5.8' => undef,
297             'darwin-thread-multi-2level-5.10' => undef,
298             'darwin-thread-multi-2level-5.12' => undef,
299             'darwin-thread-multi-2level-5.14' => undef,
300             'darwin-thread-multi-2level-5.16' => undef,
301             },
302             },
303             );
304              
305             # Add URLs for all ActiveState repos
306             for my $readonly_arch (qw(
307             MSWin32-x64
308             MSWin32-x86
309             darwin
310             i686-linux
311             x86_64-linux
312             sun4-solaris
313             sun4-solaris-64
314             ))
315             {
316             my $arch = $readonly_arch;
317             my $fullarch = "$arch-thread-multi";
318             $fullarch = "$arch-thread-multi-2level" if $arch =~ /^darwin/;
319             $fullarch = "$arch-multi-thread" if $arch =~ /^MSWin/;
320              
321             for my $version (8, 10, 12, 14, 16, 18, 20) {
322             # There are no 64-bit 5.8 repositories
323             next if $version == 8 && $arch =~ /64/;
324              
325             # There are no PPM repos for 5.16 or later for Solaris
326             last if $version == 16 && $arch =~ /^sun4-solaris/;
327              
328             # Starting with ActivePerl 5.18 all 32-bit builds use 64-bit ints
329             if ($version == 18 && $arch =~ /^(MSWin32-x86|i686-linux)$/) {
330             $_ .= "-64int" for $arch, $fullarch;
331             }
332              
333             # There are no 32-bit PPM repos for 5.20 or later for Linux
334             last if $version == 20 && $arch eq "i686-linux-64int";
335              
336             $REPO{activestate}{arch}{"$fullarch-5.$version"} =
337             "http://ppm4.activestate.com/$arch/5.$version/${version}00/";
338             }
339             }
340              
341             sub _default_arch {
342 0     0   0 my $arch = $Config{archname};
343 0 0       0 if ($] >= 5.008) {
344 0         0 $arch .= "-$Config{PERL_REVISION}.$Config{PERL_VERSION}";
345             }
346 0         0 return $arch;
347             }
348              
349             sub get {
350 1     1 1 43 my $name = shift;
351 1 50       4 return () unless exists $REPO{$name};
352              
353 1         1 my %repo = %{$REPO{$name}};
  1         6  
354 1   33     4 my $arch = shift || _default_arch();
355              
356             # Set up "packlist" and "packlist_noarch" keys
357 1   33     5 my $packlist = $repo{packlist} || $repo{home};
358 1         1 delete $repo{packlist};
359 1 50       3 if (exists $repo{arch}{$arch}) {
360 1         2 $repo{packlist} = $repo{arch}{$arch};
361 1   33     3 $repo{packlist} ||= $packlist;
362             }
363 1 50       4 if (exists $repo{arch}{noarch}) {
364 0         0 $repo{packlist_noarch} = $repo{arch}{noarch};
365 0   0     0 $repo{packlist_noarch} ||= $packlist;
366             }
367 1         1 delete $repo{arch};
368              
369 1         4 return %repo;
370             }
371              
372             sub list {
373 1   33 1 1 86 my $arch = shift || _default_arch();
374 13 100       34 return sort grep {
375 1         3 exists $REPO{$_}{arch}{$arch} or
376             exists $REPO{$_}{arch}{noarch}
377             } keys %REPO;
378             }
379              
380             sub used_archs {
381 1     1 1 81 my %arch;
382 1         7 $arch{$_} = 1 for map keys %{$REPO{$_}{arch}}, keys %REPO;
  13         76  
383 1         29 return sort keys %arch;
384             }
385              
386             1;
387              
388             __END__