App-Acmeman

 view release on metacpan or  search on metacpan

inc/ExtUtils/AutoInstall.pm  view on Meta::CPAN

        }
        elsif ($arg =~ /^--skip(?:deps)?$/) {
            $SkipInstall = 1;
        }
        elsif ($arg =~ /^--test(?:only)?$/) {
            $TestOnly = 1;
        }
    }
}

# overrides MakeMaker's prompt() to automatically accept the default choice
sub _prompt {
    goto &ExtUtils::MakeMaker::prompt unless $AcceptDefault;

    my ($prompt, $default) = @_;
    my $y = ($default =~ /^[Yy]/);

    print $prompt, ' [', ($y ? 'Y' : 'y'), '/', ($y ? 'n' : 'N'), '] ';
    print "$default\n";
    return $default;
}

# the workhorse
sub import {
    my $class = shift;
    my @args  = @_ or return;
    my $core_all;

inc/ExtUtils/AutoInstall.pm  view on Meta::CPAN

            else {
                print "missing." . ($arg ? " (would need $arg)" : '') . "\n";
                push @required, $mod => $arg;
            }
        }

        next unless @required;

        my $mandatory = ($feature eq '-core' or $core_all);

        if (!$SkipInstall and ($CheckOnly or _prompt(
            qq{==> Auto-install the }. (@required / 2).
            ($mandatory ? ' mandatory' : ' optional').
            qq{ module(s) from CPAN?}, $default ? 'y' : 'n',
        ) =~ /^[Yy]/)) {
            push (@Missing, @required);
            $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
        }

        elsif (!$SkipInstall and $default and $mandatory and _prompt(
            qq{==> The module(s) are mandatory! Really skip?}, 'n',
        ) =~ /^[Nn]/) {
            push (@Missing, @required);
            $DisabledTests{$_} = 1 for map { glob($_) } @skiptests;
        }

        else {
            $DisabledTests{$_} = 1 for map { glob($_) } @tests;
        }
    }

inc/ExtUtils/AutoInstall.pm  view on Meta::CPAN


    return (index($cwd, $cpan) > -1);
}

sub _update_to {
    my $class = __PACKAGE__;
    my $ver   = shift;

    return if defined(_version_check(_load($class), $ver)); # no need to upgrade

    if (_prompt(
        "==> A newer version of $class ($ver) is required. Install?", 'y'
    ) =~ /^[Nn]/) {
        die "*** Please install $class $ver manually.\n";
    }

    print << ".";
*** Trying to fetch it from CPAN...
.

    # install ourselves

inc/ExtUtils/AutoInstall.pm  view on Meta::CPAN


*** Cannot bootstrap myself. :-( Installation terminated.
.
}

# check if we're connected to some host, using inet_aton
sub _connected_to {
    my $site = shift;

    return (
        ( _load('Socket') and Socket::inet_aton($site) ) or _prompt(qq(
*** Your host cannot resolve the domain name '$site', which
    probably means the Internet connections are unavailable.
==> Should we try to install the required module(s) anyway?), 'n'
        ) =~ /^[Yy]/
    );
}

# check if a directory is writable; may create it on demand
sub _can_write {
    my $path = shift;
    mkdir ($path, 0755) unless -e $path;

    return 1 if -w $path;

    print << ".";
*** You are not allowed to write to the directory '$path';
    the installation may fail due to insufficient permissions.
.

    if (eval '$>' and lc(`sudo -V`) =~ /version/ and _prompt(qq(
==> Should we try to re-execute the autoinstall process with 'sudo'?), 'y'
    ) =~ /^[Yy]/) {
        # try to bootstrap ourselves from sudo
        print << ".";
*** Trying to re-execute the autoinstall process with 'sudo'...
.
        my $missing = join(',', @Missing);
        my $config  = join(',',
            UNIVERSAL::isa($Config, 'HASH') ? %{$Config} : @{$Config}
        ) if $Config;

        return unless system('sudo', $^X, $0, "--config=$config", "--installdeps=$missing");

        print << ".";
*** The 'sudo' command exited with error!  Resuming...
.
    }

    return _prompt(qq(
==> Should we try to install the required module(s) anyway?), 'n'
    ) =~ /^[Yy]/
}

# load a module and return the version it reports
sub _load {
    my $mod = pop; # class/instance doesn't matter
    my $file = $mod;

    $file =~ s|::|/|g;



( run in 0.636 second using v1.01-cache-2.11-cpan-6aa56a78535 )