blib/lib/PPM/Repositories.pm

filter: Statementstmt 90.0% 54 / 60 Branchbran 77.2% 17 / 22 Conditioncond 60.0% 18 / 30 MC/DCmcdc 40.0% 8 / 20 Subroutinesub 85.7% 6 / 7 Podpod 100% 3 / 3 totaltotal 74.6% 106 / 142 CC 12 SCAR 19.9
CC
12
Cov
79%
get
12.9
_default_arch
6.0
list
3.3
CRAP 7.3
↑ Summary
1 package PPM::Repositories;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Config qw(%Config);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 require Exporter;
9  
10 1 our @ISA = qw(Exporter);
11 1 our @EXPORT = qw(%Repositories);
12 1 our @EXPORT_OK = qw(get list used_archs);
13 1 our $VERSION = '0.20';
14  
15 1 my %Default = (
16 Type => 'Webpage',
17 Active => 1,
18 PerlV => [ 5.8 ],
19 PerlO => ['MSWin32'],
20 );
21  
22 1 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 1 for my $name (keys %Repositories) {
135 22 for my $key (keys %Default) {
136 88 ▶ next if $Repositories{$name}{$key};
Branch: 1 branch
BranchTrueFalseTotal
if $PPM::Repositories::Repositories{$name}{$key} 18 70 88
137 70 $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 1 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 1 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 7 my $arch = $readonly_arch;
317 7 my $fullarch = "$arch-thread-multi";
318 7 ▶ $fullarch = "$arch-thread-multi-2level" if $arch =~ /^darwin/;
Branch: 1 branch
BranchTrueFalseTotal
if $arch =~ /^darwin/ 1 6 7
319 7 ▶ $fullarch = "$arch-multi-thread" if $arch =~ /^MSWin/;
Branch: 1 branch
BranchTrueFalseTotal
if $arch =~ /^MSWin/ 2 5 7
320  
321 7 for my $version (8, 10, 12, 14, 16, 18, 20) {
322 # There are no 64-bit 5.8 repositories
323 45 ▶ next if $version == 8 && $arch =~ /64/;
Branch: 1 branch
BranchTrueFalseTotal
if $version == 8 and $arch =~ /64/ 3 42 45
Condition100%3/3
$version == 8 and $arch =~ /64/
!ll&&!rl&&r
3843
MC/DC100%2/2
$version == 8 and $arch =~ /64/
$version == 8 $arch =~ /64/
Truth table100%3/3
A and B
A= $version == 8B= $arch =~ /64/
ABresult
0X0
100
111
324  
325 # There are no PPM repos for 5.16 or later for Solaris
326 42 ▶ last if $version == 16 && $arch =~ /^sun4-solaris/;
Branch: 1 branch
BranchTrueFalseTotal
if $version == 16 and $arch =~ /^sun4-solaris/ 2 40 42
Condition100%3/3
$version == 16 and $arch =~ /^sun4-solaris/
!ll&&!rl&&r
3552
MC/DC100%2/2
$version == 16 and $arch =~ /^sun4-solaris/
$version == 16 $arch =~ /^sun4-solaris/
Truth table100%3/3
A and B
A= $version == 16B= $arch =~ /^sun4-solaris/
ABresult
0X0
100
111
327  
328 # Starting with ActivePerl 5.18 all 32-bit builds use 64-bit ints
329 40 ▶ if ($version == 18 && $arch =~ /^(MSWin32-x86|i686-linux)$/) {
Branch: 1 branch
BranchTrueFalseTotal
if ($version == 18 and $arch =~ /^(MSWin32-x86|i686-linux)$/) 2 38 40
Condition100%3/3
$version == 18 and $arch =~ /^(MSWin32-x86|i686-linux)$/
!ll&&!rl&&r
3532
MC/DC100%2/2
$version == 18 and $arch =~ /^(MSWin32-x86|i686-linux)$/
$version == 18 $arch =~ /^(MSWin32-x86|i686-linux)$/
Truth table100%3/3
A and B
A= $version == 18B= $arch =~ /^(MSWin32-x86|i686-linux)$/
ABresult
0X0
100
111
330 2 $_ .= "-64int" for $arch, $fullarch;
331 }
332  
333 # There are no 32-bit PPM repos for 5.20 or later for Linux
334 40 ▶ last if $version == 20 && $arch eq "i686-linux-64int";
Branch: 1 branch
BranchTrueFalseTotal
if $version == 20 and $arch eq "i686-linux-64int" 1 39 40
Condition100%3/3
$version == 20 and $arch eq "i686-linux-64int"
!ll&&!rl&&r
3541
MC/DC100%2/2
$version == 20 and $arch eq "i686-linux-64int"
$version == 20 $arch eq "i686-linux-64int"
Truth table100%3/3
A and B
A= $version == 20B= $arch eq "i686-linux-64int"
ABresult
0X0
100
111
335  
336 39 $REPO{activestate}{arch}{"$fullarch-5.$version"} =
337 "http://ppm4.activestate.com/$arch/5.$version/${version}00/";
338 }
339 }
340  
341 0 ▶sub _default_arch {
Subroutine _default_arch: not called CC=2 SCAR=17.9
342 0 my $arch = $Config{archname};
343 0 ▶ if ($] >= 5.008) {
Branch: 1 branch
BranchTrueFalseTotal
if ($] >= "5.008") 0 0 0
344 0 $arch .= "-$Config{PERL_REVISION}.$Config{PERL_VERSION}";
345 }
346 0 return $arch;
347 }
348  
349 1 ▶sub get {
Subroutine get: called CC=8 SCAR=25.6
Pod documented
350 1 my $name = shift;
351 1 ▶ return () unless exists $REPO{$name};
Branch: 1 branch
BranchTrueFalseTotal
unless exists $REPO{$name} 0 1 1
352  
353 1 my %repo = %{$REPO{$name}};
354 1 ▶ my $arch = shift || _default_arch();
Condition33%1/3
shift() || _default_arch()
l!l&&r!l&&!r
100
MC/DC0%0/2
shift() || _default_arch()
shift() _default_arch()
Truth table33%1/3
A || B
A= shift()B= _default_arch()
ABresult
1X1
011
000
355  
356 # Set up "packlist" and "packlist_noarch" keys
357 1 ▶ my $packlist = $repo{packlist} || $repo{home};
Condition33%1/3
$repo{'packlist'} || $repo{'home'}
l!l&&r!l&&!r
010
MC/DC0%0/2
$repo{'packlist'} || $repo{'home'}
$repo{'packlist'} $repo{'home'}
Truth table33%1/3
A || B
A= $repo{'packlist'}B= $repo{'home'}
ABresult
1X1
011
000
358 1 delete $repo{packlist};
359 1 ▶ if (exists $repo{arch}{$arch}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $repo{"arch"}{$arch}) 1 0 1
360 1 $repo{packlist} = $repo{arch}{$arch};
361 1 ▶ $repo{packlist} ||= $packlist;
Condition33%1/3
$repo{"packlist"} ||= $packlist
l!l&&r!l&&!r
100
MC/DC0%0/2
$repo{"packlist"} ||= $packlist
$repo{"packlist"} $packlist
Truth table33%1/3
A ||= B
A= $repo{"packlist"}B= $packlist
ABresult
1X1
011
000
362 }
363 1 ▶ if (exists $repo{arch}{noarch}) {
Branch: 1 branch
BranchTrueFalseTotal
if (exists $repo{"arch"}{"noarch"}) 0 1 1
364 0 $repo{packlist_noarch} = $repo{arch}{noarch};
365 0 ▶ $repo{packlist_noarch} ||= $packlist;
Condition0%0/3
$repo{"packlist_noarch"} ||= $packlist
l!l&&r!l&&!r
000
MC/DC0%0/2
$repo{"packlist_noarch"} ||= $packlist
$repo{"packlist_noarch"} $packlist
Truth table0%0/3
A ||= B
A= $repo{"packlist_noarch"}B= $packlist
ABresult
1X1
011
000
366 }
367 1 delete $repo{arch};
368  
369 1 return %repo;
370 }
371  
372 1 ▶sub list {
Subroutine list: called CC=3 SCAR=12.0
Pod documented
373 1 ▶ my $arch = shift || _default_arch();
Condition33%1/3
shift() || _default_arch()
l!l&&r!l&&!r
100
MC/DC0%0/2
shift() || _default_arch()
shift() _default_arch()
Truth table33%1/3
A || B
A= shift()B= _default_arch()
ABresult
1X1
011
000
374 return sort grep {
375 1 exists $REPO{$_}{arch}{$arch} or
376 exists $REPO{$_}{arch}{noarch}
377 13 ▶ } keys %REPO;
Condition66%2/3
exists $REPO{$_}{'arch'}{$arch} || exists $REPO{$_}{'arch'}{'noarch'}
l!l&&r!l&&!r
1210
MC/DC0%0/2
exists $REPO{$_}{'arch'}{$arch} || exists $REPO{$_}{'arch'}{'noarch'}
exists $REPO{$_}{'arch'}{$arch} exists $REPO{$_}{'arch'}{'noarch'}
Truth table66%2/3
A || B
A= exists $REPO{$_}{'arch'}{$arch}B= exists $REPO{$_}{'arch'}{'noarch'}
ABresult
1X1
011
000
378 }
379  
380 1 ▶sub used_archs {
Subroutine used_archs: called CC=2 SCAR=6.9
Pod documented
381 1 my %arch;
382 1 $arch{$_} = 1 for map keys %{$REPO{$_}{arch}}, keys %REPO;
383 1 return sort keys %arch;
384 }
385  
386 1 1;
387  
388 __END__
↑ Summary