This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make spelling of values for 'FILES' consistent
[perl5.git] / Porting / bisect.pl
index 6e78247..82b9ae7 100755 (executable)
@@ -17,19 +17,28 @@ my ($start, $end, $validate, $usage, $bad, $jobs, $make, $gold,
     $module, $with_module);
 
 my $need_cpan_config;
+my $cpan_config_dir;
 
 $bad = !GetOptions('start=s' => \$start, 'end=s' => \$end,
                    'jobs|j=i' => \$jobs, 'make=s' => \$make, 'gold=s' => \$gold,
                    validate => \$validate, 'usage|help|?' => \$usage,
-                   'module=s' => \$module, 'with-module=s' => \$with_module);
+                   'module=s' => \$module, 'with-module=s' => \$with_module,
+                   'cpan-config-dir=s' => \$cpan_config_dir);
 unshift @ARGV, '--help' if $bad || $usage;
 unshift @ARGV, '--validate' if $validate;
 
 if ($module || $with_module) {
-  $need_cpan_config = 1;
-
   unshift @ARGV, '--module', $module if defined $module;
   unshift @ARGV, '--with-module', $with_module if defined $with_module;
+
+  if ($cpan_config_dir) {
+    my $c = File::Spec->catfile($cpan_config_dir, 'CPAN', 'MyConfig.pm');
+    die "--cpan-config-dir: $c does not exist\n" unless -e $c;
+
+    unshift @ARGV, '--cpan-config-dir', $cpan_config_dir;
+  } else {
+    $need_cpan_config = 1;
+  }
 }
 
 my $runner = $0;
@@ -52,8 +61,10 @@ if (!defined $jobs &&
         while (<$fh>) {
             ++$cpus if /^processor\s+:\s+\d+$/;
         }
-    } elsif (-x '/sbin/sysctl') {
-        $cpus =  $1 if `/sbin/sysctl hw.ncpu` =~ /^hw\.ncpu: (\d+)$/;
+    } elsif (-x '/sbin/sysctl' || -x '/usr/sbin/sysctl') {
+        my $sysctl =  '/sbin/sysctl';
+        $sysctl =  "/usr$sysctl" unless -x $sysctl;
+        $cpus =  $1 if `$sysctl hw.ncpu` =~ /^hw\.ncpu: (\d+)$/;
     } elsif (-x '/usr/bin/getconf') {
         $cpus = $1 if `/usr/bin/getconf _NPROCESSORS_ONLN` =~ /^(\d+)$/;
     }
@@ -75,30 +86,12 @@ if ($need_cpan_config) {
 I could not find a CPAN::MyConfig. We need to create one now so that
 you can bisect with --module or --with-module. I'll boot up the CPAN
 shell for you. Feel free to use defaults or change things as needed.
+We recommend using 'manual' over 'local::lib' if it asks.
+
 Type 'quit' when finished.
+
 EOF
     system("$^X -MCPAN -e shell");
-
-    # mkpath for older File::Spec support (5.8.8, etc)
-    eval { mkpath($cdir); };
-    die "Failed to mkdir $cdir: $@\n" if $@;
-
-    open (my $fh, '>', $cfile)
-      || die "Could not open $cfile for writing: $!\n";
-
-    my $data = `$^X -mCPAN -MData::Dumper -e 'CPAN::Config->load;
-                print Dumper(\$CPAN::Config)' 2>/dev/null`;
-
-    # Replace $VAR1 = { with $CPAN::Config = {
-    unless ($data =~ s/^.*\$VAR1\s+=\s+{/\$CPAN::Config = {/s) {
-      die "CPAN::Config does not look right, can't continue.\n",
-          "Try creating a CPAN::MyConfig manually.\n",
-          "The unrecognized output was: $data";
-    }
-
-    print $fh $data;
-    print $fh "\n1;\n";
-    close $data;
   }
 }