fix perl prereq in Makefile.PL
[p5sagit/local-lib.git] / Makefile.PL
index 4dc9ce0..8b045aa 100644 (file)
@@ -189,6 +189,7 @@ my %RUN_DEPS = (
   'ExtUtils::MakeMaker' => '6.74', # version PERL_MM_OPT is shell parsed
   'ExtUtils::Install'   => '1.43', # version INSTALL_BASE was added
   'Module::Build'       => '0.36', # PERL_MB_OPT
+  'CPAN'                => '1.82', # sudo support + CPAN::HandleConfig
 );
 
 my %extra_info = (
@@ -208,7 +209,7 @@ my %extra_info = (
     license => [ 'http://dev.perl.org/licenses/' ],
   },
   prereqs => {
-    runtime   => { requires => { %RUN_DEPS, perl => '5.8.1' } },
+    runtime   => { requires => { perl => '5.6.0' } },
   },
 );
 
@@ -223,10 +224,10 @@ END
 }
 
 # don't bother fixing CPAN.pm if bootstrapped from cpanminus
-unless ($ENV{PERL5_CPANM_IS_RUNNING}) {
-    my $required_CPAN = '1.82';
-    $RUN_DEPS{'CPAN'} = $required_CPAN; # sudo support + CPAN::HandleConfig
-
+if ($ENV{PERL5_CPANM_IS_RUNNING}) {
+    delete $RUN_DEPS{CPAN};
+}
+else {
     # No, really. See
     # https://rt.cpan.org/Public/Bug/Display.html?id=23735
     # for why CPAN now sets the CPANPLUS env var.
@@ -258,7 +259,7 @@ unless ($ENV{PERL5_CPANM_IS_RUNNING}) {
                 my $value = $CPAN::Config->{$setting} or next;
                 if ($setting =~ /^make/
                   ? $value =~ /(?:PREFIX|INSTALL_BASE)/
-                  : /(?:--prefix|--install_base)/
+                  : $value =~ /(?:--prefix|--install_base)/
                 ) {
                     die <<"DEATH";
 WHOA THERE! It looks like you've got $CPAN::Config->{$setting} set in
@@ -274,18 +275,21 @@ DEATH
         require CPAN;
         # Explode if it looks like requiring CPAN::HandleConfig should
         # have worked, but didn't.
-        die($error) if $CPAN::VERSION >= $required_CPAN;
+        die($error) if $CPAN::VERSION >= $RUN_DEPS{CPAN};
     }
 }
 chdir($cwd);
 
+@{$extra_info{prereqs}{runtime}{requires}}{keys %RUN_DEPS} = values %RUN_DEPS;
+
 # have to do this since old EUMM dev releases miss the eval $VERSION line
-my $mymeta_works = do { no warnings; $ExtUtils::MakeMaker::VERSION >= 6.57_07 };
-my $mymeta = do { no warnings; $ExtUtils::MakeMaker::VERSION >= 6.57_02 };
+my $eumm_version = eval $ExtUtils::MakeMaker::VERSION;
+my $mymeta_works = $eumm_version >= 6.57_07;
+my $mymeta = $eumm_version >= 6.57_02;
 
-my $has_test_requires = do { no warnings; $ExtUtils::MakeMaker::VERSION >= 6.63_03 };
+my $has_test_requires = $eumm_version >= 6.63_03;
 
-my $has_meta_v2 = do { no warnings; $ExtUtils::MakeMaker::VERSION >= 6.57_10 };
+my $has_meta_v2 = $eumm_version >= 6.57_10;
 if (! $has_meta_v2) {
   %extra_info = ();
 }
@@ -305,8 +309,8 @@ WriteMakefile(
   PREREQ_PM => {
     %RUN_DEPS,
   },
-  keys %BUILD_DEPS ? ( BUILD_REQUIRES => \%BUILD_DEPS ) : (),
-  keys %TEST_DEPS ? ( TEST_REQUIRES => \%TEST_DEPS ) : (),
+  BUILD_REQUIRES => \%BUILD_DEPS,
+  TEST_REQUIRES => \%TEST_DEPS,
   META_ADD => \%extra_info,
   META_MERGE => {
     no_index => {