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   6435 use strict;
  1         3  
  1         45  
4 1     1   6 use warnings;
  1         3  
  1         277  
5            
6 1     1   8 use Config qw(%Config);
  1         14  
  1         1551  
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.19';
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 ],
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 ],
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             'uwinnipeg56-ppm3' => {
86             location => 'http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer',
87             Type => 'PPMServer',
88             Notes => 'University of Winnipeg: 5.6 (PPM3)',
89             PerlV => [ 5.6 ],
90             },
91             uwinnipeg56 => {
92             location => 'http://theoryx5.uwinnipeg.ca/ppmpackages',
93             Notes => 'University of Winnipeg: 5.6',
94             PerlV => [ 5.6 ],
95             },
96             'uwinnipeg58-ppm3' => {
97             location => 'http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer58',
98             Type => 'PPMServer',
99             Notes => 'University of Winnipeg: 5.8 (PPM3)',
100             },
101             uwinnipeg58 => {
102             location => 'http://theoryx5.uwinnipeg.ca/ppms',
103             Notes => 'University of Winnipeg: 5.8 (PPM4)',
104             },
105             uwinnipeg510 => {
106             location => 'http://cpan.uwinnipeg.ca/PPMPackages/10xx/',
107             Notes => 'University of Winnipeg: 5.10',
108             PerlV => [ '5.10' ],
109             },
110             uwinnipeg512 => {
111             location => 'http://cpan.uwinnipeg.ca/PPMPackages/12xx/',
112             Notes => 'University of Winnipeg: 5.12',
113             PerlV => [ 5.12 ],
114             },
115             voltar => {
116             location => 'http://voltar.org/active/5.8/',
117             Notes => 'Paul Miller\'s Games::RolePlay::MapGen and Gtk2 repository',
118             },
119             wxperl => {
120             location => 'http://www.wxperl.co.uk/repository',
121             Notes => 'wxPerl modules',
122             PerlV => [ 5.8, '5.10', 5.12, 5.14 ],
123             },
124             );
125            
126             for my $name (keys %Repositories) {
127             for my $key (keys %Default) {
128             next if $Repositories{$name}{$key};
129             $Repositories{$name}{$key} = $Default{$key};
130             }
131             }
132            
133             #
134             # * An undef repo URL defaults to the "packlist" value, which
135             # in turn defaults to the "home" value.
136             #
137             # * The "packlist" and "arch" keys are implementation details
138             # and are not exposed outside the module.
139             #
140             my %REPO = (
141             activestate => {
142             home => 'http://ppm.activestate.com/',
143             desc => 'Default ActivePerl repository from ActiveState',
144             arch => {
145             # filled in below
146             },
147             },
148             bioperl => {
149             home => 'http://www.bioperl.org/wiki/Installing_Bioperl_on_Windows',
150             desc => 'BioPerl - Regular Releases',
151             packlist => 'http://bioperl.org/DIST/',
152             arch => {
153             'MSWin32-x86-multi-thread-5.8' => undef,
154             'MSWin32-x86-multi-thread-5.10' => undef,
155             },
156             },
157             'bioperl-rc' => {
158             home => 'http://www.bioperl.org/wiki/Installing_Bioperl_on_Windows',
159             desc => 'BioPerl - Release Candidates',
160             packlist => 'http://bioperl.org/DIST/RC/',
161             arch => {
162             'MSWin32-x86-multi-thread-5.8' => undef,
163             'MSWin32-x86-multi-thread-5.10' => undef,
164             },
165             },
166             bribes => {
167             home => 'http://www.bribes.org/perl/ppmdir.html',
168             desc => 'Bribes de Perl',
169             packlist => 'http://www.bribes.org/perl/ppm',
170             arch => {
171             'MSWin32-x86-multi-thread' => undef,
172             'MSWin32-x86-multi-thread-5.8' => undef,
173             'MSWin32-x86-multi-thread-5.10' => undef,
174             'MSWin32-x86-multi-thread-5.12' => undef,
175             },
176             },
177             gtk2 => {
178             home => 'http://www.lostmind.de/gtk2-perl',
179             desc => 'gtk2-perl bindings (check also \'voltar\' repository)',
180             packlist => 'http://www.lostmind.de/gtk2-perl/ppm/',
181             arch => {
182             'MSWin32-x86-multi-thread-5.8' => undef,
183             },
184             },
185             log4perl => {
186             home => 'http://log4perl.sourceforge.net',
187             desc => 'log4perl',
188             packlist => 'http://log4perl.sourceforge.net/ppm',
189             arch => {
190             'noarch' => undef,
191             },
192             },
193             roth => {
194             home => 'http://www.roth.net/perl/packages/',
195             desc => 'Dave Roth\'s modules',
196             arch => {
197             'MSWin32-x86-multi-thread' => undef,
198             'MSWin32-x86-multi-thread-5.8' => undef,
199             },
200             },
201             sisyphusion => {
202             home => 'http://www.sisyphusion.tk/ppm/ppmindex.html',
203             desc => 'Math, PDL, Gtk2 and other ad hoc',
204             packlist => 'http://www.sisyphusion.tk/ppm',
205             arch => {
206             'MSWin32-x86-multi-thread' => undef,
207             'MSWin32-x86-multi-thread-5.8' => undef,
208             'MSWin32-x86-multi-thread-5.10' => undef,
209             'MSWin32-x64-multi-thread-5.10' => undef,
210             'MSWin32-x86-multi-thread-5.12' => undef,
211             'MSWin32-x64-multi-thread-5.12' => undef,
212             'MSWin32-x86-multi-thread-5.14' => undef,
213             'MSWin32-x64-multi-thread-5.14' => undef,
214             },
215             },
216             tcool => {
217             home => 'http://ppm.tcool.org/intro/register',
218             desc => 'Kenichi Ishigaki\'s repository',
219             packlist => 'http://ppm.tcool.org/archives/',
220             arch => {
221             'MSWin32-x86-multi-thread-5.8' => undef,
222             },
223             },
224             trouchelle => {
225             home => 'http://trouchelle.com/perl/ppmrepview.pl',
226             desc => 'Trouchelle',
227             arch => {
228             'MSWin32-x86-multi-thread-5.8' =>
229             'http://trouchelle.com/ppm/',
230             'MSWin32-x86-multi-thread-5.10' =>
231             'http://trouchelle.com/ppm10/',
232             'MSWin32-x86-multi-thread-5.12' =>
233             'http://trouchelle.com/ppm12/',
234             },
235             },
236             uwinnipeg => {
237             home => 'http://cpan.uwinnipeg.ca/',
238             desc => 'University of Winnipeg',
239             arch => {
240             'MSWin32-x86-multi-thread' =>
241             'http://theoryx5.uwinnipeg.ca/ppmpackages/',
242             'MSWin32-x86-multi-thread-5.8' =>
243             'http://theoryx5.uwinnipeg.ca/ppms/',
244             'MSWin32-x86-multi-thread-5.10' =>
245             'http://cpan.uwinnipeg.ca/PPMPackages/10xx/',
246             'MSWin32-x86-multi-thread-5.12' =>
247             'http://cpan.uwinnipeg.ca/PPMPackages/12xx/',
248             },
249             },
250             voltar => {
251             home => 'http://voltar.org/active/',
252             desc => 'Paul Miller\'s Games::RolePlay::MapGen and Gtk2 repository',
253             arch => {
254             'MSWin32-x86-multi-thread-5.8' =>
255             'http://voltar.org/active/5.8/',
256             },
257             },
258             wxperl => {
259             home => 'http://www.wxperl.co.uk/ppm.html',
260             desc => 'wxPerl modules',
261             packlist => 'http://www.wxperl.co.uk/repository',
262             arch => {
263             'MSWin32-x86-multi-thread-5.8' => undef,
264             'MSWin32-x86-multi-thread-5.10' => undef,
265             'MSWin32-x86-multi-thread-5.12' => undef,
266             'MSWin32-x86-multi-thread-5.14' => undef,
267             'MSWin32-x64-multi-thread-5.10' => undef,
268             'MSWin32-x64-multi-thread-5.12' => undef,
269             'MSWin32-x64-multi-thread-5.14' => undef,
270             'i686-linux-thread-multi-5.8' => undef,
271             'i686-linux-thread-multi-5.10' => undef,
272             'i686-linux-thread-multi-5.12' => undef,
273             'i686-linux-thread-multi-5.14' => undef,
274             'x86_64-linux-thread-multi-5.10' => undef,
275             'x86_64-linux-thread-multi-5.12' => undef,
276             'x86_64-linux-thread-multi-5.14' => undef,
277             'darwin-thread-multi-2level-5.8' => undef,
278             'darwin-thread-multi-2level-5.10' => undef,
279             'darwin-thread-multi-2level-5.12' => undef,
280             },
281             },
282             );
283            
284             # Add URLs for all ActiveState repos
285             for my $arch (qw(
286             IA64.ARCHREV_0
287             IA64.ARCHREV_0-LP64
288             MSWin32-x64
289             MSWin32-x86
290             PA-RISC1.1
291             PA-RISC2.0-LP64
292             darwin
293             i686-linux
294             x86_64-linux
295             sun4-solaris
296             ))
297             {
298             my $fullarch = "$arch-thread-multi";
299             $fullarch = "$arch-thread-multi-2level" if $arch =~ /^darwin/;
300             $fullarch = "$arch-multi-thread" if $arch =~ /^MSWin/;
301            
302             unless ($arch eq "MSWin32-x64" || $arch eq "x86_64-linux") {
303             # There are no 64-bit 5.8 repositories
304             $REPO{activestate}{arch}{"$fullarch-5.8"} =
305             "http://ppm4.activestate.com/$arch/5.8/800/";
306             }
307            
308             # There are no HP-UX 5.10 repositories (yet).
309             next if $arch =~ /^(PA-RISC|IA64)/;
310            
311             $REPO{activestate}{arch}{"$fullarch-5.10"} =
312             "http://ppm4.activestate.com/$arch/5.10/1000/";
313            
314             $REPO{activestate}{arch}{"$fullarch-5.12"} =
315             "http://ppm4.activestate.com/$arch/5.12/1200/";
316             }
317            
318             sub _default_arch {
319 0     0   0 my $arch = $Config{archname};
320 0 0       0 if ($] >= 5.008) {
321 0         0 $arch .= "-$Config{PERL_REVISION}.$Config{PERL_VERSION}";
322             }
323 0         0 return $arch;
324             }
325            
326             sub get {
327 1     1 1 77 my $name = shift;
328 1 50       4 return () unless exists $REPO{$name};
329            
330 1         2 my %repo = %{$REPO{$name}};
  1         6  
331 1   33     5 my $arch = shift || _default_arch();
332            
333             # Set up "packlist" and "packlist_noarch" keys
334 1   33     6 my $packlist = $repo{packlist} || $repo{home};
335 1         3 delete $repo{packlist};
336 1 50       5 if (exists $repo{arch}{$arch}) {
337 1         2 $repo{packlist} = $repo{arch}{$arch};
338 1   33     4 $repo{packlist} ||= $packlist;
339             }
340 1 50       5 if (exists $repo{arch}{noarch}) {
341 0         0 $repo{packlist_noarch} = $repo{arch}{noarch};
342 0   0     0 $repo{packlist_noarch} ||= $packlist;
343             }
344 1         2 delete $repo{arch};
345            
346 1         6 return %repo;
347             }
348            
349             sub list {
350 1   33 1 1 130 my $arch = shift || _default_arch();
351 13 100       47 return sort grep {
352 1         4 exists $REPO{$_}{arch}{$arch} or
353             exists $REPO{$_}{arch}{noarch}
354             } keys %REPO;
355             }
356            
357             sub used_archs {
358 1     1 1 73 my %arch;
359 1         10 $arch{$_} = 1 for map keys %{$REPO{$_}{arch}}, keys %REPO;
  13         94  
360 1         27 return sort keys %arch;
361             }
362            
363             1;
364            
365             __END__