Permalink
Browse files

Fix bootstrapping for older installers

This commit fixes two major installation issues:

1. Perl 5.10.0 has CPANPLUS::Dist::Build that does not execute
Build.PL in a separate process.  This makes bootstrapping
modules from inc/ and then getting CPANPLUS to install dependencies
impossible.  Build.PL now dies with an error if CPANPLUS::Dist::Build
older than 0.08 is detected.

2. The compatibility Makefile did not include the same bootstrapping
code as Build.PL.

Generally, any Perl from 5.10.1 on that respects configure_requires
will have no problem.  This patch is a stopgap to help older Perls.
  • Loading branch information...
1 parent fd41968 commit dae855cb2c74b8b2214cd8f7cc1cddf8157396f6 @xdg xdg committed Jan 26, 2011
Showing with 60 additions and 34 deletions.
  1. +7 −34 Build.PL
  2. +1 −0 MANIFEST
  3. +5 −0 Makefile.PL
  4. +47 −0 inc/bootstrap.pl
View
@@ -1,6 +1,11 @@
use 5.006001;
use strict;
+BEGIN {
+ die "CPANPLUS::Dist::Build version 0.08 or later is required to install Module::Build\n"
+ if $INC{'CPANPLUS/Dist/Build.pm'} && CPANPLUS::Dist::Build->VERSION lt '0.08';
+}
+
# On some platforms (*ahem*, MacPerl 5.6.1) "use lib qw(lib);" doesn't
# find the local "lib" directory, so we use File::Spec to do it properly.
use File::Spec 0.82;
@@ -9,40 +14,8 @@ use lib File::Spec->catdir('lib'); # use our self to install
use lib File::Spec->catdir('t', 'bundled'); # use bundled modules
use lib File::Spec->catdir('t', 'lib'); # our utilities
-my @exit_warn;
-END {
- warn "\nThese additional prerequisites must be installed:\n requires:\n"
- if @exit_warn;
- for my $h ( @exit_warn ) {
- my ($mod, $min) = @$h;
- warn " ! $mod (we need version $min)\n";
- }
-}
-
-# System installed configuration prereqs should take precedence
-BEGIN {
- if ( ! eval "use Perl::OSType 1 (); 1" ) {
- push @exit_warn, [ 'Perl::OSType', '1.00' ];
- delete $INC{'Perl/OSType.pm'};
- eval "require inc::Perl::OSType; 1"
- and $INC{'Perl/OSType.pm'} = {'inc/Perl/OSType.pm'};
- die $@ if $@;
- }
- if ( ! eval "use version 0.87 (); 1" ) {
- push @exit_warn, [ 'version', '0.87' ];
- delete $INC{'version.pm'};
- eval "require inc::MBVersion; 1"
- and $INC{'version.pm'} = {'inc/MBVersion.pm'};
- die $@ if $@;
- }
- if ( ! eval "use Module::Metadata 1.000002 (); 1" ) {
- push @exit_warn, [ 'Module::Metadata', '1.000002' ];
- delete $INC{'Module/Metadata.pm'};
- eval "require inc::Module::Metadata; 1"
- and $INC{'Module/Metadata.pm'} = {'inc/Module/Metadata.pm'};
- die $@ if $@;
- }
-}
+# bootstrap configure_requires prereqs
+BEGIN { do 'inc/bootstrap.pl' }
# We use Module::Build to test & install itself.
use Module::Build;
View
@@ -1,6 +1,7 @@
Build.PL
Changes
contrib/bash_completion.module-build
+inc/bootstrap.pl
inc/MBVersion.pm
inc/Module/Metadata.pm
inc/Perl/OSType.pm
View
@@ -4,7 +4,12 @@
use 5.006001;
+
use lib qw(lib);
+
+# bootstrap configure_requires prereqs
+BEGIN { do 'inc/bootstrap.pl' or die defined($@) ? $@ : $! }
+
use Module::Build::Compat;
Module::Build::Compat->run_build_pl(args => \@ARGV);
View
@@ -0,0 +1,47 @@
+# bootstrap.pl
+# bootstrap modules in inc/ for use during configuration with
+# either Build.PL or Makefile.PL
+
+my @exit_warn;
+
+END {
+ warn "\nThese additional prerequisites must be installed:\n requires:\n"
+ if @exit_warn;
+ while( my $h = shift @exit_warn ) {
+ my ($mod, $min) = @$h;
+ warn " ! $mod (we need version $min)\n";
+ }
+}
+
+BEGIN {
+ if ( ! eval "use Perl::OSType 1 (); 1" ) {
+ print "*** BOOTSTRAPPING Perl::OSType ***\n";
+ push @exit_warn, [ 'Perl::OSType', '1.00' ];
+ delete $INC{'Perl/OSType.pm'};
+ local @INC = @INC;
+ push @INC, 'inc';
+ eval "require Perl::OSType; 1"
+ or die "BOOSTRAP FAIL: $@";
+ }
+ if ( ! eval "use version 0.87 (); 1" ) {
+ print "*** BOOTSTRAPPING version ***\n";
+ push @exit_warn, [ 'version', '0.87' ];
+ delete $INC{'version.pm'};
+ local @INC = @INC;
+ push @INC, 'inc';
+ eval "require MBVersion; 1"
+ or die "BOOSTRAP FAIL: $@";
+ }
+ if ( ! eval "use Module::Metadata 1.000002 (); 1" ) {
+ print "*** BOOTSTRAPPING Module::Metadata ***\n";
+ push @exit_warn, [ 'Module::Metadata', '1.000002' ];
+ delete $INC{'Module/Metadata.pm'};
+ local @INC = @INC;
+ push @INC, 'inc';
+ eval "require Module::Metadata; 1"
+ or die "BOOSTRAP FAIL: $@";
+ }
+}
+
+1;
+

0 comments on commit dae855c

Please sign in to comment.