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