line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#line 1 |
2
|
|
|
|
|
|
|
package Module::AutoInstall; |
3
|
1
|
|
|
1
|
|
6
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
67
|
|
4
|
1
|
|
|
1
|
|
6
|
use strict; |
|
1
|
|
|
|
|
17
|
|
|
1
|
|
|
|
|
19
|
|
5
|
1
|
|
|
1
|
|
6
|
use Cwd (); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
6
|
|
|
|
|
|
|
use ExtUtils::MakeMaker (); |
7
|
1
|
|
|
1
|
|
8
|
|
|
1
|
|
|
|
|
5
|
|
|
1
|
|
|
|
|
97
|
|
8
|
|
|
|
|
|
|
use vars qw{$VERSION}; |
9
|
1
|
|
|
1
|
|
1944
|
BEGIN { |
10
|
|
|
|
|
|
|
$VERSION = '1.03'; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# special map on pre-defined feature sets |
14
|
|
|
|
|
|
|
my %FeatureMap = ( |
15
|
|
|
|
|
|
|
'' => 'Core Features', # XXX: deprecated |
16
|
|
|
|
|
|
|
'-core' => 'Core Features', |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
# various lexical flags |
20
|
|
|
|
|
|
|
my ( @Missing, @Existing, %DisabledTests, $UnderCPAN, $HasCPANPLUS ); |
21
|
|
|
|
|
|
|
my ( $Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly ); |
22
|
|
|
|
|
|
|
my ( $PostambleActions, $PostambleUsed ); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# See if it's a testing or non-interactive session |
25
|
|
|
|
|
|
|
_accept_default( $ENV{AUTOMATED_TESTING} or ! -t STDIN ); |
26
|
|
|
|
|
|
|
_init(); |
27
|
|
|
|
|
|
|
|
28
|
1
|
|
|
1
|
|
3
|
sub _accept_default { |
29
|
|
|
|
|
|
|
$AcceptDefault = shift; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
0
|
0
|
0
|
sub missing_modules { |
33
|
|
|
|
|
|
|
return @Missing; |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
0
|
sub do_install { |
37
|
|
|
|
|
|
|
__PACKAGE__->install( |
38
|
|
|
|
|
|
|
[ |
39
|
0
|
0
|
|
0
|
0
|
0
|
$Config |
|
0
|
0
|
|
|
|
0
|
|
40
|
|
|
|
|
|
|
? ( UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} ) |
41
|
|
|
|
|
|
|
: () |
42
|
|
|
|
|
|
|
], |
43
|
|
|
|
|
|
|
@Missing, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# initialize various flags, and/or perform install |
48
|
1
|
|
50
|
1
|
|
13
|
sub _init { |
49
|
|
|
|
|
|
|
foreach my $arg ( |
50
|
|
|
|
|
|
|
@ARGV, |
51
|
|
|
|
|
|
|
split( |
52
|
|
|
|
|
|
|
/[\s\t]+/, |
53
|
|
|
|
|
|
|
$ENV{PERL_AUTOINSTALL} || $ENV{PERL_EXTUTILS_AUTOINSTALL} || '' |
54
|
|
|
|
|
|
|
) |
55
|
|
|
|
|
|
|
) |
56
|
2
|
100
|
|
|
|
19
|
{ |
|
|
50
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
57
|
1
|
|
|
|
|
5
|
if ( $arg =~ /^--config=(.*)$/ ) { |
58
|
|
|
|
|
|
|
$Config = [ split( ',', $1 ) ]; |
59
|
|
|
|
|
|
|
} |
60
|
1
|
|
|
|
|
12
|
elsif ( $arg =~ /^--installdeps=(.*)$/ ) { |
61
|
1
|
|
|
|
|
0
|
__PACKAGE__->install( $Config, @Missing = split( /,/, $1 ) ); |
62
|
|
|
|
|
|
|
exit 0; |
63
|
|
|
|
|
|
|
} |
64
|
0
|
|
|
|
|
0
|
elsif ( $arg =~ /^--default(?:deps)?$/ ) { |
65
|
|
|
|
|
|
|
$AcceptDefault = 1; |
66
|
|
|
|
|
|
|
} |
67
|
0
|
|
|
|
|
0
|
elsif ( $arg =~ /^--check(?:deps)?$/ ) { |
68
|
|
|
|
|
|
|
$CheckOnly = 1; |
69
|
|
|
|
|
|
|
} |
70
|
0
|
|
|
|
|
0
|
elsif ( $arg =~ /^--skip(?:deps)?$/ ) { |
71
|
|
|
|
|
|
|
$SkipInstall = 1; |
72
|
|
|
|
|
|
|
} |
73
|
0
|
|
|
|
|
0
|
elsif ( $arg =~ /^--test(?:only)?$/ ) { |
74
|
|
|
|
|
|
|
$TestOnly = 1; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
} |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
# overrides MakeMaker's prompt() to automatically accept the default choice |
80
|
0
|
0
|
|
0
|
|
0
|
sub _prompt { |
81
|
|
|
|
|
|
|
goto &ExtUtils::MakeMaker::prompt unless $AcceptDefault; |
82
|
0
|
|
|
|
|
0
|
|
83
|
0
|
|
|
|
|
0
|
my ( $prompt, $default ) = @_; |
84
|
|
|
|
|
|
|
my $y = ( $default =~ /^[Yy]/ ); |
85
|
0
|
0
|
|
|
|
0
|
|
|
|
0
|
|
|
|
|
|
86
|
0
|
|
|
|
|
0
|
print $prompt, ' [', ( $y ? 'Y' : 'y' ), '/', ( $y ? 'n' : 'N' ), '] '; |
87
|
0
|
|
|
|
|
0
|
print "$default\n"; |
88
|
|
|
|
|
|
|
return $default; |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# the workhorse |
92
|
0
|
|
|
0
|
|
0
|
sub import { |
93
|
0
|
0
|
|
|
|
0
|
my $class = shift; |
94
|
0
|
|
|
|
|
0
|
my @args = @_ or return; |
95
|
|
|
|
|
|
|
my $core_all; |
96
|
0
|
|
|
|
|
0
|
|
97
|
0
|
|
|
|
|
0
|
print "*** $class version " . $class->VERSION . "\n"; |
98
|
|
|
|
|
|
|
print "*** Checking for Perl dependencies...\n"; |
99
|
0
|
|
|
|
|
0
|
|
100
|
|
|
|
|
|
|
my $cwd = Cwd::cwd(); |
101
|
0
|
|
|
|
|
0
|
|
102
|
|
|
|
|
|
|
$Config = []; |
103
|
0
|
|
|
|
|
0
|
|
104
|
|
|
|
|
|
|
my $maxlen = length( |
105
|
0
|
|
|
|
|
0
|
( |
106
|
0
|
|
|
|
|
0
|
sort { length($b) <=> length($a) } |
107
|
|
|
|
|
|
|
grep { /^[^\-]/ } |
108
|
0
|
|
|
|
|
0
|
map { |
109
|
0
|
0
|
|
|
|
0
|
ref($_) |
|
|
0
|
|
|
|
|
|
110
|
|
|
|
|
|
|
? ( ( ref($_) eq 'HASH' ) ? keys(%$_) : @{$_} ) |
111
|
|
|
|
|
|
|
: '' |
112
|
0
|
0
|
|
|
|
0
|
} |
113
|
0
|
|
|
|
|
0
|
map { +{@args}->{$_} } |
|
0
|
|
|
|
|
0
|
|
114
|
|
|
|
|
|
|
grep { /^[^\-]/ or /^-core$/i } keys %{ +{@args} } |
115
|
|
|
|
|
|
|
)[0] |
116
|
|
|
|
|
|
|
); |
117
|
0
|
|
|
|
|
0
|
|
118
|
0
|
|
|
|
|
0
|
while ( my ( $feature, $modules ) = splice( @args, 0, 2 ) ) { |
119
|
0
|
|
|
|
|
0
|
my ( @required, @tests, @skiptests ); |
120
|
0
|
|
|
|
|
0
|
my $default = 1; |
121
|
|
|
|
|
|
|
my $conflict = 0; |
122
|
0
|
0
|
|
|
|
0
|
|
123
|
0
|
|
|
|
|
0
|
if ( $feature =~ m/^-(\w+)$/ ) { |
124
|
|
|
|
|
|
|
my $option = lc($1); |
125
|
|
|
|
|
|
|
|
126
|
0
|
0
|
0
|
|
|
0
|
# check for a newer version of myself |
127
|
|
|
|
|
|
|
_update_to( $modules, @_ ) and return if $option eq 'version'; |
128
|
|
|
|
|
|
|
|
129
|
0
|
0
|
|
|
|
0
|
# sets CPAN configuration options |
130
|
|
|
|
|
|
|
$Config = $modules if $option eq 'config'; |
131
|
|
|
|
|
|
|
|
132
|
0
|
0
|
0
|
|
|
0
|
# promote every features to core status |
133
|
|
|
|
|
|
|
$core_all = ( $modules =~ /^all$/i ) and next |
134
|
|
|
|
|
|
|
if $option eq 'core'; |
135
|
0
|
0
|
|
|
|
0
|
|
136
|
|
|
|
|
|
|
next unless $option eq 'core'; |
137
|
|
|
|
|
|
|
} |
138
|
0
|
|
0
|
|
|
0
|
|
139
|
|
|
|
|
|
|
print "[" . ( $FeatureMap{ lc($feature) } || $feature ) . "]\n"; |
140
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
141
|
|
|
|
|
|
|
$modules = [ %{$modules} ] if UNIVERSAL::isa( $modules, 'HASH' ); |
142
|
0
|
0
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
143
|
|
|
|
|
|
|
unshift @$modules, -default => &{ shift(@$modules) } |
144
|
|
|
|
|
|
|
if ( ref( $modules->[0] ) eq 'CODE' ); # XXX: bugward combatability |
145
|
0
|
|
|
|
|
0
|
|
146
|
0
|
0
|
|
|
|
0
|
while ( my ( $mod, $arg ) = splice( @$modules, 0, 2 ) ) { |
147
|
0
|
|
|
|
|
0
|
if ( $mod =~ m/^-(\w+)$/ ) { |
148
|
|
|
|
|
|
|
my $option = lc($1); |
149
|
0
|
0
|
|
|
|
0
|
|
150
|
0
|
0
|
|
|
|
0
|
$default = $arg if ( $option eq 'default' ); |
151
|
0
|
0
|
|
|
|
0
|
$conflict = $arg if ( $option eq 'conflict' ); |
|
0
|
|
|
|
|
0
|
|
152
|
0
|
0
|
|
|
|
0
|
@tests = @{$arg} if ( $option eq 'tests' ); |
|
0
|
|
|
|
|
0
|
|
153
|
|
|
|
|
|
|
@skiptests = @{$arg} if ( $option eq 'skiptests' ); |
154
|
0
|
|
|
|
|
0
|
|
155
|
|
|
|
|
|
|
next; |
156
|
|
|
|
|
|
|
} |
157
|
0
|
|
|
|
|
0
|
|
158
|
|
|
|
|
|
|
printf( "- %-${maxlen}s ...", $mod ); |
159
|
0
|
0
|
0
|
|
|
0
|
|
160
|
0
|
|
|
|
|
0
|
if ( $arg and $arg =~ /^\D/ ) { |
161
|
0
|
|
|
|
|
0
|
unshift @$modules, $arg; |
162
|
|
|
|
|
|
|
$arg = 0; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
|
165
|
0
|
0
|
0
|
|
|
0
|
# XXX: check for conflicts and uninstalls(!) them. |
166
|
|
|
|
|
|
|
if ( |
167
|
|
|
|
|
|
|
defined( my $cur = _version_check( _load($mod), $arg ||= 0 ) ) ) |
168
|
0
|
0
|
|
|
|
0
|
{ |
169
|
0
|
|
|
|
|
0
|
print "loaded. ($cur" . ( $arg ? " >= $arg" : '' ) . ")\n"; |
170
|
0
|
|
|
|
|
0
|
push @Existing, $mod => $arg; |
|
0
|
|
|
|
|
0
|
|
171
|
|
|
|
|
|
|
$DisabledTests{$_} = 1 for map { glob($_) } @skiptests; |
172
|
|
|
|
|
|
|
} |
173
|
0
|
0
|
|
|
|
0
|
else { |
174
|
0
|
|
|
|
|
0
|
print "missing." . ( $arg ? " (would need $arg)" : '' ) . "\n"; |
175
|
|
|
|
|
|
|
push @required, $mod => $arg; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
} |
178
|
0
|
0
|
|
|
|
0
|
|
179
|
|
|
|
|
|
|
next unless @required; |
180
|
0
|
|
0
|
|
|
0
|
|
181
|
|
|
|
|
|
|
my $mandatory = ( $feature eq '-core' or $core_all ); |
182
|
0
|
0
|
0
|
|
|
0
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
183
|
|
|
|
|
|
|
if ( |
184
|
|
|
|
|
|
|
!$SkipInstall |
185
|
|
|
|
|
|
|
and ( |
186
|
|
|
|
|
|
|
$CheckOnly |
187
|
|
|
|
|
|
|
or _prompt( |
188
|
|
|
|
|
|
|
qq{==> Auto-install the } |
189
|
|
|
|
|
|
|
. ( @required / 2 ) |
190
|
|
|
|
|
|
|
. ( $mandatory ? ' mandatory' : ' optional' ) |
191
|
|
|
|
|
|
|
. qq{ module(s) from CPAN?}, |
192
|
|
|
|
|
|
|
$default ? 'y' : 'n', |
193
|
|
|
|
|
|
|
) =~ /^[Yy]/ |
194
|
|
|
|
|
|
|
) |
195
|
|
|
|
|
|
|
) |
196
|
0
|
|
|
|
|
0
|
{ |
197
|
0
|
|
|
|
|
0
|
push( @Missing, @required ); |
|
0
|
|
|
|
|
0
|
|
198
|
|
|
|
|
|
|
$DisabledTests{$_} = 1 for map { glob($_) } @skiptests; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
elsif ( !$SkipInstall |
202
|
|
|
|
|
|
|
and $default |
203
|
|
|
|
|
|
|
and $mandatory |
204
|
|
|
|
|
|
|
and |
205
|
|
|
|
|
|
|
_prompt( qq{==> The module(s) are mandatory! Really skip?}, 'n', ) |
206
|
|
|
|
|
|
|
=~ /^[Nn]/ ) |
207
|
0
|
|
|
|
|
0
|
{ |
208
|
0
|
|
|
|
|
0
|
push( @Missing, @required ); |
|
0
|
|
|
|
|
0
|
|
209
|
|
|
|
|
|
|
$DisabledTests{$_} = 1 for map { glob($_) } @skiptests; |
210
|
|
|
|
|
|
|
} |
211
|
|
|
|
|
|
|
|
212
|
0
|
|
|
|
|
0
|
else { |
|
0
|
|
|
|
|
0
|
|
213
|
|
|
|
|
|
|
$DisabledTests{$_} = 1 for map { glob($_) } @tests; |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
} |
216
|
0
|
|
|
|
|
0
|
|
217
|
|
|
|
|
|
|
$UnderCPAN = _check_lock(); # check for $UnderCPAN |
218
|
0
|
0
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
219
|
0
|
|
|
|
|
0
|
if ( @Missing and not( $CheckOnly or $UnderCPAN ) ) { |
220
|
0
|
|
|
|
|
0
|
require Config; |
221
|
|
|
|
|
|
|
print |
222
|
|
|
|
|
|
|
"*** Dependencies will be installed the next time you type '$Config::Config{make}'.\n"; |
223
|
|
|
|
|
|
|
|
224
|
0
|
0
|
|
|
|
0
|
# make an educated guess of whether we'll need root permission. |
225
|
|
|
|
|
|
|
print " (You may need to do that as the 'root' user.)\n" |
226
|
|
|
|
|
|
|
if eval '$>'; |
227
|
0
|
|
|
|
|
0
|
} |
228
|
|
|
|
|
|
|
print "*** $class configuration finished.\n"; |
229
|
0
|
|
|
|
|
0
|
|
230
|
|
|
|
|
|
|
chdir $cwd; |
231
|
|
|
|
|
|
|
|
232
|
1
|
|
|
1
|
|
12
|
# import to main:: |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
3898
|
|
233
|
0
|
0
|
|
|
|
0
|
no strict 'refs'; |
|
0
|
|
|
|
|
0
|
|
234
|
|
|
|
|
|
|
*{'main::WriteMakefile'} = \&Write if caller(0) eq 'main'; |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
# Check to see if we are currently running under CPAN.pm and/or CPANPLUS; |
238
|
|
|
|
|
|
|
# if we are, then we simply let it taking care of our dependencies |
239
|
0
|
0
|
|
0
|
|
0
|
sub _check_lock { |
240
|
|
|
|
|
|
|
return unless @Missing; |
241
|
0
|
0
|
|
|
|
0
|
|
242
|
0
|
|
|
|
|
0
|
if ($ENV{PERL5_CPANPLUS_IS_RUNNING}) { |
243
|
|
|
|
|
|
|
print <<'END_MESSAGE'; |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
*** Since we're running under CPANPLUS, I'll just let it take care |
246
|
|
|
|
|
|
|
of the dependency's installation later. |
247
|
0
|
|
|
|
|
0
|
END_MESSAGE |
248
|
|
|
|
|
|
|
return 1; |
249
|
|
|
|
|
|
|
} |
250
|
0
|
|
|
|
|
0
|
|
251
|
|
|
|
|
|
|
_load_cpan(); |
252
|
|
|
|
|
|
|
|
253
|
0
|
|
|
|
|
0
|
# Find the CPAN lock-file |
254
|
0
|
0
|
|
|
|
0
|
my $lock = MM->catfile( $CPAN::Config->{cpan_home}, ".lock" ); |
255
|
|
|
|
|
|
|
return unless -f $lock; |
256
|
|
|
|
|
|
|
|
257
|
0
|
|
|
|
|
0
|
# Check the lock |
258
|
0
|
0
|
|
|
|
0
|
local *LOCK; |
259
|
|
|
|
|
|
|
return unless open(LOCK, $lock); |
260
|
0
|
0
|
0
|
|
|
0
|
|
|
|
0
|
0
|
|
|
|
|
261
|
|
|
|
|
|
|
if ( |
262
|
|
|
|
|
|
|
( $^O eq 'MSWin32' ? _under_cpan() : == getppid() ) |
263
|
|
|
|
|
|
|
and ( $CPAN::Config->{prerequisites_policy} || '' ) ne 'ignore' |
264
|
0
|
|
|
|
|
0
|
) { |
265
|
|
|
|
|
|
|
print <<'END_MESSAGE'; |
266
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
*** Since we're running under CPAN, I'll just let it take care |
268
|
|
|
|
|
|
|
of the dependency's installation later. |
269
|
0
|
|
|
|
|
0
|
END_MESSAGE |
270
|
|
|
|
|
|
|
return 1; |
271
|
|
|
|
|
|
|
} |
272
|
0
|
|
|
|
|
0
|
|
273
|
0
|
|
|
|
|
0
|
close LOCK; |
274
|
|
|
|
|
|
|
return; |
275
|
|
|
|
|
|
|
} |
276
|
|
|
|
|
|
|
|
277
|
1
|
|
|
1
|
0
|
3
|
sub install { |
278
|
|
|
|
|
|
|
my $class = shift; |
279
|
1
|
|
|
|
|
1
|
|
280
|
1
|
0
|
|
|
|
2
|
my $i; # used below to strip leading '-' from config keys |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
1
|
|
|
|
|
2
|
|
281
|
|
|
|
|
|
|
my @config = ( map { s/^-// if ++$i; $_ } @{ +shift } ); |
282
|
1
|
|
|
|
|
3
|
|
283
|
1
|
|
|
|
|
7
|
my ( @modules, @installed ); |
284
|
|
|
|
|
|
|
while ( my ( $pkg, $ver ) = splice( @_, 0, 2 ) ) { |
285
|
|
|
|
|
|
|
|
286
|
4
|
50
|
|
|
|
12
|
# grep out those already installed |
287
|
4
|
|
|
|
|
39
|
if ( defined( _version_check( _load($pkg), $ver ) ) ) { |
288
|
|
|
|
|
|
|
push @installed, $pkg; |
289
|
|
|
|
|
|
|
} |
290
|
0
|
|
|
|
|
0
|
else { |
291
|
|
|
|
|
|
|
push @modules, $pkg, $ver; |
292
|
|
|
|
|
|
|
} |
293
|
|
|
|
|
|
|
} |
294
|
1
|
50
|
|
|
|
7
|
|
295
|
0
|
0
|
|
|
|
0
|
return @installed unless @modules; # nothing to do |
296
|
|
|
|
|
|
|
return @installed if _check_lock(); # defer to the CPAN shell |
297
|
0
|
|
|
|
|
0
|
|
298
|
|
|
|
|
|
|
print "*** Installing dependencies...\n"; |
299
|
0
|
0
|
|
|
|
0
|
|
300
|
|
|
|
|
|
|
return unless _connected_to('cpan.org'); |
301
|
0
|
|
|
|
|
0
|
|
302
|
0
|
|
|
|
|
0
|
my %args = @config; |
303
|
0
|
|
|
|
|
0
|
my %failed; |
304
|
0
|
0
|
0
|
|
|
0
|
local *FAILED; |
305
|
0
|
|
|
|
|
0
|
if ( $args{do_once} and open( FAILED, '.#autoinstall.failed' ) ) { |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
306
|
0
|
|
|
|
|
0
|
while () { chomp; $failed{$_}++ } |
307
|
|
|
|
|
|
|
close FAILED; |
308
|
0
|
|
|
|
|
0
|
|
309
|
0
|
|
|
|
|
0
|
my @newmod; |
310
|
0
|
0
|
|
|
|
0
|
while ( my ( $k, $v ) = splice( @modules, 0, 2 ) ) { |
311
|
|
|
|
|
|
|
push @newmod, ( $k => $v ) unless $failed{$k}; |
312
|
0
|
|
|
|
|
0
|
} |
313
|
|
|
|
|
|
|
@modules = @newmod; |
314
|
|
|
|
|
|
|
} |
315
|
0
|
0
|
|
|
|
0
|
|
316
|
0
|
|
|
|
|
0
|
if ( _has_cpanplus() ) { |
317
|
|
|
|
|
|
|
_install_cpanplus( \@modules, \@config ); |
318
|
0
|
|
|
|
|
0
|
} else { |
319
|
|
|
|
|
|
|
_install_cpan( \@modules, \@config ); |
320
|
|
|
|
|
|
|
} |
321
|
0
|
|
|
|
|
0
|
|
322
|
|
|
|
|
|
|
print "*** $class installation finished.\n"; |
323
|
|
|
|
|
|
|
|
324
|
0
|
|
|
|
|
0
|
# see if we have successfully installed them |
325
|
0
|
0
|
0
|
|
|
0
|
while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) { |
|
|
0
|
|
|
|
|
|
326
|
0
|
|
|
|
|
0
|
if ( defined( _version_check( _load($pkg), $ver ) ) ) { |
327
|
|
|
|
|
|
|
push @installed, $pkg; |
328
|
|
|
|
|
|
|
} |
329
|
0
|
|
|
|
|
0
|
elsif ( $args{do_once} and open( FAILED, '>> .#autoinstall.failed' ) ) { |
330
|
|
|
|
|
|
|
print FAILED "$pkg\n"; |
331
|
|
|
|
|
|
|
} |
332
|
|
|
|
|
|
|
} |
333
|
0
|
0
|
|
|
|
0
|
|
334
|
|
|
|
|
|
|
close FAILED if $args{do_once}; |
335
|
0
|
|
|
|
|
0
|
|
336
|
|
|
|
|
|
|
return @installed; |
337
|
|
|
|
|
|
|
} |
338
|
|
|
|
|
|
|
|
339
|
0
|
|
|
0
|
|
0
|
sub _install_cpanplus { |
|
0
|
|
|
|
|
0
|
|
340
|
0
|
|
|
|
|
0
|
my @modules = @{ +shift }; |
|
0
|
|
|
|
|
0
|
|
341
|
0
|
|
|
|
|
0
|
my @config = _cpanplus_config( @{ +shift } ); |
342
|
|
|
|
|
|
|
my $installed = 0; |
343
|
0
|
|
|
|
|
0
|
|
344
|
0
|
|
|
|
|
0
|
require CPANPLUS::Backend; |
345
|
0
|
|
|
|
|
0
|
my $cp = CPANPLUS::Backend->new; |
346
|
|
|
|
|
|
|
my $conf = $cp->configure_object; |
347
|
0
|
0
|
0
|
|
|
0
|
|
348
|
|
|
|
|
|
|
return unless $conf->can('conf') # 0.05x+ with "sudo" support |
349
|
|
|
|
|
|
|
or _can_write($conf->_get_build('base')); # 0.04x |
350
|
|
|
|
|
|
|
|
351
|
0
|
|
0
|
|
|
0
|
# if we're root, set UNINST=1 to avoid trouble unless user asked for it. |
352
|
0
|
0
|
|
|
|
0
|
my $makeflags = $conf->get_conf('makeflags') || ''; |
353
|
|
|
|
|
|
|
if ( UNIVERSAL::isa( $makeflags, 'HASH' ) ) { |
354
|
0
|
0
|
|
|
|
0
|
# 0.03+ uses a hashref here |
355
|
|
|
|
|
|
|
$makeflags->{UNINST} = 1 unless exists $makeflags->{UNINST}; |
356
|
|
|
|
|
|
|
|
357
|
|
|
|
|
|
|
} else { |
358
|
0
|
0
|
0
|
|
|
0
|
# 0.02 and below uses a scalar |
359
|
|
|
|
|
|
|
$makeflags = join( ' ', split( ' ', $makeflags ), 'UNINST=1' ) |
360
|
|
|
|
|
|
|
if ( $makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' } ); |
361
|
|
|
|
|
|
|
|
362
|
0
|
|
|
|
|
0
|
} |
363
|
0
|
|
|
|
|
0
|
$conf->set_conf( makeflags => $makeflags ); |
364
|
|
|
|
|
|
|
$conf->set_conf( prereqs => 1 ); |
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
|
367
|
0
|
|
|
|
|
0
|
|
368
|
0
|
|
|
|
|
0
|
while ( my ( $key, $val ) = splice( @config, 0, 2 ) ) { |
369
|
|
|
|
|
|
|
$conf->set_conf( $key, $val ); |
370
|
|
|
|
|
|
|
} |
371
|
0
|
|
|
|
|
0
|
|
372
|
0
|
|
|
|
|
0
|
my $modtree = $cp->module_tree; |
373
|
0
|
|
|
|
|
0
|
while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) { |
374
|
|
|
|
|
|
|
print "*** Installing $pkg...\n"; |
375
|
0
|
0
|
0
|
|
|
0
|
|
376
|
|
|
|
|
|
|
MY::preinstall( $pkg, $ver ) or next if defined &MY::preinstall; |
377
|
0
|
|
|
|
|
0
|
|
378
|
0
|
|
|
|
|
0
|
my $success; |
379
|
|
|
|
|
|
|
my $obj = $modtree->{$pkg}; |
380
|
0
|
0
|
0
|
|
|
0
|
|
381
|
0
|
|
|
|
|
0
|
if ( $obj and defined( _version_check( $obj->{version}, $ver ) ) ) { |
382
|
0
|
|
|
|
|
0
|
my $pathname = $pkg; |
383
|
|
|
|
|
|
|
$pathname =~ s/::/\\W/; |
384
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
385
|
0
|
|
|
|
|
0
|
foreach my $inc ( grep { m/$pathname.pm/i } keys(%INC) ) { |
386
|
|
|
|
|
|
|
delete $INC{$inc}; |
387
|
|
|
|
|
|
|
} |
388
|
0
|
|
|
|
|
0
|
|
389
|
|
|
|
|
|
|
my $rv = $cp->install( modules => [ $obj->{module} ] ); |
390
|
0
|
0
|
0
|
|
|
0
|
|
|
|
|
0
|
|
|
|
|
391
|
0
|
|
|
|
|
0
|
if ( $rv and ( $rv->{ $obj->{module} } or $rv->{ok} ) ) { |
392
|
0
|
|
|
|
|
0
|
print "*** $pkg successfully installed.\n"; |
393
|
|
|
|
|
|
|
$success = 1; |
394
|
0
|
|
|
|
|
0
|
} else { |
395
|
0
|
|
|
|
|
0
|
print "*** $pkg installation cancelled.\n"; |
396
|
|
|
|
|
|
|
$success = 0; |
397
|
|
|
|
|
|
|
} |
398
|
0
|
|
|
|
|
0
|
|
399
|
|
|
|
|
|
|
$installed += $success; |
400
|
0
|
|
|
|
|
0
|
} else { |
401
|
|
|
|
|
|
|
print << "."; |
402
|
|
|
|
|
|
|
*** Could not find a version $ver or above for $pkg; skipping. |
403
|
|
|
|
|
|
|
. |
404
|
|
|
|
|
|
|
} |
405
|
0
|
0
|
|
|
|
0
|
|
406
|
|
|
|
|
|
|
MY::postinstall( $pkg, $ver, $success ) if defined &MY::postinstall; |
407
|
|
|
|
|
|
|
} |
408
|
0
|
|
|
|
|
0
|
|
409
|
|
|
|
|
|
|
return $installed; |
410
|
|
|
|
|
|
|
} |
411
|
|
|
|
|
|
|
|
412
|
0
|
|
|
0
|
|
0
|
sub _cpanplus_config { |
413
|
0
|
|
|
|
|
0
|
my @config = (); |
414
|
0
|
|
|
|
|
0
|
while ( @_ ) { |
415
|
0
|
0
|
|
|
|
0
|
my ($key, $value) = (shift(), shift()); |
416
|
0
|
0
|
|
|
|
0
|
if ( $key eq 'prerequisites_policy' ) { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
417
|
0
|
|
|
|
|
0
|
if ( $value eq 'follow' ) { |
418
|
|
|
|
|
|
|
$value = CPANPLUS::Internals::Constants::PREREQ_INSTALL(); |
419
|
0
|
|
|
|
|
0
|
} elsif ( $value eq 'ask' ) { |
420
|
|
|
|
|
|
|
$value = CPANPLUS::Internals::Constants::PREREQ_ASK(); |
421
|
0
|
|
|
|
|
0
|
} elsif ( $value eq 'ignore' ) { |
422
|
|
|
|
|
|
|
$value = CPANPLUS::Internals::Constants::PREREQ_IGNORE(); |
423
|
0
|
|
|
|
|
0
|
} else { |
424
|
|
|
|
|
|
|
die "*** Cannot convert option $key = '$value' to CPANPLUS version.\n"; |
425
|
|
|
|
|
|
|
} |
426
|
0
|
|
|
|
|
0
|
} else { |
427
|
|
|
|
|
|
|
die "*** Cannot convert option $key to CPANPLUS version.\n"; |
428
|
|
|
|
|
|
|
} |
429
|
0
|
|
|
|
|
0
|
} |
430
|
|
|
|
|
|
|
return @config; |
431
|
|
|
|
|
|
|
} |
432
|
|
|
|
|
|
|
|
433
|
0
|
|
|
0
|
|
0
|
sub _install_cpan { |
|
0
|
|
|
|
|
0
|
|
434
|
0
|
|
|
|
|
0
|
my @modules = @{ +shift }; |
|
0
|
|
|
|
|
0
|
|
435
|
0
|
|
|
|
|
0
|
my @config = @{ +shift }; |
436
|
0
|
|
|
|
|
0
|
my $installed = 0; |
437
|
|
|
|
|
|
|
my %args; |
438
|
0
|
|
|
|
|
0
|
|
439
|
0
|
|
|
|
|
0
|
_load_cpan(); |
440
|
|
|
|
|
|
|
require Config; |
441
|
0
|
0
|
|
|
|
0
|
|
442
|
|
|
|
|
|
|
if (CPAN->VERSION < 1.80) { |
443
|
0
|
0
|
0
|
|
|
0
|
# no "sudo" support, probe for writableness |
444
|
|
|
|
|
|
|
return unless _can_write( MM->catfile( $CPAN::Config->{cpan_home}, 'sources' ) ) |
445
|
|
|
|
|
|
|
and _can_write( $Config::Config{sitelib} ); |
446
|
|
|
|
|
|
|
} |
447
|
|
|
|
|
|
|
|
448
|
0
|
|
0
|
|
|
0
|
# if we're root, set UNINST=1 to avoid trouble unless user asked for it. |
449
|
0
|
0
|
0
|
|
|
0
|
my $makeflags = $CPAN::Config->{make_install_arg} || ''; |
450
|
|
|
|
|
|
|
$CPAN::Config->{make_install_arg} = |
451
|
|
|
|
|
|
|
join( ' ', split( ' ', $makeflags ), 'UNINST=1' ) |
452
|
|
|
|
|
|
|
if ( $makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' } ); |
453
|
|
|
|
|
|
|
|
454
|
0
|
|
|
|
|
0
|
# don't show start-up info |
455
|
|
|
|
|
|
|
$CPAN::Config->{inhibit_startup_message} = 1; |
456
|
|
|
|
|
|
|
|
457
|
0
|
|
|
|
|
0
|
# set additional options |
458
|
0
|
0
|
|
|
|
0
|
while ( my ( $opt, $arg ) = splice( @config, 0, 2 ) ) { |
459
|
|
|
|
|
|
|
( $args{$opt} = $arg, next ) |
460
|
0
|
|
|
|
|
0
|
if $opt =~ /^force$/; # pseudo-option |
461
|
|
|
|
|
|
|
$CPAN::Config->{$opt} = $arg; |
462
|
|
|
|
|
|
|
} |
463
|
0
|
|
|
|
|
0
|
|
464
|
|
|
|
|
|
|
local $CPAN::Config->{prerequisites_policy} = 'follow'; |
465
|
0
|
|
|
|
|
0
|
|
466
|
0
|
0
|
0
|
|
|
0
|
while ( my ( $pkg, $ver ) = splice( @modules, 0, 2 ) ) { |
467
|
|
|
|
|
|
|
MY::preinstall( $pkg, $ver ) or next if defined &MY::preinstall; |
468
|
0
|
|
|
|
|
0
|
|
469
|
|
|
|
|
|
|
print "*** Installing $pkg...\n"; |
470
|
0
|
|
|
|
|
0
|
|
471
|
0
|
|
|
|
|
0
|
my $obj = CPAN::Shell->expand( Module => $pkg ); |
472
|
|
|
|
|
|
|
my $success = 0; |
473
|
0
|
0
|
0
|
|
|
0
|
|
474
|
0
|
|
|
|
|
0
|
if ( $obj and defined( _version_check( $obj->cpan_version, $ver ) ) ) { |
475
|
0
|
|
|
|
|
0
|
my $pathname = $pkg; |
476
|
|
|
|
|
|
|
$pathname =~ s/::/\\W/; |
477
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
478
|
0
|
|
|
|
|
0
|
foreach my $inc ( grep { m/$pathname.pm/i } keys(%INC) ) { |
479
|
|
|
|
|
|
|
delete $INC{$inc}; |
480
|
|
|
|
|
|
|
} |
481
|
0
|
0
|
|
|
|
0
|
|
482
|
|
|
|
|
|
|
my $rv = $args{force} ? CPAN::Shell->force( install => $pkg ) |
483
|
0
|
|
0
|
|
|
0
|
: CPAN::Shell->install($pkg); |
484
|
0
|
0
|
|
|
|
0
|
$rv ||= eval { |
485
|
|
|
|
|
|
|
$CPAN::META->instance( 'CPAN::Distribution', $obj->cpan_file, ) |
486
|
|
|
|
|
|
|
->{install} |
487
|
|
|
|
|
|
|
if $CPAN::META; |
488
|
|
|
|
|
|
|
}; |
489
|
0
|
0
|
|
|
|
0
|
|
490
|
0
|
|
|
|
|
0
|
if ( $rv eq 'YES' ) { |
491
|
0
|
|
|
|
|
0
|
print "*** $pkg successfully installed.\n"; |
492
|
|
|
|
|
|
|
$success = 1; |
493
|
|
|
|
|
|
|
} |
494
|
0
|
|
|
|
|
0
|
else { |
495
|
0
|
|
|
|
|
0
|
print "*** $pkg installation failed.\n"; |
496
|
|
|
|
|
|
|
$success = 0; |
497
|
|
|
|
|
|
|
} |
498
|
0
|
|
|
|
|
0
|
|
499
|
|
|
|
|
|
|
$installed += $success; |
500
|
|
|
|
|
|
|
} |
501
|
0
|
|
|
|
|
0
|
else { |
502
|
|
|
|
|
|
|
print << "."; |
503
|
|
|
|
|
|
|
*** Could not find a version $ver or above for $pkg; skipping. |
504
|
|
|
|
|
|
|
. |
505
|
|
|
|
|
|
|
} |
506
|
0
|
0
|
|
|
|
0
|
|
507
|
|
|
|
|
|
|
MY::postinstall( $pkg, $ver, $success ) if defined &MY::postinstall; |
508
|
|
|
|
|
|
|
} |
509
|
0
|
|
|
|
|
0
|
|
510
|
|
|
|
|
|
|
return $installed; |
511
|
|
|
|
|
|
|
} |
512
|
|
|
|
|
|
|
|
513
|
|
|
|
|
|
|
sub _has_cpanplus { |
514
|
0
|
|
0
|
0
|
|
0
|
return ( |
515
|
|
|
|
|
|
|
$HasCPANPLUS = ( |
516
|
|
|
|
|
|
|
$INC{'CPANPLUS/Config.pm'} |
517
|
|
|
|
|
|
|
or _load('CPANPLUS::Shell::Default') |
518
|
|
|
|
|
|
|
) |
519
|
|
|
|
|
|
|
); |
520
|
|
|
|
|
|
|
} |
521
|
|
|
|
|
|
|
|
522
|
|
|
|
|
|
|
# make guesses on whether we're under the CPAN installation directory |
523
|
0
|
|
|
0
|
|
0
|
sub _under_cpan { |
524
|
0
|
|
|
|
|
0
|
require Cwd; |
525
|
|
|
|
|
|
|
require File::Spec; |
526
|
0
|
|
|
|
|
0
|
|
527
|
0
|
|
|
|
|
0
|
my $cwd = File::Spec->canonpath( Cwd::cwd() ); |
528
|
|
|
|
|
|
|
my $cpan = File::Spec->canonpath( $CPAN::Config->{cpan_home} ); |
529
|
0
|
|
|
|
|
0
|
|
530
|
|
|
|
|
|
|
return ( index( $cwd, $cpan ) > -1 ); |
531
|
|
|
|
|
|
|
} |
532
|
|
|
|
|
|
|
|
533
|
0
|
|
|
0
|
|
0
|
sub _update_to { |
534
|
0
|
|
|
|
|
0
|
my $class = __PACKAGE__; |
535
|
|
|
|
|
|
|
my $ver = shift; |
536
|
|
|
|
|
|
|
|
537
|
0
|
0
|
|
|
|
0
|
return |
538
|
|
|
|
|
|
|
if defined( _version_check( _load($class), $ver ) ); # no need to upgrade |
539
|
0
|
0
|
|
|
|
0
|
|
540
|
|
|
|
|
|
|
if ( |
541
|
|
|
|
|
|
|
_prompt( "==> A newer version of $class ($ver) is required. Install?", |
542
|
|
|
|
|
|
|
'y' ) =~ /^[Nn]/ |
543
|
|
|
|
|
|
|
) |
544
|
0
|
|
|
|
|
0
|
{ |
545
|
|
|
|
|
|
|
die "*** Please install $class $ver manually.\n"; |
546
|
|
|
|
|
|
|
} |
547
|
0
|
|
|
|
|
0
|
|
548
|
|
|
|
|
|
|
print << "."; |
549
|
|
|
|
|
|
|
*** Trying to fetch it from CPAN... |
550
|
|
|
|
|
|
|
. |
551
|
|
|
|
|
|
|
|
552
|
0
|
0
|
0
|
|
|
0
|
# install ourselves |
553
|
|
|
|
|
|
|
_load($class) and return $class->import(@_) |
554
|
|
|
|
|
|
|
if $class->install( [], $class, $ver ); |
555
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
556
|
|
|
|
|
|
|
print << '.'; exit 1; |
557
|
|
|
|
|
|
|
|
558
|
|
|
|
|
|
|
*** Cannot bootstrap myself. :-( Installation terminated. |
559
|
|
|
|
|
|
|
. |
560
|
|
|
|
|
|
|
} |
561
|
|
|
|
|
|
|
|
562
|
|
|
|
|
|
|
# check if we're connected to some host, using inet_aton |
563
|
0
|
|
|
0
|
|
0
|
sub _connected_to { |
564
|
|
|
|
|
|
|
my $site = shift; |
565
|
|
|
|
|
|
|
|
566
|
0
|
|
0
|
|
|
0
|
return ( |
567
|
|
|
|
|
|
|
( _load('Socket') and Socket::inet_aton($site) ) or _prompt( |
568
|
|
|
|
|
|
|
qq( |
569
|
|
|
|
|
|
|
*** Your host cannot resolve the domain name '$site', which |
570
|
|
|
|
|
|
|
probably means the Internet connections are unavailable. |
571
|
|
|
|
|
|
|
==> Should we try to install the required module(s) anyway?), 'n' |
572
|
|
|
|
|
|
|
) =~ /^[Yy]/ |
573
|
|
|
|
|
|
|
); |
574
|
|
|
|
|
|
|
} |
575
|
|
|
|
|
|
|
|
576
|
|
|
|
|
|
|
# check if a directory is writable; may create it on demand |
577
|
0
|
|
|
0
|
|
0
|
sub _can_write { |
578
|
0
|
0
|
|
|
|
0
|
my $path = shift; |
579
|
|
|
|
|
|
|
mkdir( $path, 0755 ) unless -e $path; |
580
|
0
|
0
|
|
|
|
0
|
|
581
|
|
|
|
|
|
|
return 1 if -w $path; |
582
|
0
|
|
|
|
|
0
|
|
583
|
|
|
|
|
|
|
print << "."; |
584
|
|
|
|
|
|
|
*** You are not allowed to write to the directory '$path'; |
585
|
|
|
|
|
|
|
the installation may fail due to insufficient permissions. |
586
|
|
|
|
|
|
|
. |
587
|
0
|
0
|
0
|
|
|
0
|
|
|
|
0
|
0
|
|
|
|
|
588
|
|
|
|
|
|
|
if ( |
589
|
|
|
|
|
|
|
eval '$>' and lc(`sudo -V`) =~ /version/ and _prompt( |
590
|
|
|
|
|
|
|
qq( |
591
|
|
|
|
|
|
|
==> Should we try to re-execute the autoinstall process with 'sudo'?), |
592
|
|
|
|
|
|
|
((-t STDIN) ? 'y' : 'n') |
593
|
|
|
|
|
|
|
) =~ /^[Yy]/ |
594
|
|
|
|
|
|
|
) |
595
|
|
|
|
|
|
|
{ |
596
|
|
|
|
|
|
|
|
597
|
0
|
|
|
|
|
0
|
# try to bootstrap ourselves from sudo |
598
|
|
|
|
|
|
|
print << "."; |
599
|
|
|
|
|
|
|
*** Trying to re-execute the autoinstall process with 'sudo'... |
600
|
0
|
|
|
|
|
0
|
. |
601
|
0
|
|
|
|
|
0
|
my $missing = join( ',', @Missing ); |
602
|
0
|
0
|
|
|
|
0
|
my $config = join( ',', |
|
0
|
0
|
|
|
|
0
|
|
603
|
|
|
|
|
|
|
UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} ) |
604
|
|
|
|
|
|
|
if $Config; |
605
|
|
|
|
|
|
|
|
606
|
0
|
0
|
|
|
|
0
|
return |
607
|
|
|
|
|
|
|
unless system( 'sudo', $^X, $0, "--config=$config", |
608
|
|
|
|
|
|
|
"--installdeps=$missing" ); |
609
|
0
|
|
|
|
|
0
|
|
610
|
|
|
|
|
|
|
print << "."; |
611
|
|
|
|
|
|
|
*** The 'sudo' command exited with error! Resuming... |
612
|
|
|
|
|
|
|
. |
613
|
|
|
|
|
|
|
} |
614
|
0
|
|
|
|
|
0
|
|
615
|
|
|
|
|
|
|
return _prompt( |
616
|
|
|
|
|
|
|
qq( |
617
|
|
|
|
|
|
|
==> Should we try to install the required module(s) anyway?), 'n' |
618
|
|
|
|
|
|
|
) =~ /^[Yy]/; |
619
|
|
|
|
|
|
|
} |
620
|
|
|
|
|
|
|
|
621
|
|
|
|
|
|
|
# load a module and return the version it reports |
622
|
4
|
|
|
4
|
|
7
|
sub _load { |
623
|
4
|
|
|
|
|
6
|
my $mod = pop; # class/instance doesn't matter |
624
|
|
|
|
|
|
|
my $file = $mod; |
625
|
4
|
|
|
|
|
15
|
|
626
|
4
|
|
|
|
|
10
|
$file =~ s|::|/|g; |
627
|
|
|
|
|
|
|
$file .= '.pm'; |
628
|
4
|
|
|
|
|
5
|
|
629
|
4
|
|
33
|
|
|
7
|
local $@; |
630
|
|
|
|
|
|
|
return eval { require $file; $mod->VERSION } || ( $@ ? undef: 0 ); |
631
|
|
|
|
|
|
|
} |
632
|
|
|
|
|
|
|
|
633
|
|
|
|
|
|
|
# Load CPAN.pm and it's configuration |
634
|
0
|
0
|
|
0
|
|
0
|
sub _load_cpan { |
635
|
0
|
|
|
|
|
0
|
return if $CPAN::VERSION; |
636
|
0
|
0
|
|
|
|
0
|
require CPAN; |
637
|
|
|
|
|
|
|
if ( $CPAN::HandleConfig::VERSION ) { |
638
|
0
|
|
|
|
|
0
|
# Newer versions of CPAN have a HandleConfig module |
639
|
|
|
|
|
|
|
CPAN::HandleConfig->load; |
640
|
|
|
|
|
|
|
} else { |
641
|
0
|
|
|
|
|
0
|
# Older versions had the load method in Config directly |
642
|
|
|
|
|
|
|
CPAN::Config->load; |
643
|
|
|
|
|
|
|
} |
644
|
|
|
|
|
|
|
} |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
# compare two versions, either use Sort::Versions or plain comparison |
647
|
4
|
|
|
4
|
|
13
|
sub _version_check { |
648
|
4
|
50
|
|
|
|
18
|
my ( $cur, $min ) = @_; |
649
|
|
|
|
|
|
|
return unless defined $cur; |
650
|
4
|
|
|
|
|
12
|
|
651
|
|
|
|
|
|
|
$cur =~ s/\s+$//; |
652
|
|
|
|
|
|
|
|
653
|
4
|
50
|
33
|
|
|
87
|
# check for version numbers that are not in decimal format |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
654
|
0
|
0
|
0
|
|
|
0
|
if ( ref($cur) or ref($min) or $cur =~ /v|\..*\./ or $min =~ /v|\..*\./ ) { |
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
655
|
|
|
|
|
|
|
if ( ( $version::VERSION or defined( _load('version') )) and |
656
|
|
|
|
|
|
|
version->can('new') |
657
|
|
|
|
|
|
|
) { |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
# use version.pm if it is installed. |
660
|
0
|
0
|
|
|
|
0
|
return ( |
661
|
|
|
|
|
|
|
( version->new($cur) >= version->new($min) ) ? $cur : undef ); |
662
|
|
|
|
|
|
|
} |
663
|
|
|
|
|
|
|
elsif ( $Sort::Versions::VERSION or defined( _load('Sort::Versions') ) ) |
664
|
|
|
|
|
|
|
{ |
665
|
|
|
|
|
|
|
|
666
|
0
|
0
|
|
|
|
0
|
# use Sort::Versions as the sorting algorithm for a.b.c versions |
667
|
|
|
|
|
|
|
return ( ( Sort::Versions::versioncmp( $cur, $min ) != -1 ) |
668
|
|
|
|
|
|
|
? $cur |
669
|
|
|
|
|
|
|
: undef ); |
670
|
|
|
|
|
|
|
} |
671
|
0
|
|
|
|
|
0
|
|
672
|
|
|
|
|
|
|
warn "Cannot reliably compare non-decimal formatted versions.\n" |
673
|
|
|
|
|
|
|
. "Please install version.pm or Sort::Versions.\n"; |
674
|
|
|
|
|
|
|
} |
675
|
|
|
|
|
|
|
|
676
|
4
|
|
|
|
|
16
|
# plain comparison |
677
|
4
|
50
|
|
|
|
39
|
local $^W = 0; # shuts off 'not numeric' bugs |
678
|
|
|
|
|
|
|
return ( $cur >= $min ? $cur : undef ); |
679
|
|
|
|
|
|
|
} |
680
|
|
|
|
|
|
|
|
681
|
0
|
|
|
0
|
|
|
# nothing; this usage is deprecated. |
682
|
|
|
|
|
|
|
sub main::PREREQ_PM { return {}; } |
683
|
|
|
|
|
|
|
|
684
|
0
|
|
|
0
|
|
|
sub _make_args { |
685
|
|
|
|
|
|
|
my %args = @_; |
686
|
0
|
0
|
0
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
687
|
|
|
|
|
|
|
$args{PREREQ_PM} = { %{ $args{PREREQ_PM} || {} }, @Existing, @Missing } |
688
|
|
|
|
|
|
|
if $UnderCPAN or $TestOnly; |
689
|
0
|
0
|
0
|
|
|
|
|
690
|
0
|
|
|
|
|
|
if ( $args{EXE_FILES} and -e 'MANIFEST' ) { |
691
|
0
|
|
|
|
|
|
require ExtUtils::Manifest; |
692
|
|
|
|
|
|
|
my $manifest = ExtUtils::Manifest::maniread('MANIFEST'); |
693
|
0
|
|
|
|
|
|
|
694
|
0
|
|
|
|
|
|
$args{EXE_FILES} = |
|
0
|
|
|
|
|
|
|
695
|
|
|
|
|
|
|
[ grep { exists $manifest->{$_} } @{ $args{EXE_FILES} } ]; |
696
|
|
|
|
|
|
|
} |
697
|
0
|
|
0
|
|
|
|
|
698
|
0
|
|
|
|
|
|
$args{test}{TESTS} ||= 't/*.t'; |
699
|
0
|
|
|
|
|
|
$args{test}{TESTS} = join( ' ', |
700
|
0
|
|
|
|
|
|
grep { !exists( $DisabledTests{$_} ) } |
701
|
|
|
|
|
|
|
map { glob($_) } split( /\s+/, $args{test}{TESTS} ) ); |
702
|
0
|
|
|
|
|
|
|
703
|
0
|
|
|
|
|
|
my $missing = join( ',', @Missing ); |
704
|
0
|
0
|
|
|
|
|
my $config = |
|
0
|
0
|
|
|
|
|
|
705
|
|
|
|
|
|
|
join( ',', UNIVERSAL::isa( $Config, 'HASH' ) ? %{$Config} : @{$Config} ) |
706
|
|
|
|
|
|
|
if $Config; |
707
|
0
|
0
|
|
|
|
|
|
708
|
|
|
|
|
|
|
$PostambleActions = ( |
709
|
|
|
|
|
|
|
$missing |
710
|
|
|
|
|
|
|
? "\$(PERL) $0 --config=$config --installdeps=$missing" |
711
|
|
|
|
|
|
|
: "\$(NOECHO) \$(NOOP)" |
712
|
|
|
|
|
|
|
); |
713
|
0
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
return %args; |
715
|
|
|
|
|
|
|
} |
716
|
|
|
|
|
|
|
|
717
|
|
|
|
|
|
|
# a wrapper to ExtUtils::MakeMaker::WriteMakefile |
718
|
0
|
|
|
0
|
0
|
|
sub Write { |
719
|
0
|
0
|
|
|
|
|
require Carp; |
720
|
|
|
|
|
|
|
Carp::croak "WriteMakefile: Need even number of args" if @_ % 2; |
721
|
0
|
0
|
|
|
|
|
|
722
|
0
|
|
|
|
|
|
if ($CheckOnly) { |
723
|
|
|
|
|
|
|
print << "."; |
724
|
|
|
|
|
|
|
*** Makefile not written in check-only mode. |
725
|
0
|
|
|
|
|
|
. |
726
|
|
|
|
|
|
|
return; |
727
|
|
|
|
|
|
|
} |
728
|
0
|
|
|
|
|
|
|
729
|
|
|
|
|
|
|
my %args = _make_args(@_); |
730
|
1
|
|
|
1
|
|
10
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
199
|
|
731
|
|
|
|
|
|
|
no strict 'refs'; |
732
|
0
|
|
|
|
|
|
|
733
|
0
|
0
|
|
|
|
|
$PostambleUsed = 0; |
734
|
0
|
|
|
|
|
|
local *MY::postamble = \&postamble unless defined &MY::postamble; |
735
|
|
|
|
|
|
|
ExtUtils::MakeMaker::WriteMakefile(%args); |
736
|
0
|
0
|
|
|
|
|
|
737
|
|
|
|
|
|
|
print << "." unless $PostambleUsed; |
738
|
|
|
|
|
|
|
*** WARNING: Makefile written with customized MY::postamble() without |
739
|
|
|
|
|
|
|
including contents from Module::AutoInstall::postamble() -- |
740
|
|
|
|
|
|
|
auto installation features disabled. Please contact the author. |
741
|
|
|
|
|
|
|
. |
742
|
0
|
|
|
|
|
|
|
743
|
|
|
|
|
|
|
return 1; |
744
|
|
|
|
|
|
|
} |
745
|
|
|
|
|
|
|
|
746
|
0
|
|
|
0
|
0
|
|
sub postamble { |
747
|
|
|
|
|
|
|
$PostambleUsed = 1; |
748
|
0
|
|
|
|
|
|
|
749
|
|
|
|
|
|
|
return << "."; |
750
|
|
|
|
|
|
|
|
751
|
|
|
|
|
|
|
config :: installdeps |
752
|
|
|
|
|
|
|
\t\$(NOECHO) \$(NOOP) |
753
|
|
|
|
|
|
|
|
754
|
|
|
|
|
|
|
checkdeps :: |
755
|
|
|
|
|
|
|
\t\$(PERL) $0 --checkdeps |
756
|
|
|
|
|
|
|
|
757
|
|
|
|
|
|
|
installdeps :: |
758
|
|
|
|
|
|
|
\t$PostambleActions |
759
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
. |
761
|
|
|
|
|
|
|
|
762
|
|
|
|
|
|
|
} |
763
|
|
|
|
|
|
|
|
764
|
|
|
|
|
|
|
1; |
765
|
|
|
|
|
|
|
|
766
|
|
|
|
|
|
|
__END__ |