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