line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# -*- Mode: cperl; coding: utf-8; cperl-indent-level: 4 -*- |
2
|
|
|
|
|
|
|
# vim: ts=4 sts=4 sw=4: |
3
|
|
|
|
|
|
|
package CPAN::Bundle; |
4
|
12
|
|
|
12
|
|
42
|
use strict; |
|
12
|
|
|
|
|
39
|
|
|
12
|
|
|
|
|
275
|
|
5
|
12
|
|
|
12
|
|
4524
|
use CPAN::Module; |
|
12
|
|
|
|
|
20
|
|
|
12
|
|
|
|
|
440
|
|
6
|
|
|
|
|
|
|
@CPAN::Bundle::ISA = qw(CPAN::Module); |
7
|
|
|
|
|
|
|
|
8
|
12
|
|
|
|
|
17906
|
use vars qw( |
9
|
|
|
|
|
|
|
$VERSION |
10
|
12
|
|
|
12
|
|
58
|
); |
|
12
|
|
|
|
|
13
|
|
11
|
|
|
|
|
|
|
$VERSION = "5.5002"; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub look { |
14
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
15
|
0
|
|
|
|
|
|
$CPAN::Frontend->myprint($self->as_string); |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
#-> CPAN::Bundle::undelay |
19
|
|
|
|
|
|
|
sub undelay { |
20
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
21
|
0
|
|
|
|
|
|
delete $self->{later}; |
22
|
0
|
|
|
|
|
|
for my $c ( $self->contains ) { |
23
|
0
|
0
|
|
|
|
|
my $obj = CPAN::Shell->expandany($c) or next; |
24
|
0
|
|
|
|
|
|
$obj->undelay; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# mark as dirty/clean |
29
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::color_cmd_tmps ; |
30
|
|
|
|
|
|
|
sub color_cmd_tmps { |
31
|
0
|
|
|
0
|
0
|
|
my($self) = shift; |
32
|
0
|
|
0
|
|
|
|
my($depth) = shift || 0; |
33
|
0
|
|
0
|
|
|
|
my($color) = shift || 0; |
34
|
0
|
|
0
|
|
|
|
my($ancestors) = shift || []; |
35
|
|
|
|
|
|
|
# a module needs to recurse to its cpan_file, a distribution needs |
36
|
|
|
|
|
|
|
# to recurse into its prereq_pms, a bundle needs to recurse into its modules |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return if exists $self->{incommandcolor} |
39
|
|
|
|
|
|
|
&& $color==1 |
40
|
0
|
0
|
0
|
|
|
|
&& $self->{incommandcolor}==$color; |
|
|
|
0
|
|
|
|
|
41
|
0
|
0
|
|
|
|
|
if ($depth>=$CPAN::MAX_RECURSION) { |
42
|
0
|
|
|
|
|
|
my $e = CPAN::Exception::RecursiveDependency->new($ancestors); |
43
|
0
|
0
|
|
|
|
|
if ($e->is_resolvable) { |
44
|
0
|
|
|
|
|
|
return $self->{incommandcolor}=2; |
45
|
|
|
|
|
|
|
} else { |
46
|
0
|
|
|
|
|
|
die $e; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
} |
49
|
|
|
|
|
|
|
# warn "color_cmd_tmps $depth $color " . $self->id; # sleep 1; |
50
|
|
|
|
|
|
|
|
51
|
0
|
|
|
|
|
|
for my $c ( $self->contains ) { |
52
|
0
|
0
|
|
|
|
|
my $obj = CPAN::Shell->expandany($c) or next; |
53
|
0
|
0
|
|
|
|
|
CPAN->debug("c[$c]obj[$obj]") if $CPAN::DEBUG; |
54
|
0
|
|
|
|
|
|
$obj->color_cmd_tmps($depth+1,$color,[@$ancestors, $self->id]); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
# never reached code? |
57
|
|
|
|
|
|
|
#if ($color==0) { |
58
|
|
|
|
|
|
|
#delete $self->{badtestcnt}; |
59
|
|
|
|
|
|
|
#} |
60
|
0
|
|
|
|
|
|
$self->{incommandcolor} = $color; |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::as_string ; |
64
|
|
|
|
|
|
|
sub as_string { |
65
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
66
|
0
|
|
|
|
|
|
$self->contains; |
67
|
|
|
|
|
|
|
# following line must be "=", not "||=" because we have a moving target |
68
|
0
|
|
|
|
|
|
$self->{INST_VERSION} = $self->inst_version; |
69
|
0
|
|
|
|
|
|
return $self->SUPER::as_string; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::contains ; |
73
|
|
|
|
|
|
|
sub contains { |
74
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
75
|
0
|
|
0
|
|
|
|
my($inst_file) = $self->inst_file || ""; |
76
|
0
|
|
|
|
|
|
my($id) = $self->id; |
77
|
0
|
0
|
|
|
|
|
$self->debug("inst_file[$inst_file]id[$id]") if $CPAN::DEBUG; |
78
|
0
|
0
|
0
|
|
|
|
if ($inst_file && CPAN::Version->vlt($self->inst_version,$self->cpan_version)) { |
79
|
0
|
|
|
|
|
|
undef $inst_file; |
80
|
|
|
|
|
|
|
} |
81
|
0
|
0
|
|
|
|
|
unless ($inst_file) { |
82
|
|
|
|
|
|
|
# Try to get at it in the cpan directory |
83
|
0
|
0
|
|
|
|
|
$self->debug("no inst_file") if $CPAN::DEBUG; |
84
|
0
|
|
|
|
|
|
my $cpan_file; |
85
|
0
|
0
|
|
|
|
|
$CPAN::Frontend->mydie("I don't know a bundle with ID $id\n") unless |
86
|
|
|
|
|
|
|
$cpan_file = $self->cpan_file; |
87
|
0
|
0
|
|
|
|
|
if ($cpan_file eq "N/A") { |
88
|
0
|
|
|
|
|
|
$CPAN::Frontend->mydie("Bundle $id not found on disk and not on CPAN. |
89
|
|
|
|
|
|
|
Maybe stale symlink? Maybe removed during session? Giving up.\n"); |
90
|
|
|
|
|
|
|
} |
91
|
0
|
|
|
|
|
|
my $dist = $CPAN::META->instance('CPAN::Distribution', |
92
|
|
|
|
|
|
|
$self->cpan_file); |
93
|
0
|
0
|
|
|
|
|
$self->debug("before get id[$dist->{ID}]") if $CPAN::DEBUG; |
94
|
0
|
|
|
|
|
|
$dist->get; |
95
|
0
|
0
|
|
|
|
|
$self->debug("after get id[$dist->{ID}]") if $CPAN::DEBUG; |
96
|
0
|
|
|
|
|
|
my($todir) = $CPAN::Config->{'cpan_home'}; |
97
|
0
|
|
|
|
|
|
my(@me,$from,$to,$me); |
98
|
0
|
|
|
|
|
|
@me = split /::/, $self->id; |
99
|
0
|
|
|
|
|
|
$me[-1] .= ".pm"; |
100
|
0
|
|
|
|
|
|
$me = File::Spec->catfile(@me); |
101
|
0
|
|
|
|
|
|
$from = $self->find_bundle_file($dist->{build_dir},join('/',@me)); |
102
|
0
|
|
|
|
|
|
$to = File::Spec->catfile($todir,$me); |
103
|
0
|
|
|
|
|
|
File::Path::mkpath(File::Basename::dirname($to)); |
104
|
0
|
0
|
|
|
|
|
File::Copy::copy($from, $to) |
105
|
|
|
|
|
|
|
or Carp::confess("Couldn't copy $from to $to: $!"); |
106
|
0
|
|
|
|
|
|
$inst_file = $to; |
107
|
|
|
|
|
|
|
} |
108
|
0
|
|
|
|
|
|
my @result; |
109
|
0
|
|
|
|
|
|
my $fh = FileHandle->new; |
110
|
0
|
|
|
|
|
|
local $/ = "\n"; |
111
|
0
|
0
|
|
|
|
|
open($fh,$inst_file) or die "Could not open '$inst_file': $!"; |
112
|
0
|
|
|
|
|
|
my $in_cont = 0; |
113
|
0
|
0
|
|
|
|
|
$self->debug("inst_file[$inst_file]") if $CPAN::DEBUG; |
114
|
0
|
|
|
|
|
|
while (<$fh>) { |
115
|
0
|
0
|
|
|
|
|
$in_cont = m/^=(?!head1\s+(?i-xsm:CONTENTS))/ ? 0 : |
|
|
0
|
|
|
|
|
|
116
|
|
|
|
|
|
|
m/^=head1\s+(?i-xsm:CONTENTS)/ ? 1 : $in_cont; |
117
|
0
|
0
|
|
|
|
|
next unless $in_cont; |
118
|
0
|
0
|
|
|
|
|
next if /^=/; |
119
|
0
|
|
|
|
|
|
s/\#.*//; |
120
|
0
|
0
|
|
|
|
|
next if /^\s+$/; |
121
|
0
|
|
|
|
|
|
chomp; |
122
|
0
|
|
|
|
|
|
push @result, (split " ", $_, 2)[0]; |
123
|
|
|
|
|
|
|
} |
124
|
0
|
|
|
|
|
|
close $fh; |
125
|
0
|
|
|
|
|
|
delete $self->{STATUS}; |
126
|
0
|
|
|
|
|
|
$self->{CONTAINS} = \@result; |
127
|
0
|
0
|
|
|
|
|
$self->debug("CONTAINS[@result]") if $CPAN::DEBUG; |
128
|
0
|
0
|
|
|
|
|
unless (@result) { |
129
|
0
|
|
|
|
|
|
$CPAN::Frontend->mywarn(qq{ |
130
|
|
|
|
|
|
|
The bundle file "$inst_file" may be a broken |
131
|
|
|
|
|
|
|
bundlefile. It seems not to contain any bundle definition. |
132
|
|
|
|
|
|
|
Please check the file and if it is bogus, please delete it. |
133
|
|
|
|
|
|
|
Sorry for the inconvenience. |
134
|
|
|
|
|
|
|
}); |
135
|
|
|
|
|
|
|
} |
136
|
0
|
|
|
|
|
|
@result; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::find_bundle_file |
140
|
|
|
|
|
|
|
# $where is in local format, $what is in unix format |
141
|
|
|
|
|
|
|
sub find_bundle_file { |
142
|
0
|
|
|
0
|
0
|
|
my($self,$where,$what) = @_; |
143
|
0
|
0
|
|
|
|
|
$self->debug("where[$where]what[$what]") if $CPAN::DEBUG; |
144
|
|
|
|
|
|
|
### The following two lines let CPAN.pm become Bundle/CPAN.pm :-( |
145
|
|
|
|
|
|
|
### my $bu = File::Spec->catfile($where,$what); |
146
|
|
|
|
|
|
|
### return $bu if -f $bu; |
147
|
0
|
|
|
|
|
|
my $manifest = File::Spec->catfile($where,"MANIFEST"); |
148
|
0
|
0
|
|
|
|
|
unless (-f $manifest) { |
149
|
0
|
|
|
|
|
|
require ExtUtils::Manifest; |
150
|
0
|
|
|
|
|
|
my $cwd = CPAN::anycwd(); |
151
|
0
|
|
|
|
|
|
$self->safe_chdir($where); |
152
|
0
|
|
|
|
|
|
ExtUtils::Manifest::mkmanifest(); |
153
|
0
|
|
|
|
|
|
$self->safe_chdir($cwd); |
154
|
|
|
|
|
|
|
} |
155
|
0
|
0
|
|
|
|
|
my $fh = FileHandle->new($manifest) |
156
|
|
|
|
|
|
|
or Carp::croak("Couldn't open $manifest: $!"); |
157
|
0
|
|
|
|
|
|
local($/) = "\n"; |
158
|
0
|
|
|
|
|
|
my $bundle_filename = $what; |
159
|
0
|
|
|
|
|
|
$bundle_filename =~ s|Bundle.*/||; |
160
|
0
|
|
|
|
|
|
my $bundle_unixpath; |
161
|
0
|
|
|
|
|
|
while (<$fh>) { |
162
|
0
|
0
|
|
|
|
|
next if /^\s*\#/; |
163
|
0
|
|
|
|
|
|
my($file) = /(\S+)/; |
164
|
0
|
0
|
|
|
|
|
if ($file =~ m|\Q$what\E$|) { |
165
|
0
|
|
|
|
|
|
$bundle_unixpath = $file; |
166
|
|
|
|
|
|
|
# return File::Spec->catfile($where,$bundle_unixpath); # bad |
167
|
0
|
|
|
|
|
|
last; |
168
|
|
|
|
|
|
|
} |
169
|
|
|
|
|
|
|
# retry if she managed to have no Bundle directory |
170
|
0
|
0
|
|
|
|
|
$bundle_unixpath = $file if $file =~ m|\Q$bundle_filename\E$|; |
171
|
|
|
|
|
|
|
} |
172
|
0
|
0
|
|
|
|
|
return File::Spec->catfile($where, split /\//, $bundle_unixpath) |
173
|
|
|
|
|
|
|
if $bundle_unixpath; |
174
|
0
|
|
|
|
|
|
Carp::croak("Couldn't find a Bundle file in $where"); |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
# needs to work quite differently from Module::inst_file because of |
178
|
|
|
|
|
|
|
# cpan_home/Bundle/ directory and the possibility that we have |
179
|
|
|
|
|
|
|
# shadowing effect. As it makes no sense to take the first in @INC for |
180
|
|
|
|
|
|
|
# Bundles, we parse them all for $VERSION and take the newest. |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::inst_file ; |
183
|
|
|
|
|
|
|
sub inst_file { |
184
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
185
|
0
|
|
|
|
|
|
my($inst_file); |
186
|
|
|
|
|
|
|
my(@me); |
187
|
0
|
|
|
|
|
|
@me = split /::/, $self->id; |
188
|
0
|
|
|
|
|
|
$me[-1] .= ".pm"; |
189
|
0
|
|
|
|
|
|
my($incdir,$bestv); |
190
|
0
|
|
|
|
|
|
foreach $incdir ($CPAN::Config->{'cpan_home'},@INC) { |
191
|
0
|
|
|
|
|
|
my $parsefile = File::Spec->catfile($incdir, @me); |
192
|
0
|
0
|
|
|
|
|
CPAN->debug("parsefile[$parsefile]") if $CPAN::DEBUG; |
193
|
0
|
0
|
|
|
|
|
next unless -f $parsefile; |
194
|
0
|
|
|
|
|
|
my $have = eval { MM->parse_version($parsefile); }; |
|
0
|
|
|
|
|
|
|
195
|
0
|
0
|
|
|
|
|
if ($@) { |
196
|
0
|
|
|
|
|
|
$CPAN::Frontend->mywarn("Error while parsing version number in file '$parsefile'\n"); |
197
|
|
|
|
|
|
|
} |
198
|
0
|
0
|
0
|
|
|
|
if (!$bestv || CPAN::Version->vgt($have,$bestv)) { |
199
|
0
|
|
|
|
|
|
$self->{INST_FILE} = $parsefile; |
200
|
0
|
|
|
|
|
|
$self->{INST_VERSION} = $bestv = $have; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
} |
203
|
0
|
|
|
|
|
|
$self->{INST_FILE}; |
204
|
|
|
|
|
|
|
} |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::inst_version ; |
207
|
|
|
|
|
|
|
sub inst_version { |
208
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
209
|
0
|
|
|
|
|
|
$self->inst_file; # finds INST_VERSION as side effect |
210
|
0
|
|
|
|
|
|
$self->{INST_VERSION}; |
211
|
|
|
|
|
|
|
} |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::rematein ; |
214
|
|
|
|
|
|
|
sub rematein { |
215
|
0
|
|
|
0
|
0
|
|
my($self,$meth) = @_; |
216
|
0
|
0
|
|
|
|
|
$self->debug("self[$self] meth[$meth]") if $CPAN::DEBUG; |
217
|
0
|
|
|
|
|
|
my($id) = $self->id; |
218
|
0
|
0
|
0
|
|
|
|
Carp::croak( "Can't $meth $id, don't have an associated bundle file. :-(\n" ) |
219
|
|
|
|
|
|
|
unless $self->inst_file || $self->cpan_file; |
220
|
0
|
|
|
|
|
|
my($s,%fail); |
221
|
0
|
|
|
|
|
|
for $s ($self->contains) { |
222
|
0
|
0
|
|
|
|
|
my($type) = $s =~ m|/| ? 'CPAN::Distribution' : |
|
|
0
|
|
|
|
|
|
223
|
|
|
|
|
|
|
$s =~ m|^Bundle::| ? 'CPAN::Bundle' : 'CPAN::Module'; |
224
|
0
|
0
|
|
|
|
|
if ($type eq 'CPAN::Distribution') { |
225
|
0
|
|
|
|
|
|
$CPAN::Frontend->mywarn(qq{ |
226
|
|
|
|
|
|
|
The Bundle }.$self->id.qq{ contains |
227
|
|
|
|
|
|
|
explicitly a file '$s'. |
228
|
|
|
|
|
|
|
Going to $meth that. |
229
|
|
|
|
|
|
|
}); |
230
|
0
|
|
|
|
|
|
$CPAN::Frontend->mysleep(5); |
231
|
|
|
|
|
|
|
} |
232
|
|
|
|
|
|
|
# possibly noisy action: |
233
|
0
|
0
|
|
|
|
|
$self->debug("type[$type] s[$s]") if $CPAN::DEBUG; |
234
|
0
|
|
|
|
|
|
my $obj = $CPAN::META->instance($type,$s); |
235
|
0
|
|
|
|
|
|
$obj->{reqtype} = $self->{reqtype}; |
236
|
|
|
|
|
|
|
# $obj->$meth(); |
237
|
|
|
|
|
|
|
# XXX should optional be based on whether bundle was optional? -- xdg, 2012-04-01 |
238
|
|
|
|
|
|
|
# A: Sure, what could demand otherwise? --andk, 2013-11-25 |
239
|
0
|
|
|
|
|
|
CPAN::Queue->queue_item(qmod => $obj->id, reqtype => $self->{reqtype}, optional => !$self->{mandatory}); |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
} |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
# If a bundle contains another that contains an xs_file we have here, |
244
|
|
|
|
|
|
|
# we just don't bother I suppose |
245
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::xs_file |
246
|
|
|
|
|
|
|
sub xs_file { |
247
|
0
|
|
|
0
|
0
|
|
return 0; |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::force ; |
251
|
0
|
|
|
0
|
0
|
|
sub fforce { shift->rematein('fforce',@_); } |
252
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::force ; |
253
|
0
|
|
|
0
|
0
|
|
sub force { shift->rematein('force',@_); } |
254
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::notest ; |
255
|
0
|
|
|
0
|
0
|
|
sub notest { shift->rematein('notest',@_); } |
256
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::get ; |
257
|
0
|
|
|
0
|
0
|
|
sub get { shift->rematein('get',@_); } |
258
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::make ; |
259
|
0
|
|
|
0
|
0
|
|
sub make { shift->rematein('make',@_); } |
260
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::test ; |
261
|
|
|
|
|
|
|
sub test { |
262
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
263
|
|
|
|
|
|
|
# $self->{badtestcnt} ||= 0; |
264
|
0
|
|
|
|
|
|
$self->rematein('test',@_); |
265
|
|
|
|
|
|
|
} |
266
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::install ; |
267
|
|
|
|
|
|
|
sub install { |
268
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
269
|
0
|
|
|
|
|
|
$self->rematein('install',@_); |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::clean ; |
272
|
0
|
|
|
0
|
0
|
|
sub clean { shift->rematein('clean',@_); } |
273
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::uptodate ; |
275
|
|
|
|
|
|
|
sub uptodate { |
276
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
277
|
0
|
0
|
|
|
|
|
return 0 unless $self->SUPER::uptodate; # we must have the current Bundle def |
278
|
0
|
|
|
|
|
|
my $c; |
279
|
0
|
|
|
|
|
|
foreach $c ($self->contains) { |
280
|
0
|
|
|
|
|
|
my $obj = CPAN::Shell->expandany($c); |
281
|
0
|
0
|
|
|
|
|
return 0 unless $obj->uptodate; |
282
|
|
|
|
|
|
|
} |
283
|
0
|
|
|
|
|
|
return 1; |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
#-> sub CPAN::Bundle::readme ; |
287
|
|
|
|
|
|
|
sub readme { |
288
|
0
|
|
|
0
|
0
|
|
my($self) = @_; |
289
|
0
|
0
|
|
|
|
|
my($file) = $self->cpan_file or $CPAN::Frontend->myprint(qq{ |
290
|
|
|
|
|
|
|
No File found for bundle } . $self->id . qq{\n}), return; |
291
|
0
|
0
|
|
|
|
|
$self->debug("self[$self] file[$file]") if $CPAN::DEBUG; |
292
|
0
|
|
|
|
|
|
$CPAN::META->instance('CPAN::Distribution',$file)->readme; |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
1; |