5 use vars qw($bootstrapping $bootstrapping_args $no_manpages);
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
19 if($^O eq 'solaris') {
21 for my $env_path (split /:/, $ENV{PATH}) {
22 $have_gtar = 1 if -x File::Spec->catfile($env_path, 'gtar');
27 if(exists $ENV{PERL_LL_TAR}) {
28 $have_gtar ||= -x $ENV{PERL_LL_TAR};
31 die <<'DEATH' unless $have_gtar;
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
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 # the fancy dash is U+2212 or \xE2\x88\x92
49 if(grep { /\xE2\x88\x92/ } @ARGV or grep { /−/ } @ARGV) {
51 WHOA THERE! It looks like you've got some fancy dashes in your commandline!
52 These are *not* the traditional -- dashes that software recognizes. You
53 probably got these by copy-pasting from the perldoc for this module as
54 rendered by a UTF8-capable formatter. This most typically happens on an OS X
55 terminal, but can happen elsewhere too. Please try again after replacing the
56 dashes with normal minus signs.
59 if (my ($x) = grep { /^--bootstrap(?:=.*)?$/ } @ARGV) {
60 @ARGV = grep { !/^--bootstrap(?:=.*)?$/ } @ARGV;
62 if(my ($x) = grep { /^--no-manpages/ } @ARGV) {
64 @ARGV = grep { !/^--no-manpages/ } @ARGV;
66 my ($path) = $x =~ /^--bootstrap(?:=(.*))?$/;
67 my @args = $path ? $path : ();
75 local::lib->import(@args);
77 my @libs = map { "-I$_" } split $Config{path_sep}, $ENV{PERL5LIB};
78 $bootstrapping_args = "@libs";
79 push(@ARGV,$ENV{PERL_MM_OPT});
82 # <mst> GODDAMN makepl_arg INSTALLDIRS=site
83 # <mst> we must set PERL_AUTOINSTALL_PREFER_CPAN too
84 $ENV{PERL_AUTOINSTALL_PREFER_CPAN} = 1;
86 system($^X, '-MExtUtils::MakeMaker 6.74', '-e1');
89 system($^X, '-MExtUtils::Install 1.43', '-e1');
92 system($^X, '-MModule::Build 0.36', '-e1');
95 system($^X, '-MCPAN 1.82', '-e1');
97 my $cpan_command = '';
99 my $did_cpan_config = 0;
100 my $cpan_config_command =
101 'my $done; require ExtUtils::MakeMaker;
102 my $orig = ExtUtils::MakeMaker->can("prompt");
103 *ExtUtils::MakeMaker::prompt = sub ($;$) {
104 if (!$done && $_[0] =~ /manual configuration/) {
110 # not yet -- apeiron, 2010-03-10
111 #$CPAN::Config->{urllist} = ["http://cpan.shadowcatprojects.net"];
112 # <mst> all bootstrapped fine on one DH account
113 # <mst> on another, it tries to install man stuff into /usr/local
114 # <mst> cannot for the life of me figure out why
115 # <mst> (same fucking server as well)
116 # <mst> GOT THE BASTARD
117 # <mst> ExtUtils::ParseXS uses Module::Build
118 # <mst> but Module::Build depends on it
119 # <mst> so you need to set prefer_installer MM
120 # <mst> so cpan uses EU::ParseXS Makefile.PL
121 # <mst> since we already got EUMM, *that* works
122 $CPAN::Config->{prefer_installer} = "EUMM";
124 unless ($done || -w $CPAN::Config->{keep_source_where}) {
125 my $save = $CPAN::Config->{urllist};
126 delete @{$CPAN::Config}{keys %$CPAN::Config};
127 $CPAN::Config->{urllist} = $save;
131 $ENV{PERL_MM_USE_DEFAULT} = 1;
133 # XXX - remove the force on EUMM once its test suite survive PERL_MM_OPT
135 if ($eumm) { # non-zero exit
136 $cpan_command .= 'force("install","ExtUtils::MakeMaker"); ';
139 $cpan_command .= 'install("ExtUtils::Install"); ';
142 $cpan_command .= 'install("Module::Build"); ';
145 $cpan_command .= 'force("install","CPAN"); ';
147 if(length $cpan_command) {
148 system($^X, '-MCPAN', '-e', $cpan_config_command);
150 system($^X, '-MCPAN', '-e', $cpan_command);
153 system($^X, '-MCPAN', '-e', 'CPAN::Config->load; CPAN::Config->commit;');
156 # if we call this code directly, the changes get written to
157 # $BOOTSTRAP/lib/perl5/CPAN/Config.pm, not where the user expects them to
158 # be in their ~/.cpan/CPAN/MyConfig.pm.
159 system($^X, '-MCPAN', '-e', $cpan_config_command)
160 unless $did_cpan_config;
161 system($^X, '-MCPAN',
163 q[CPAN::HandleConfig->load;],
165 q[$CPAN::Config->{makepl_arg} = ] .
166 q['INSTALLMAN1DIR=none INSTALLMAN3DIR=none';],
168 q[$CPAN::Config->{buildpl_arg} = ] .
169 q['--install_path libdoc="" --install_path bindoc=""';],
171 q[CPAN::Config->commit;],
179 require ExtUtils::MakeMaker;
180 ExtUtils::MakeMaker->import;
181 (do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml';
183 my %CONFIGURE_DEPS = ();
189 'ExtUtils::MakeMaker' => '6.74', # version PERL_MM_OPT is shell parsed
190 'ExtUtils::Install' => '1.43', # version INSTALL_BASE was added
191 'Module::Build' => '0.36', # PERL_MB_OPT
192 'CPAN' => '1.82', # sudo support + CPAN::HandleConfig
196 'meta-spec' => { version => 2 },
199 # r/w: p5sagit@git.shadowcat.co.uk:local-lib.git
200 url => 'git://git.shadowcat.co.uk/p5sagit/local-lib.git',
201 web => 'http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=p5sagit/local-lib.git',
204 x_IRC => 'irc://irc.perl.org/#local-lib',
206 web => 'https://rt.cpan.org/Public/Dist/Display.html?Name=local-lib',
207 mailto => 'bug-local-lib@rt.cpan.org',
209 license => [ 'http://dev.perl.org/licenses/' ],
212 runtime => { requires => { perl => '5.8.1' } },
216 if ($bootstrapping) {
218 *MY::postamble = sub {
220 PERL += $bootstrapping_args
221 FULLPERL += $bootstrapping_args
226 # don't bother fixing CPAN.pm if bootstrapped from cpanminus
227 if ($ENV{PERL5_CPANM_IS_RUNNING}) {
228 delete $RUN_DEPS{CPAN};
232 # https://rt.cpan.org/Public/Bug/Display.html?id=23735
233 # for why CPAN now sets the CPANPLUS env var.
234 # trouble is this means we can't auto_install(_now) CPAN itself
235 # without this beautiful hack
237 my $no_cpanplus_env = !exists $ENV{PERL5_CPANPLUS_IS_RUNNING};
238 my $no_cpan_env = !exists $ENV{PERL5_CPAN_IS_RUNNING};
240 delete $ENV{PERL5_CPANPLUS_IS_RUNNING} if $no_cpanplus_env;
241 delete $ENV{PERL5_CPAN_IS_RUNNING} if $no_cpan_env;
243 # and make sure that the user doesn't have any existing CPAN config that'll
244 # cause us problems for the next few steps.
246 eval { require CPAN::HandleConfig; };
247 # Need newish CPAN.pm for this, ergo skip it if that version of CPAN isn't
249 # It will already be installed by the time we reach here if bootstrapping,
250 # otherwise, if we're running from CPAN then it will be installed soon
251 # enough, and we'll come back here..
253 CPAN::HandleConfig->require_myconfig_or_config;
254 if ( $CPAN::Config ) {
256 makepl_arg make_install_arg
257 mbuild_arg mbuild_install_arg mbuildpl_arg
259 my $value = $CPAN::Config->{$setting} or next;
260 if ($setting =~ /^make/
261 ? $value =~ /(?:PREFIX|INSTALL_BASE)/
262 : $value =~ /(?:--prefix|--install_base)/
265 WHOA THERE! It looks like you've got $CPAN::Config->{$setting} set in
266 your CPAN config. This is known to cause problems with local::lib. Please
267 either remove this setting or clear out your .cpan directory.
276 # Explode if it looks like requiring CPAN::HandleConfig should
277 # have worked, but didn't.
278 die($error) if $CPAN::VERSION >= $RUN_DEPS{CPAN};
283 @{$extra_info{prereqs}{runtime}{requires}}{keys %RUN_DEPS} = values %RUN_DEPS;
285 # have to do this since old EUMM dev releases miss the eval $VERSION line
286 my $eumm_version = eval $ExtUtils::MakeMaker::VERSION;
287 my $mymeta_works = $eumm_version >= 6.57_07;
288 my $mymeta = $eumm_version >= 6.57_02;
290 my $has_test_requires = $eumm_version >= 6.63_03;
292 my $has_meta_v2 = $eumm_version >= 6.57_10;
293 if (! $has_meta_v2) {
296 if (not $has_test_requires) {
297 %BUILD_DEPS = (%BUILD_DEPS, %TEST_DEPS);
300 if (not $mymeta_works) {
301 %RUN_DEPS = (%RUN_DEPS, %BUILD_DEPS);
306 NAME => 'local::lib',
307 VERSION_FROM => 'lib/local/lib.pm',
308 CONFIGURE_REQUIRES => \%CONFIGURE_DEPS,
312 keys %BUILD_DEPS ? ( BUILD_REQUIRES => \%BUILD_DEPS ) : (),
313 keys %TEST_DEPS ? ( TEST_REQUIRES => \%TEST_DEPS ) : (),
314 META_ADD => \%extra_info,
317 directory => [ 'xt' ]
320 ($mymeta && !$mymeta_works ? (NO_MYMETA => 1) : ()),