~ubuntu-branches/ubuntu/precise/libmodule-signature-perl/precise-updates

« back to all changes in this revision

Viewing changes to inc/ExtUtils/AutoInstall.pm

  • Committer: Bazaar Package Importer
  • Author(s): Chip Salzenberg
  • Date: 2005-04-08 18:28:23 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050408182823-9f7rbs3n81zp48n1
Tags: 0.44-3
Re-upload with full source, as the 0.44-1 upload was borked so the
0.44-2 upload was refused.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#line 1 "inc/ExtUtils/AutoInstall.pm - /usr/local/lib/perl5/site_perl/5.8.0/ExtUtils/AutoInstall.pm"
2
 
# $File: //member/autrijus/ExtUtils-AutoInstall/AutoInstall.pm $ 
3
 
# $Revision: #46 $ $Change: 5867 $ $DateTime: 2003/05/15 18:26:55 $
4
 
 
 
1
#line 1 "inc/ExtUtils/AutoInstall.pm - /usr/local/lib/perl5/site_perl/5.8.5/ExtUtils/AutoInstall.pm"
5
2
package ExtUtils::AutoInstall;
6
 
$ExtUtils::AutoInstall::VERSION = '0.52';
 
3
$ExtUtils::AutoInstall::VERSION = '0.61';
7
4
 
8
5
use strict;
9
 
 
10
 
use Cwd;
 
6
use Cwd ();
11
7
use ExtUtils::MakeMaker ();
12
8
 
13
 
#line 264
 
9
#line 305
14
10
 
15
11
# special map on pre-defined feature sets
16
12
my %FeatureMap = (
17
 
    ''      => 'Core Features', # XXX: deprecated
 
13
    ''      => 'Core Features', # XXX: deprecated
18
14
    '-core' => 'Core Features',
19
15
);
20
16
 
23
19
my ($Config, $CheckOnly, $SkipInstall, $AcceptDefault, $TestOnly);
24
20
my ($PostambleActions, $PostambleUsed);
25
21
 
26
 
$AcceptDefault = 1 unless -t STDIN; # non-interactive session
 
22
_accept_default(!-t STDIN); # see if it's a non-interactive session
27
23
_init();
28
24
 
 
25
sub _accept_default {
 
26
    $AcceptDefault = shift;
 
27
}
 
28
 
29
29
sub missing_modules {
30
30
    return @Missing;
31
31
}
32
32
 
33
33
sub do_install {
34
34
    __PACKAGE__->install(
35
 
        [ UNIVERSAL::isa($Config, 'HASH') ? %{$Config} : @{$Config}],
36
 
        @Missing,
 
35
        [ UNIVERSAL::isa($Config, 'HASH') ? %{$Config} : @{$Config}],
 
36
        @Missing,
37
37
    );
38
38
}
39
39
 
40
40
# initialize various flags, and/or perform install
41
41
sub _init {
42
42
    foreach my $arg (@ARGV, split(/[\s\t]+/, $ENV{PERL_EXTUTILS_AUTOINSTALL} || '')) {
43
 
        if ($arg =~ /^--config=(.*)$/) {
44
 
            $Config = [ split(',', $1) ];
45
 
        }
46
 
        elsif ($arg =~ /^--installdeps=(.*)$/) {
47
 
            __PACKAGE__->install($Config, @Missing = split(/,/, $1));
48
 
            exit 0;
49
 
        }
50
 
        elsif ($arg =~ /^--default(?:deps)?$/) {
51
 
            $AcceptDefault = 1;
52
 
        }
53
 
        elsif ($arg =~ /^--check(?:deps)?$/) {
54
 
            $CheckOnly = 1;
55
 
        }
56
 
        elsif ($arg =~ /^--skip(?:deps)?$/) {
57
 
            $SkipInstall = 1;
58
 
        }
59
 
        elsif ($arg =~ /^--test(?:only)?$/) {
60
 
            $TestOnly = 1;
61
 
        }
 
43
        if ($arg =~ /^--config=(.*)$/) {
 
44
            $Config = [ split(',', $1) ];
 
45
        }
 
46
        elsif ($arg =~ /^--installdeps=(.*)$/) {
 
47
            __PACKAGE__->install($Config, @Missing = split(/,/, $1));
 
48
            exit 0;
 
49
        }
 
50
        elsif ($arg =~ /^--default(?:deps)?$/) {
 
51
            $AcceptDefault = 1;
 
52
        }
 
53
        elsif ($arg =~ /^--check(?:deps)?$/) {
 
54
            $CheckOnly = 1;
 
55
        }
 
56
        elsif ($arg =~ /^--skip(?:deps)?$/) {
 
57
            $SkipInstall = 1;
 
58
        }
 
59
        elsif ($arg =~ /^--test(?:only)?$/) {
 
60
            $TestOnly = 1;
 
61
        }
62
62
    }
63
63
}
64
64
 
