Commit | Line | Data |
391107e5 |
1 | use strict; |
2 | use warnings; |
86f54d7f |
3 | use vars qw($bootstrapping); |
4 | |
5 | BEGIN { |
d4dbe584 |
6 | # watch out for fancy dashes. these can wind up in our @ARGV if the user is |
7 | # copypasting the bootstrap command from the POD displayed e.g. by perldoc |
8 | # on a Mac OS X terminal. since no software recognizes and handles these |
9 | # dashes, it's better to die loudly telling the user exactly what happened |
10 | # so they don't make the same mistake again rather than being the only |
11 | # program in the universe that works with them. |
12 | if(grep { /−/ } @ARGV) { |
13 | die <<'DEATH'; |
14 | WHOA THERE! It looks like you've got some fancy dashes in your commandline! |
15 | These are *not* the traditional -- dashes that software recognizes. You |
16 | probably got these by copy-pasting from the perldoc for this module as |
17 | rendered by a UTF8-capable formatter. This most typically happens on an OS X |
18 | terminal, but can happen elsewhere too. Please try again after replacing the |
19 | dashes with normal minus signs. |
20 | DEATH |
21 | } |
c2447f35 |
22 | if (my ($x) = grep { /^--bootstrap(?:=.*)?$/ } @ARGV) { |
23 | @ARGV = grep { !/^--bootstrap(?:=.*)?$/ } @ARGV; |
86f54d7f |
24 | $bootstrapping = 1; |
c2447f35 |
25 | $x =~ /^--bootstrap(?:=(.*))?$/; |
86f54d7f |
26 | my @args = (defined $1 ? ($1) : ()); |
27 | |
28 | { |
29 | local @INC = @INC; |
30 | unshift(@INC, 'lib'); |
31 | require local::lib; |
32 | } |
33 | |
34 | local::lib->import(@args); |
35 | |
36 | push(@ARGV,$ENV{PERL_MM_OPT}); |
4662123f |
37 | push(@ARGV, map { "-I$_" } split(':',$ENV{PERL5LIB})); |
86f54d7f |
38 | |
39 | system($^X, '-MExtUtils::MakeMaker 6.31', '-e1'); |
b57052ce |
40 | my $eumm = $? >> 8; |
41 | |
42 | system($^X, '-MCPAN 1.80', '-e1'); |
43 | my $cpan = $? >> 8; |
44 | my $cpan_command = ''; |
86f54d7f |
45 | |
715c31a0 |
46 | system($^X, '-MCPAN', '-e', |
279e9381 |
47 | 'my $done; require ExtUtils::MakeMaker; |
48 | my $orig = ExtUtils::MakeMaker->can("prompt"); |
49 | *ExtUtils::MakeMaker::prompt = sub { |
50 | if (!$done && $_[0] =~ /manual configuration/) { |
51 | $done++; |
52 | return "no"; |
53 | } |
54 | return $orig->(@_); |
55 | }; |
56 | CPAN::Config->load; |
57 | unless ($done || -w $CPAN::Config->{keep_source_where}) { |
715c31a0 |
58 | my $save = $CPAN::Config->{urllist}; |
59 | delete @{$CPAN::Config}{keys %$CPAN::Config}; |
60 | $CPAN::Config->{urllist} = $save; |
61 | CPAN::Config->init; |
62 | }' |
63 | ); |
64 | |
279e9381 |
65 | $ENV{PERL_MM_USE_DEFAULT} = 1; |
66 | |
86f54d7f |
67 | # XXX - remove the force on EUMM once its test suite survive PERL_MM_OPT |
68 | |
b57052ce |
69 | if ($eumm) { # non-zero exit |
70 | $cpan_command .= 'force("install","ExtUtils::MakeMaker"); '; |
71 | } |
72 | if ($cpan) { |
c2447f35 |
73 | $cpan_command .= 'force("install","CPAN"); '; |
b57052ce |
74 | } |
75 | if(length $cpan_command) { |
76 | system($^X, '-MCPAN', '-e', $cpan_command); |
86f54d7f |
77 | } |
715c31a0 |
78 | if ($cpan) { |
79 | system($^X, '-MCPAN', '-e', 'CPAN::Config->load; CPAN::Config->commit;'); |
80 | } |
86f54d7f |
81 | } |
82 | } |
83 | |
391107e5 |
84 | use inc::Module::Install; |
85 | |
86 | name 'local-lib'; |
87 | all_from 'lib/local/lib.pm'; |
88 | |
89 | requires 'ExtUtils::MakeMaker' => '6.31'; # version INSTALL_BASE was added |
86f54d7f |
90 | requires 'ExtUtils::CBuilder'; # this and ParseXS are needed for MB C_support |
91 | requires 'ExtUtils::ParseXS'; |
391107e5 |
92 | requires 'Module::Build' => '0.28'; # lib -> lib/perl5 change |
86f54d7f |
93 | requires 'CPAN' => '1.80'; # sudo support |
94 | |
10fcef9b |
95 | # No, really. See |
96 | # https://rt.cpan.org/Public/Bug/Display.html?id=23735 |
97 | # for why CPAN now sets the CPANPLUS env var. |
98 | # trouble is this means we can't auto_install(_now) CPAN itself |
99 | # without this beautiful hack |
100 | |
101 | my $no_cpanplus_env = !exists $ENV{PERL5_CPANPLUS_IS_RUNNING}; |
102 | require CPAN; |
103 | delete $ENV{PERL5_CPANPLUS_IS_RUNNING} if $no_cpanplus_env; |
104 | |
86f54d7f |
105 | if ($bootstrapping) { |
106 | auto_install_now; |
107 | } else { |
108 | auto_install; |
109 | } |
391107e5 |
110 | |
111 | WriteAll; |