Commit | Line | Data |
391107e5 |
1 | use strict; |
2 | use warnings; |
c4dbb66c |
3 | use File::Spec; |
4 | use Cwd; |
b9c94c15 |
5 | use vars qw($bootstrapping $bootstrapping_args $no_manpages); |
53699c99 |
6 | use Config; |
86f54d7f |
7 | |
1c9cde8e |
8 | # Solaris (and possibly other Unices) have a tar in /usr/bin that, among |
9 | # other things, does not understand @LongLink. This can cause |
10 | # extraction to look like it succeeded, but it actually failed (because |
11 | # the error message for the @LongLink failure scrolled offscreen). |
12 | # Therefore, given the fact that GNU tar is the most widespread tar available, |
13 | # and it actually supports the feature we want (I'd bet it originated in GNU |
14 | # tar, but I digress), we'll look for GNU tar. If we don't find it, and the |
15 | # user hasn't pointed us to a suitable tar, we'll bomb and tell them what to |
16 | # do. |
17 | |
18 | my $have_gtar = 0; |
19 | if($^O eq 'solaris') { |
20 | $have_gtar = 0; |
21 | for my $env_path (split /:/, $ENV{PATH}) { |
22 | $have_gtar = 1 if -x File::Spec->catfile($env_path, 'gtar'); |
23 | } |
24 | } else { |
25 | $have_gtar = 1; |
26 | } |
27 | if(exists $ENV{PERL_LL_TAR}) { |
28 | $have_gtar ||= -x $ENV{PERL_LL_TAR}; |
29 | } |
30 | |
c27d9c94 |
31 | die <<'DEATH' unless $have_gtar; |
1c9cde8e |
32 | You are using Solaris (or another traditional Unix) that does not provide a sane |
33 | tar, capable of dealing with the output of GNU tar. Please either set the |
34 | PERL_LL_TAR environment variable to the location of a version of tar that |
35 | understands the @LongLink convention or put a binary named gtar somewhere on |
36 | your PATH. |
37 | DEATH |
38 | |
c4dbb66c |
39 | my $cwd; |
86f54d7f |
40 | BEGIN { |
c4dbb66c |
41 | $cwd = Cwd::cwd(); |
d4dbe584 |
42 | # watch out for fancy dashes. these can wind up in our @ARGV if the user is |
43 | # copypasting the bootstrap command from the POD displayed e.g. by perldoc |
44 | # on a Mac OS X terminal. since no software recognizes and handles these |
45 | # dashes, it's better to die loudly telling the user exactly what happened |
46 | # so they don't make the same mistake again rather than being the only |
47 | # program in the universe that works with them. |
48 | if(grep { /−/ } @ARGV) { |
49 | die <<'DEATH'; |
50 | WHOA THERE! It looks like you've got some fancy dashes in your commandline! |
51 | These are *not* the traditional -- dashes that software recognizes. You |
52 | probably got these by copy-pasting from the perldoc for this module as |
53 | rendered by a UTF8-capable formatter. This most typically happens on an OS X |
54 | terminal, but can happen elsewhere too. Please try again after replacing the |
55 | dashes with normal minus signs. |
56 | DEATH |
57 | } |
c2447f35 |
58 | if (my ($x) = grep { /^--bootstrap(?:=.*)?$/ } @ARGV) { |
59 | @ARGV = grep { !/^--bootstrap(?:=.*)?$/ } @ARGV; |
86f54d7f |
60 | $bootstrapping = 1; |
b9c94c15 |
61 | if(my ($x) = grep { /^--no-manpages/ } @ARGV) { |
62 | $no_manpages = 1; |
63 | @ARGV = grep { !/^--no-manpages/ } @ARGV; |
64 | } |
c4dbb66c |
65 | my ($path) = $x =~ /^--bootstrap(?:=(.*))?$/; |
66 | my @args = $path ? $path : (); |
86f54d7f |
67 | |
68 | { |
69 | local @INC = @INC; |
70 | unshift(@INC, 'lib'); |
71 | require local::lib; |
72 | } |
73 | |
74 | local::lib->import(@args); |
75 | |
53699c99 |
76 | my @libs = map { "-I$_" } split $Config{path_sep}, $ENV{PERL5LIB}; |
c4dbb66c |
77 | $bootstrapping_args = "@libs"; |
86f54d7f |
78 | push(@ARGV,$ENV{PERL_MM_OPT}); |
c4dbb66c |
79 | push(@ARGV, @libs); |
86f54d7f |
80 | |
1c9cde8e |
81 | # <mst> GODDAMN makepl_arg INSTALLDIRS=site |
82 | # <mst> we must set PERL_AUTOINSTALL_PREFER_CPAN too |
83 | $ENV{PERL_AUTOINSTALL_PREFER_CPAN} = 1; |
84 | |
86f54d7f |
85 | system($^X, '-MExtUtils::MakeMaker 6.31', '-e1'); |
b57052ce |
86 | my $eumm = $? >> 8; |
87 | |
e9227729 |
88 | system($^X, '-MExtUtils::Install 1.43', '-e1'); |
89 | my $eui = $? >> 8; |
90 | |
d2185901 |
91 | system($^X, '-MCPAN 1.82', '-e1'); |
b57052ce |
92 | my $cpan = $? >> 8; |
93 | my $cpan_command = ''; |
86f54d7f |
94 | |
715c31a0 |
95 | system($^X, '-MCPAN', '-e', |
279e9381 |
96 | 'my $done; require ExtUtils::MakeMaker; |
97 | my $orig = ExtUtils::MakeMaker->can("prompt"); |
b143d045 |
98 | *ExtUtils::MakeMaker::prompt = sub ($;$) { |
279e9381 |
99 | if (!$done && $_[0] =~ /manual configuration/) { |
100 | $done++; |
101 | return "no"; |
102 | } |
103 | return $orig->(@_); |
104 | }; |
1c9cde8e |
105 | $CPAN::Config->{urllist} = ["http://cpan.shadowcatprojects.net"]; |
106 | # <mst> all bootstrapped fine on one DH account |
107 | # <mst> on another, it tries to install man stuff into /usr/local |
108 | # <mst> cannot for the life of me figure out why |
109 | # <mst> (same fucking server as well) |
110 | # <mst> GOT THE BASTARD |
111 | # <mst> ExtUtils::ParseXS uses Module::Build |
112 | # <mst> but Module::Build depends on it |
113 | # <mst> so you need to set prefer_installer MM |
114 | # <mst> so cpan uses EU::ParseXS' Makefile.PL |
115 | # <mst> since we already got EUMM, *that* works |
116 | $CPAN::Config->{prefer_installer} = "EUMM"; |
279e9381 |
117 | CPAN::Config->load; |
118 | unless ($done || -w $CPAN::Config->{keep_source_where}) { |
715c31a0 |
119 | my $save = $CPAN::Config->{urllist}; |
120 | delete @{$CPAN::Config}{keys %$CPAN::Config}; |
121 | $CPAN::Config->{urllist} = $save; |
122 | CPAN::Config->init; |
123 | }' |
124 | ); |
125 | |
279e9381 |
126 | $ENV{PERL_MM_USE_DEFAULT} = 1; |
127 | |
86f54d7f |
128 | # XXX - remove the force on EUMM once its test suite survive PERL_MM_OPT |
129 | |
b57052ce |
130 | if ($eumm) { # non-zero exit |
131 | $cpan_command .= 'force("install","ExtUtils::MakeMaker"); '; |
132 | } |
e9227729 |
133 | if ($eui) { |
134 | $cpan_command .= 'install("ExtUtils::Install"); '; |
135 | } |
b57052ce |
136 | if ($cpan) { |
c2447f35 |
137 | $cpan_command .= 'force("install","CPAN"); '; |
b57052ce |
138 | } |
139 | if(length $cpan_command) { |
140 | system($^X, '-MCPAN', '-e', $cpan_command); |
86f54d7f |
141 | } |
715c31a0 |
142 | if ($cpan) { |
143 | system($^X, '-MCPAN', '-e', 'CPAN::Config->load; CPAN::Config->commit;'); |
144 | } |
b9c94c15 |
145 | if($no_manpages) { |
146 | # if we call this code directly, the changes get written to |
147 | # $BOOTSTRAP/lib/perl5/CPAN/Config.pm, not where the user expects them to |
148 | # be in their ~/.cpan/CPAN/MyConfig.pm. |
149 | system($^X, '-MCPAN', |
150 | '-e', |
151 | q[CPAN::HandleConfig->load;], |
152 | '-e', |
153 | q[$CPAN::Config->{makepl_arg} = ] . |
154 | q['INSTALLMAN1DIR=none INSTALLMAN3DIR=none';], |
155 | '-e', |
156 | q[$CPAN::Config->{buildpl_arg} = ] . |
157 | q['--install_path libdoc="" --install_path bindoc=""';], |
158 | '-e', |
159 | q[CPAN::Config->commit;], |
160 | ); |
161 | } |
c4dbb66c |
162 | |
163 | chdir($cwd); |
86f54d7f |
164 | } |
165 | } |
166 | |
391107e5 |
167 | use inc::Module::Install; |
168 | |
169 | name 'local-lib'; |
170 | all_from 'lib/local/lib.pm'; |
171 | |
172 | requires 'ExtUtils::MakeMaker' => '6.31'; # version INSTALL_BASE was added |
e9227729 |
173 | requires 'ExtUtils::Install' => '1.43'; # ditto |
86f54d7f |
174 | requires 'ExtUtils::CBuilder'; # this and ParseXS are needed for MB C_support |
175 | requires 'ExtUtils::ParseXS'; |
391107e5 |
176 | requires 'Module::Build' => '0.28'; # lib -> lib/perl5 change |
d2185901 |
177 | my $required_CPAN = '1.82'; |
6d74e2d7 |
178 | requires 'CPAN' => $required_CPAN; # sudo support + CPAN::HandleConfig |
86f54d7f |
179 | |
10fcef9b |
180 | # No, really. See |
181 | # https://rt.cpan.org/Public/Bug/Display.html?id=23735 |
182 | # for why CPAN now sets the CPANPLUS env var. |
183 | # trouble is this means we can't auto_install(_now) CPAN itself |
184 | # without this beautiful hack |
185 | |
186 | my $no_cpanplus_env = !exists $ENV{PERL5_CPANPLUS_IS_RUNNING}; |
9a021b2b |
187 | my $no_cpan_env = !exists $ENV{PERL5_CPAN_IS_RUNNING}; |
10fcef9b |
188 | require CPAN; |
189 | delete $ENV{PERL5_CPANPLUS_IS_RUNNING} if $no_cpanplus_env; |
9a021b2b |
190 | delete $ENV{PERL5_CPAN_IS_RUNNING} if $no_cpan_env; |
10fcef9b |
191 | |
c4dbb66c |
192 | # and make sure that the user doesn't have any existing CPAN config that'll |
193 | # cause us problems for the next few steps. |
6d74e2d7 |
194 | { |
195 | local $@; |
196 | eval { require CPAN::HandleConfig; }; |
197 | # Need newish CPAN.pm for this, ergo skip it if that version of CPAN isn't |
198 | # installed yet. |
199 | # It will already be installed by the time we reach here if bootstrapping, |
200 | # otherwise, if we're running from CPAN then it will be installed soon |
201 | # enough, and we'll come back here.. |
202 | if (!$@) { |
203 | CPAN::HandleConfig->load; |
204 | for my $eumm_setting ( qw/makepl_arg make_install_arg/ ) { |
205 | if ($CPAN::Config->{$eumm_setting} =~ /(?:PREFIX|INSTALL_BASE)/) { |
206 | die "Possibly invalid config detected in $eumm_setting: " . $CPAN::Config->{$eumm_setting}; |
207 | } |
208 | } |
209 | |
210 | for my $mb_setting (qw/mbuild_arg mbuild_install_arg mbuildpl_arg/) { |
211 | if ($CPAN::Config->{$mb_setting} =~ /(?:--prefix|--install_base)/) { |
212 | die "Possibly invalid config detected in $mb_setting: " . $CPAN::Config->{$mb_setting}; |
213 | } |
214 | } |
c4dbb66c |
215 | } |
6d74e2d7 |
216 | else { |
217 | my $error = $@; |
218 | require CPAN; |
219 | # Explode if it looks like requiring CPAN::HandleConfig should |
220 | # have worked, but didn't. |
221 | die($error) if $CPAN::VERSION >= $required_CPAN; |
c4dbb66c |
222 | } |
223 | } |
224 | |
86f54d7f |
225 | if ($bootstrapping) { |
226 | auto_install_now; |
c4dbb66c |
227 | postamble <<"END"; |
228 | PERL += $bootstrapping_args |
229 | FULLPERL += $bootstrapping_args |
230 | END |
86f54d7f |
231 | } else { |
232 | auto_install; |
233 | } |
c4dbb66c |
234 | chdir($cwd); |
391107e5 |
235 | WriteAll; |