88
88
    $Config  = [];
89
89
 
90
90
    my $maxlen = length((sort { length($b) <=> length($a) }
91
 
        grep { /^[^\-]/ }
 
91
        grep { /^[^\-]/ }
92
92
        map { ref($_) ? keys %{ref($_) eq 'HASH' ? $_ : +{@{$_}}} : '' }
93
 
        map { +{@args}->{$_} }
94
 
        grep { /^[^\-]/ or /^-core$/i } keys %{+{@args}})[0]);
 
93
        map { +{@args}->{$_} }
 
94
        grep { /^[^\-]/ or /^-core$/i } keys %{+{@args}})[0]);
95
95
 
96
96
    while (my ($feature, $modules) = splice(@args, 0, 2)) {
97
 
        my (@required, @tests, @skiptests);
98
 
        my $default  = 1;
99
 
        my $conflict = 0;
100
 
 
101
 
        if ($feature =~ m/^-(\w+)$/) {
102
 
            my $option = lc($1);
103
 
 
104
 
            # check for a newer version of myself
105
 
            _update_to($modules, @_) and return if $option eq 'version';
106
 
 
107
 
            # sets CPAN configuration options
108
 
            $Config = $modules                  if $option eq 'config';
109
 
 
110
 
            # promote every features to core status
111
 
            $core_all = ($modules =~ /^all$/i) and next
112
 
                if $option eq 'core';
113
 
 
114
 
            next unless $option eq 'core';
115
 
        }
116
 
 
117
 
        print "[".($FeatureMap{lc($feature)} || $feature)."]\n";
118
 
 
119
 
        $modules = [ %{$modules} ] if UNIVERSAL::isa($modules, 'HASH');
120
 
 
121
 
        unshift @$modules, -default => &{shift(@$modules)}
122
 
            if (ref($modules->[0]) eq 'CODE'); # XXX: bugward combatability
123
 
 
124
 
        while (my ($mod, $arg) = splice(@$modules, 0, 2)) {
125
 
            if ($mod =~ m/^-(\w+)$/) {
126
 
                my $option = lc($1);
127
 
 
128
 
                $default   = $arg    if ($option eq 'default');
129
 
                $conflict  = $arg    if ($option eq 'conflict');
130
 
                @tests     = @{$arg} if ($option eq 'tests');
131
 
                @skiptests = @{$arg} if ($option eq 'skiptests');
132
 
 
133
 
                next;
134
 
            }
135
 
 
136
 
            printf("- %-${maxlen}s ...", $mod);
137
 
 
138
 
            # XXX: check for conflicts and uninstalls(!) them.
139
 
            if (defined(my $cur = _version_check(_load($mod), $arg ||= 0))) {
140
 
                print "loaded. ($cur".($arg ? " >= $arg" : '').")\n";
141
 
                push @Existing, $mod => $arg;
142
 
                $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
143
 
            }
144
 
            else {
145
 
                print "failed! (need".($arg ? "s $arg" : 'ed').")\n";
146
 
                push @required, $mod => $arg;
147
 
            }
148
 
        }
149
 
 
150
 
        next unless @required;
151
 
 
152
 
        my $mandatory = (($feature eq '-core' or $core_all) and $default);
153
 
 
154
 
        if (!$SkipInstall and ($CheckOnly or _prompt(
155
 
            qq{==> Do you wish to install the }. (@required / 2).
156
 
            ($mandatory ? ' mandatory' : ' optional').
157
 
            qq{ module(s)?}, $default ? 'y' : 'n',
158
 
        ) =~ /^[Yy]/)) {
159
 
            push (@Missing, @required);
160
 
            $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
161
 
        }
162
 
 
163
 
        elsif (!$SkipInstall and $mandatory and _prompt(
164
 
            qq{==> The module(s) are mandatory! Really skip?}, 'n',
165
 
        ) =~ /^[Nn]/) {
166
 
            push (@Missing, @required);
167
 
            $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
168
 
        }
169
 
 
170
 
        else {
171
 
            $DisabledTests{$_} = 1 for map { glob($_) } @tests;
172
 
        }
 
97
        my (@required, @tests, @skiptests);
 
98
        my $default  = 1;
 
99
        my $conflict = 0;
 
100
 
 
101
        if ($feature =~ m/^-(\w+)$/) {
 
102
            my $option = lc($1);
 
103
 
 
104
            # check for a newer version of myself
 
105
            _update_to($modules, @_) and return if $option eq 'version';
 
106
 
 
107
            # sets CPAN configuration options
 
108
            $Config = $modules                  if $option eq 'config';
 
109
 
 
110
            # promote every features to core status
 
111
            $core_all = ($modules =~ /^all$/i) and next
 
112
                if $option eq 'core';
 
113
 
 
114
            next unless $option eq 'core';
 
115
        }
 
116
 
 
117
        print "[".($FeatureMap{lc($feature)} || $feature)."]\n";
 
118
 
 
119
        $modules = [ %{$modules} ] if UNIVERSAL::isa($modules, 'HASH');
 
120
 
 
121
        unshift @$modules, -default => &{shift(@$modules)}
 
122
            if (ref($modules->[0]) eq 'CODE'); # XXX: bugward combatability
 
123
 
 
124
        while (my ($mod, $arg) = splice(@$modules, 0, 2)) {
 
125
            if ($mod =~ m/^-(\w+)$/) {
 
126
                my $option = lc($1);
 
127
 
 
128
                $default   = $arg    if ($option eq 'default');
 
129
                $conflict  = $arg    if ($option eq 'conflict');
 
130
                @tests     = @{$arg} if ($option eq 'tests');
 
131
                @skiptests = @{$arg} if ($option eq 'skiptests');
 
132
 
 
133
                next;
 
134
            }
 
135
 
 
136
            printf("- %-${maxlen}s ...", $mod);
 
137
 
 
138
            # XXX: check for conflicts and uninstalls(!) them.
 
139
            if (defined(my $cur = _version_check(_load($mod), $arg ||= 0))) {
 
140
                print "loaded. ($cur".($arg ? " >= $arg" : '').")\n";
 
141
                push @Existing, $mod => $arg;
 
142
                $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
 
143
            }
 
144
            else {
 
145
                print "missing." . ($arg ? " (would need $arg)" : '') . "\n";
 
146
                push @required, $mod => $arg;
 
147
            }
 
148
        }
 
149
 
 
150
        next unless @required;
 
151
 
 
152
        my $mandatory = ($feature eq '-core' or $core_all);
 
153
 
 
154
        if (!$SkipInstall and ($CheckOnly or _prompt(
 
155
            qq{==> Auto-install the }. (@required / 2).
 
156
            ($mandatory ? ' mandatory' : ' optional').
 
157
            qq{ module(s) from CPAN?}, $default ? 'y' : 'n',
 
158
        ) =~ /^[Yy]/)) {
 
159
            push (@Missing, @required);
 
160
            $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
 
161
        }
 
162
 
 
163
        elsif (!$SkipInstall and $default and $mandatory and _prompt(
 
164
            qq{==> The module(s) are mandatory! Really skip?}, 'n',
 
165
        ) =~ /^[Nn]/) {
 
166
            push (@Missing, @required);
 
167
            $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
 
168
        }
 
169
 
 
170
        else {
 
171
            $DisabledTests{$_} = 1 for map { glob($_) } @tests;
 
172
        }
173
173
    }
174
174
 
175
175
    _check_lock(); # check for $UnderCPAN
176
176
 
177
177
    if (@Missing and not ($CheckOnly or $UnderCPAN)) {
178
 
        require Config;
179
 
        print "*** Dependencies will be installed the next time you type '$Config::Config{make}'.\n";
180
 
        # make an educated guess of whether we'll need root permission.
181
 
        print "    (You may need to do that as the 'root' user.)\n" if eval '$>';
 
178
        require Config;
 
179
        print "*** Dependencies will be installed the next time you type '$Config::Config{make}'.\n";
 
180
        # make an educated guess of whether we'll need root permission.
 
181
        print "    (You may need to do that as the 'root' user.)\n" if eval '$>';
182
182
    }
183
183
    print "*** $class configuration finished.\n";
184
184
 
198
198
    my $lock = MM->catfile($CPAN::Config->{cpan_home}, ".lock");
199
199
 
200
200
    if (-f $lock and open(LOCK, $lock)
201
 
        and ($^O eq 'MSWin32' ? _under_cpan() : <LOCK> == getppid())
202
 
        and ($CPAN::Config->{prerequisites_policy} || '') ne 'ignore'
 
201
        and ($^O eq 'MSWin32' ? _under_cpan() : <LOCK> == getppid())
 
202
        and ($CPAN::Config->{prerequisites_policy} || '') ne 'ignore'
203
203
    ) {
204
 
        print << '.';
 
204
        print << '.';
205
205
 
206
206
*** Since we're running under CPAN, I'll just let it take care
207
207
    of the dependency's installation later.
208
208
.
209
 
        $UnderCPAN = 1;
 
209
        $UnderCPAN = 1;
210
210
    }
