Skip to content

Instantly share code, notes, and snippets.

@miyagawa
Created May 30, 2013 09:18
Show Gist options
  • Save miyagawa/5676707 to your computer and use it in GitHub Desktop.
Save miyagawa/5676707 to your computer and use it in GitHub Desktop.
commit 427099d781914dbcb5bf4d85db8bcac9bdf46409
Author: Tatsuhiko Miyagawa <miyagawa@bulknews.net>
Date: Sun Mar 21 06:30:31 2010 -0700
don't bother fixing CPAN if running from cpanminus
diff --git a/Makefile.PL b/Makefile.PL
index 570e362..6c3466f 100644
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -175,24 +175,26 @@ requires 'ExtUtils::Install' => '1.43'; # ditto
requires 'ExtUtils::CBuilder'; # this and ParseXS are needed for MB C_support
requires 'ExtUtils::ParseXS';
requires 'Module::Build' => '0.28'; # lib -> lib/perl5 change
-my $required_CPAN = '1.82';
-requires 'CPAN' => $required_CPAN; # sudo support + CPAN::HandleConfig
-
-# No, really. See
-# https://rt.cpan.org/Public/Bug/Display.html?id=23735
-# for why CPAN now sets the CPANPLUS env var.
-# trouble is this means we can't auto_install(_now) CPAN itself
-# without this beautiful hack
-
-my $no_cpanplus_env = !exists $ENV{PERL5_CPANPLUS_IS_RUNNING};
-my $no_cpan_env = !exists $ENV{PERL5_CPAN_IS_RUNNING};
-require CPAN;
-delete $ENV{PERL5_CPANPLUS_IS_RUNNING} if $no_cpanplus_env;
-delete $ENV{PERL5_CPAN_IS_RUNNING} if $no_cpan_env;
-
-# and make sure that the user doesn't have any existing CPAN config that'll
-# cause us problems for the next few steps.
-{
+
+# don't bother fixing CPAN.pm if bootstrapped from cpanminus
+unless ($ENV{PERL5_CPANM_IS_RUNNING}) {
+ my $required_CPAN = '1.82';
+ requires 'CPAN' => $required_CPAN; # sudo support + CPAN::HandleConfig
+
+ # No, really. See
+ # https://rt.cpan.org/Public/Bug/Display.html?id=23735
+ # for why CPAN now sets the CPANPLUS env var.
+ # trouble is this means we can't auto_install(_now) CPAN itself
+ # without this beautiful hack
+
+ my $no_cpanplus_env = !exists $ENV{PERL5_CPANPLUS_IS_RUNNING};
+ my $no_cpan_env = !exists $ENV{PERL5_CPAN_IS_RUNNING};
+ require CPAN;
+ delete $ENV{PERL5_CPANPLUS_IS_RUNNING} if $no_cpanplus_env;
+ delete $ENV{PERL5_CPAN_IS_RUNNING} if $no_cpan_env;
+
+ # and make sure that the user doesn't have any existing CPAN config that'll
+ # cause us problems for the next few steps.
local $@;
eval { require CPAN::HandleConfig; };
# Need newish CPAN.pm for this, ergo skip it if that version of CPAN isn't
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment