~ubuntu-branches/ubuntu/dapper/libmodule-install-perl/dapper

« back to all changes in this revision

Viewing changes to lib/Module/Install/AutoInstall.pm

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2004-04-03 23:07:38 UTC
  • Revision ID: james.westby@ubuntu.com-20040403230738-z8wkxryscyv90fjl
Tags: upstream-0.33
ImportĀ upstreamĀ versionĀ 0.33

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# $File: //depot/cpan/Module-Install/lib/Module/Install/AutoInstall.pm $ $Author: autrijus $
 
2
# $Revision: #13 $ $Change: 1846 $ $DateTime: 2003/12/31 22:57:12 $ vim: expandtab shiftwidth=4
 
3
 
 
4
package Module::Install::AutoInstall;
 
5
use Module::Install::Base; @ISA = qw(Module::Install::Base);
 
6
 
 
7
sub AutoInstall { $_[0] }
 
8
 
 
9
sub run {
 
10
    my $self = shift;
 
11
    $self->auto_install_now(@_);
 
12
}
 
13
 
 
14
sub write {
 
15
    my $self = shift;
 
16
    $self->auto_install(@_);
 
17
}
 
18
 
 
19
sub auto_install {
 
20
    my $self = shift;
 
21
    return if $self->{done}++;
 
22
 
 
23
# ExtUtils::AutoInstall Bootstrap Code, version 7.
 
24
AUTO:{my$p='ExtUtils::AutoInstall';my$v=0.49;$p->VERSION||0>=$v
 
25
or+eval"use $p $v;1"or+do{my$e=$ENV{PERL_EXTUTILS_AUTOINSTALL};
 
26
(!defined($e)||$e!~m/--(?:default|skip|testonly)/and-t STDIN or
 
27
eval"use ExtUtils::MakeMaker;WriteMakefile(PREREQ_PM=>{'$p',$v}
 
28
);1"and exit)and print"==> $p $v required. Install it from CP".
 
29
"AN? [Y/n] "and<STDIN>!~/^n/i and print"*** Installing $p\n"and
 
30
do{if (eval '$>' and lc(`sudo -V`) =~ /version/){system('sudo',
 
31
$^X,"-MCPANPLUS","-e","CPANPLUS::install $p");eval"use $p $v;1"
 
32
||system('sudo', $^X, "-MCPAN", "-e", "CPAN::install $p")}eval{
 
33
require CPANPLUS;CPANPLUS::install$p};eval"use $p $v;1"or eval{
 
34
require CPAN;CPAN::install$p};eval"use $p $v;1"||die"*** Please
 
35
manually install $p $v from cpan.org first...\n"}}}
 
36
 
 
37
    # Flatten array of arrays into a single array
 
38
    my @core = map @$_, map @$_, grep ref,
 
39
               $self->build_requires, $self->requires;
 
40
 
 
41
    while ( @core and @_ > 1 and $_[0] =~ /^-\w+$/ ) {
 
42
        push @core, splice(@_, 0, 2);
 
43
    }
 
44
 
 
45
    ExtUtils::AutoInstall->import(
 
46
        (@core ? (-core => \@core) : ()), @_, $self->features
 
47
    );
 
48
 
 
49
    $self->makemaker_args( ExtUtils::AutoInstall::_make_args() );
 
50
 
 
51
    my $class = ref($self);
 
52
    $self->postamble(
 
53
        "# --- $class section:\n" .
 
54
        ExtUtils::AutoInstall::postamble()
 
55
    );
 
56
}
 
57
 
 
58
sub auto_install_now {
 
59
    my $self = shift;
 
60
    $self->auto_install;
 
61
    ExtUtils::AutoInstall::do_install();
 
62
}
 
63
 
 
64
1;