211
211
 
212
212
    close LOCK;
220
220
 
221
221
    my (@modules, @installed);
222
222
    while (my ($pkg, $ver) = splice(@_, 0, 2)) {
223
 
        # grep out those already installed
224
 
        if (defined(_version_check(_load($pkg), $ver))) {
225
 
            push @installed, $pkg;
226
 
        }
227
 
        else {
228
 
            push @modules, $pkg, $ver;
229
 
        }
 
223
        # grep out those already installed
 
224
        if (defined(_version_check(_load($pkg), $ver))) {
 
225
            push @installed, $pkg;
 
226
        }
 
227
        else {
 
228
            push @modules, $pkg, $ver;
 
229
        }
230
230
    }
231
231
 
232
232
    return @installed unless @modules; # nothing to do
238
238
    my %args = @config;
239
239
    my %failed;
240
240
    local *FAILED;
241
 
    if ($args{do_once} and open(FAILED, '.autoinstall.failed')) {
242
 
        while (<FAILED>) { chomp; $failed{$_}++ }
243
 
        close FAILED;
 
241
    if ($args{do_once} and open(FAILED, '.#autoinstall.failed')) {
 
242
        while (<FAILED>) { chomp; $failed{$_}++ }
 
243
        close FAILED;
244
244
 
245
 
        my @newmod;
246
 
        while (my ($k, $v) = splice(@modules, 0, 2)) {
247
 
            push @newmod, ($k => $v) unless $failed{$k};
248
 
        }
249
 
        @modules = @newmod;
 
245
        my @newmod;
 
246
        while (my ($k, $v) = splice(@modules, 0, 2)) {
 
247
            push @newmod, ($k => $v) unless $failed{$k};
 
248
        }
 
249
        @modules = @newmod;
250
250
    }
251
251
 
252
252
    if (_has_cpanplus()) {
253
 
        _install_cpanplus(\@modules, \@config);
 
253
        _install_cpanplus(\@modules, \@config);
254
254
    }
255
255
    else {
256
 
        _install_cpan(\@modules, \@config);
 
256
        _install_cpan(\@modules, \@config);
257
257
    }
258
258
 
259
259
    print "*** $class installation finished.\n";
260
260
 
261
261
    # see if we have successfully installed them
262
262
    while (my ($pkg, $ver) = splice(@modules, 0, 2)) {
263
 
        if (defined(_version_check(_load($pkg), $ver))) {
264
 
            push @installed, $pkg;
265
 
        }
266
 
        elsif ($args{do_once} and open(FAILED, '>> .autoinstall.failed')) {
267
 
            print FAILED "$pkg\n";
268
 
        }
 
263
        if (defined(_version_check(_load($pkg), $ver))) {
 
264
            push @installed, $pkg;
 
265
        }
 
266
        elsif ($args{do_once} and open(FAILED, '>> .#autoinstall.failed')) {
 
267
            print FAILED "$pkg\n";
 
268
        }
269
269
    }
270
270
 
271
271
    close FAILED if $args{do_once};
282
282
    my $cp   = CPANPLUS::Backend->new;
283
283
    my $conf = $cp->configure_object;
284
284
 
285
 
    return unless _can_write($conf->_get_build('base'));
 
285
    return unless _can_write(
 
286
        $conf->can('conf')
 
287
            ? $conf->get_conf('base')       # 0.05x+
 
288
            : $conf->_get_build('base')     # 0.04x
 
289
    );
286
290
 
287
291
    # if we're root, set UNINST=1 to avoid trouble unless user asked for it.
288
292
    my $makeflags = $conf->get_conf('makeflags') || '';
289
293
    if (UNIVERSAL::isa($makeflags, 'HASH')) {
290
 
        # 0.03+ uses a hashref here
291
 
        $makeflags->{UNINST} = 1 unless exists $makeflags->{UNINST};
 
294
        # 0.03+ uses a hashref here
 
295
        $makeflags->{UNINST} = 1 unless exists $makeflags->{UNINST};
292
296
    }
293
297
    else {
294
 
        # 0.02 and below uses a scalar
295
 
        $makeflags = join(' ', split(' ', $makeflags), 'UNINST=1')
296
 
            if ($makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' });
 
298
        # 0.02 and below uses a scalar
 
299
        $makeflags = join(' ', split(' ', $makeflags), 'UNINST=1')
 
300
            if ($makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' });
297
301
    }
298
302
    $conf->set_conf(makeflags => $makeflags);
 
303
    $conf->set_conf(prereqs => 1);
299
304
 
300
305
    while (my ($key, $val) = splice(@config, 0, 2)) {
301
 
        eval { $conf->set_conf($key, $val) };
 
306
        eval { $conf->set_conf($key, $val) };
302
307
    }
303
308
 
304
309
    my $modtree = $cp->module_tree;
305
310
    while (my ($pkg, $ver) = splice(@modules, 0, 2)) {
306
 
        print "*** Installing $pkg...\n";
307
 
 
308
 
        MY::preinstall($pkg, $ver) or next if defined &MY::preinstall;
309
 
 
310
 
        my $success;
311
 
        my $obj = $modtree->{$pkg};
312
 
 
313
 
        if ($obj and defined(_version_check($obj->{version}, $ver))) {
314
 
            my $pathname = $pkg; $pathname =~ s/::/\\W/;
315
 
 
316
 
            foreach my $inc (grep { m/$pathname.pm/i } keys(%INC)) {
317
 
                delete $INC{$inc};
318
 
            }
319
 
 
320
 
            my $rv = $cp->install( modules => [ $obj->{module} ]);
321
 
 
322
 
            if ($rv and ($rv->{$obj->{module}} or $rv->{ok})) {
323
 
                print "*** $pkg successfully installed.\n";
324
 
                $success = 1;
325
 
            }
326
 
            else {
327
 
                print "*** $pkg installation cancelled.\n";
328
 
                $success = 0;
329
 
            }
330
 
 
331
 
            $installed += $success;
332
 
        }
333
 
        else {
334
 
            print << ".";
 
311
        print "*** Installing $pkg...\n";
 
312
 
 
313
        MY::preinstall($pkg, $ver) or next if defined &MY::preinstall;
 
314
 
 
315
        my $success;
 
316
        my $obj = $modtree->{$pkg};
 
317
 
 
318
        if ($obj and defined(_version_check($obj->{version}, $ver))) {
 
319
            my $pathname = $pkg; $pathname =~ s/::/\\W/;
 
320
 
 
321
            foreach my $inc (grep { m/$pathname.pm/i } keys(%INC)) {
 
322
                delete $INC{$inc};
 
323
            }
 
324
 
 
325
            my $rv = $cp->install( modules => [ $obj->{module} ]);
 
326
 
 
327
            if ($rv and ($rv->{$obj->{module}} or $rv->{ok})) {
 
328
                print "*** $pkg successfully installed.\n";
 
329
                $success = 1;
 
330
            }
 
331
            else {
 
332
                print "*** $pkg installation cancelled.\n";
 
333
                $success = 0;
 
334
            }
 
335
 
 
336
            $installed += $success;
 
337
        }
 
338
        else {
 
339
            print << ".";
335
340
*** Could not find a version $ver or above for $pkg; skipping.
336
341
.
337
 
        }
 
342
        }
338
343
 
339
 
        MY::postinstall($pkg, $ver, $success) if defined &MY::postinstall;
 
344
        MY::postinstall($pkg, $ver, $success) if defined &MY::postinstall;
340
345
    }
341
346
 
342
347
    return $installed;
355
360
    # if we're root, set UNINST=1 to avoid trouble unless user asked for it.
356
361
    my $makeflags = $CPAN::Config->{make_install_arg} || '';
357
362
    $CPAN::Config->{make_install_arg} = join(' ', split(' ', $makeflags), 'UNINST=1')
358
 
        if ($makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' });
 
363
        if ($makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' });
359
364
 
360
365
    # don't show start-up info
361
366
    $CPAN::Config->{inhibit_startup_message} = 1;
362
367
 
363
368
    # set additional options
364
369
    while (my ($opt, $arg) = splice(@config, 0, 2)) {
365
 
        ($args{$opt} = $arg, next)
366
 
            if $opt =~ /^force$/; # pseudo-option
367
 
        $CPAN::Config->{$opt} = $arg;
 
370
        ($args{$opt} = $arg, next)
 
371
            if $opt =~ /^force$/; # pseudo-option
 
372
        $CPAN::Config->{$opt} = $arg;
368
373
    }
369
374
 
 
375
    local $CPAN::Config->{prerequisites_policy} = 'follow';
 
376
 
370
377
    while (my ($pkg, $ver) = splice(@modules, 0, 2)) {
371
 
        MY::preinstall($pkg, $ver) or next if defined &MY::preinstall;
372
 
 
373
 
        print "*** Installing $pkg...\n";
374
 
 
375
 
        my $obj = CPAN::Shell->expand(Module => $pkg);
376
 
        my $success = 0;
377
 
 
378
 
        if ($obj and defined(_version_check($obj->cpan_version, $ver))) {
379
 
            my $pathname = $pkg; $pathname =~ s/::/\\W/;
380
 
 
381
 
            foreach my $inc (grep { m/$pathname.pm/i } keys(%INC)) {
382
 
                delete $INC{$inc};
383
 
            }
384
 
 
385
 
            $obj->force('install') if $args{force};
386
 
 
387
 
            if ($obj->install eq 'YES') {
388
 
                print "*** $pkg successfully installed.\n";
389
 
                $success = 1;
390
 
            }
391
 
            else {
392
 
                print "*** $pkg installation failed.\n";
393
 
                $success = 0;
394
 
            }
395
 
 
396
 
            $installed += $success;
397
 
        }
398
 
        else {
399
 
            print << ".";
 
378
        MY::preinstall($pkg, $ver) or next if defined &MY::preinstall;
 
379
 
 
380
        print "*** Installing $pkg...\n";
 
381
 
 
382
        my $obj = CPAN::Shell->expand(Module => $pkg);
 
383
        my $success = 0;
 
384
 
 
385
        if ($obj and defined(_version_check($obj->cpan_version, $ver))) {
 
386
            my $pathname = $pkg; $pathname =~ s/::/\\W/;
 
387
 
 
388
            foreach my $inc (grep { m/$pathname.pm/i } keys(%INC)) {
 
389
                delete $INC{$inc};
 
390
            }
 
391
 
 
392
            $obj->force('install') if $args{force};
 
393
 
 
394
            my $rv = $obj->install || eval { 
 
395
                $CPAN::META->instance(
 
396
                    'CPAN::Distribution',
 
397
                    $obj->cpan_file,
 
398
                )->{install} if $CPAN::META
 
399
            };
 
400
 
 
401
            if ($rv eq 'YES') {
 
402
                print "*** $pkg successfully installed.\n";
 
403
                $success = 1;
 
404
            }
 
405
            else {
 
406
                print "*** $pkg installation failed.\n";
 
407
                $success = 0;
 
408
            }
 
409
 
 
410
            $installed += $success;
 
411
        }
 
412
        else {
 
413
            print << ".";
400
414
*** Could not find a version $ver or above for $pkg; skipping.
401
415
.
402
 
        }
 
416
        }
403
417
 
404
 
        MY::postinstall($pkg, $ver, $success) if defined &MY::postinstall;
 
418
        MY::postinstall($pkg, $ver, $success) if defined &MY::postinstall;
405
419
    }
406
420
 
407
421
    return $installed;
409
423
 
410
424
sub _has_cpanplus {
411
425
    return (
412
 
        $HasCPANPLUS = (
413
 
            $INC{'CPANPLUS/Config.pm'} or
414
 
            _load('CPANPLUS::Shell::Default')
415
 
        )
 
426
        $HasCPANPLUS = (
 
427
            $INC{'CPANPLUS/Config.pm'} or
 
428
            _load('CPANPLUS::Shell::Default')
 
429
        )
416
430
    );
417
431
}
418
432
 
434
448
    return if defined(_version_check(_load($class), $ver)); # no need to upgrade
435
449
 
436
450
    if (_prompt(
437
 
        "==> A newer version of $class ($ver) is required. Install?", 'y'
 
451
        "==> A newer version of $class ($ver) is required. Install?", 'y'
438
452
    ) =~ /^[Nn]/) {
439
 
        die "*** Please install $class $ver manually.\n";
 
453
        die "*** Please install $class $ver manually.\n";
440
454
    }
441
455
 
442
456
    print << ".";
445
459
 
446
460
    # install ourselves
447
461
    _load($class) and return $class->import(@_)
448
 
        if $class->install([], $class, $ver);
 
462
        if $class->install([], $class, $ver);
449
463
 
450
464
    print << '.'; exit 1;
451
465
 
458
472
    my $site = shift;
459
473
 
460
474
    return (
461
 
        ( _load('Socket') and Socket::inet_aton($site) ) or _prompt(qq(
 
475
        ( _load('Socket') and Socket::inet_aton($site) ) or _prompt(qq(
462
476
*** Your host cannot resolve the domain name '$site', which
463
477
    probably means the Internet connections are unavailable.
464
478
==> Should we try to install the required module(s) anyway?), 'n'
465
 
        ) =~ /^[Yy]/
 
479
        ) =~ /^[Yy]/
466
480
    );
467
481
}
468
482
 
482
496
    if (eval '$>' and lc(`sudo -V`) =~ /version/ and _prompt(qq(
483
497
==> Should we try to re-execute the autoinstall process with 'sudo'?), 'y'
484
498
    ) =~ /^[Yy]/) {
485
 
        # try to bootstrap ourselves from sudo
486
 
        print << ".";
 
499
        # try to bootstrap ourselves from sudo
 
500
        print << ".";
487
501
*** Trying to re-execute the autoinstall process with 'sudo'...
488
502
.
489
503
        my $missing = join(',', @Missing);
490
504
        my $config  = join(',',
491
 
            UNIVERSAL::isa($Config, 'HASH') ? %{$Config} : @{$Config}
 
505
            UNIVERSAL::isa($Config, 'HASH') ? %{$Config} : @{$Config}
492
506
        ) if $Config;
493
507
 
494
 
        return unless system('sudo', $^X, $0, "--config=$config", "--installdeps=$missing");
 
508
        return unless system('sudo', $^X, $0, "--config=$config", "--installdeps=$missing");
495
509
 
496
 
        print << ".";
 
510
        print << ".";
497
511
*** The 'sudo' command exited with error!  Resuming...
498
512
.
499
513
    }
524
538
 
525
539
    # check for version numbers that are not in decimal format
526
540
    if (ref($cur) or ref($min) or $cur =~ /v|\..*\./ or $min =~ /v|\..*\./) {
527
 
        if ($version::VERSION or defined(_load('version'))) {
528
 
            # use version.pm if it is installed.
529
 
            return ((version->new($cur) >= version->new($min)) ? $cur : undef);
530
 
        }
531
 
        elsif ($Sort::Versions::VERSION or defined(_load('Sort::Versions'))) {
532
 
            # use Sort::Versions as the sorting algorithm for a.b.c versions
533
 
            return ((Sort::Versions::versioncmp($cur, $min) != -1) ? $cur : undef);
534
 
        }
 
541
        if ($version::VERSION or defined(_load('version'))) {
 
542
            # use version.pm if it is installed.
 
543
            return ((version->new($cur) >= version->new($min)) ? $cur : undef);
 
544
        }
 
545
        elsif ($Sort::Versions::VERSION or defined(_load('Sort::Versions'))) {
 
546
            # use Sort::Versions as the sorting algorithm for a.b.c versions
 
547
            return ((Sort::Versions::versioncmp($cur, $min) != -1) ? $cur : undef);
 
548
        }
535
549
 
536
 
        warn "Cannot reliably compare non-decimal formatted versions.\n".
537
 
             "Please install version.pm or Sort::Versions.\n";
 
550
        warn "Cannot reliably compare non-decimal formatted versions.\n".
 
551
             "Please install version.pm or Sort::Versions.\n";
538
552
    }
539
553
 
540
554
    # plain comparison
549
563
    my %args = @_;
550
564
 
551
565
    $args{PREREQ_PM} = { %{$args{PREREQ_PM} || {} }, @Existing, @Missing }
552
 
        if $UnderCPAN or $TestOnly;
 
566
        if $UnderCPAN or $TestOnly;
553
567
 
554
568
    if ($args{EXE_FILES}) {
555
 
        require ExtUtils::Manifest;
556
 
        my $manifest = ExtUtils::Manifest::maniread('MANIFEST');
 
569
        require ExtUtils::Manifest;
 
570
        my $manifest = ExtUtils::Manifest::maniread('MANIFEST');
557
571
 
558
 
        $args{EXE_FILES} = [
559
 
            grep { exists $manifest->{$_} } @{$args{EXE_FILES}}
560
 
        ];
 
572
        $args{EXE_FILES} = [
 
573
            grep { exists $manifest->{$_} } @{$args{EXE_FILES}}
 
574
        ];
561
575
    }
562
576
 
563
577
    $args{test}{TESTS} ||= 't/*.t';
564
578
    $args{test}{TESTS} = join(' ', grep {
565
 
        !exists($DisabledTests{$_})
 
579
        !exists($DisabledTests{$_})
566
580
    } map { glob($_) } split(/\s+/, $args{test}{TESTS}));
567
581
 
568
582
    my $missing = join(',', @Missing);
569
583
    my $config  = join(',',
570
 
        UNIVERSAL::isa($Config, 'HASH') ? %{$Config} : @{$Config}
 
584
        UNIVERSAL::isa($Config, 'HASH') ? %{$Config} : @{$Config}
571
585
    ) if $Config;
572
586
 
573
587
    $PostambleActions = (
574
 
        $missing ? "\$(PERL) $0 --config=$config --installdeps=$missing"
575
 
                 : "\@\$(NOOP)"
 
588
        $missing ? "\$(PERL) $0 --config=$config --installdeps=$missing"
 
589
                 : "\@\$(NOOP)"
576
590
    );
577
591
 
578
592
    return %args;
584
598
    Carp::croak "WriteMakefile: Need even number of args" if @_ % 2;
585
599
 
586
600
    if ($CheckOnly) {
587
 
        print << ".";
 
601
        print << ".";
588
602
*** Makefile not written in check-only mode.
589
603
.
590
 
        return;
 
604
        return;
591
605
    }
592
606
 
593
607
    my %args = _make_args(@_);
629
643
 
630
644
__END__
631
645
 
632
 
#line 910
 
646
#line 970