App-Acmeman
view release on metacpan or search on metacpan
inc/ExtUtils/AutoInstall.pm view on Meta::CPAN
my $rv = $cp->install( modules => [ $obj->{module} ]);
if ($rv and ($rv->{$obj->{module}} or $rv->{ok})) {
print "*** $pkg successfully installed.\n";
$success = 1;
}
else {
print "*** $pkg installation cancelled.\n";
$success = 0;
}
$installed += $success;
}
else {
print << ".";
*** Could not find a version $ver or above for $pkg; skipping.
.
}
MY::postinstall($pkg, $ver, $success) if defined &MY::postinstall;
}
return $installed;
}
sub _install_cpan {
my @modules = @{+shift};
my @config = @{+shift};
my $installed = 0;
my %args;
require CPAN; CPAN::Config->load;
require Config;
return unless _can_write(MM->catfile($CPAN::Config->{cpan_home}, 'sources'))
and _can_write($Config::Config{sitelib});
# if we're root, set UNINST=1 to avoid trouble unless user asked for it.
my $makeflags = $CPAN::Config->{make_install_arg} || '';
$CPAN::Config->{make_install_arg} = join(' ', split(' ', $makeflags), 'UNINST=1')
if ($makeflags !~ /\bUNINST\b/ and eval qq{ $> eq '0' });
# don't show start-up info
$CPAN::Config->{inhibit_startup_message} = 1;
# set additional options
while (my ($opt, $arg) = splice(@config, 0, 2)) {
($args{$opt} = $arg, next)
if $opt =~ /^force$/; # pseudo-option
$CPAN::Config->{$opt} = $arg;
}
local $CPAN::Config->{prerequisites_policy} = 'follow';
while (my ($pkg, $ver) = splice(@modules, 0, 2)) {
MY::preinstall($pkg, $ver) or next if defined &MY::preinstall;
print "*** Installing $pkg...\n";
my $obj = CPAN::Shell->expand(Module => $pkg);
my $success = 0;
if ($obj and defined(_version_check($obj->cpan_version, $ver))) {
my $pathname = $pkg; $pathname =~ s/::/\\W/;
foreach my $inc (grep { m/$pathname.pm/i } keys(%INC)) {
delete $INC{$inc};
}
$obj->force('install') if $args{force};
my $rv = $obj->install || eval {
$CPAN::META->instance(
'CPAN::Distribution',
$obj->cpan_file,
)->{install} if $CPAN::META
};
if ($rv eq 'YES') {
print "*** $pkg successfully installed.\n";
$success = 1;
}
else {
print "*** $pkg installation failed.\n";
$success = 0;
}
$installed += $success;
}
else {
print << ".";
*** Could not find a version $ver or above for $pkg; skipping.
.
}
MY::postinstall($pkg, $ver, $success) if defined &MY::postinstall;
}
return $installed;
}
sub _has_cpanplus {
return (
$HasCPANPLUS = (
$INC{'CPANPLUS/Config.pm'} or
_load('CPANPLUS::Shell::Default')
)
);
}
# make guesses on whether we're under the CPAN installation directory
sub _under_cpan {
require Cwd;
require File::Spec;
my $cwd = File::Spec->canonpath(Cwd::cwd());
my $cpan = File::Spec->canonpath($CPAN::Config->{cpan_home});
return (index($cwd, $cpan) > -1);
}
( run in 1.963 second using v1.01-cache-2.11-cpan-97f6503c9c8 )