SYN SYN
[p5sagit/p5-mst-13.2.git] / lib / CPAN / FirstTime.pm
index 0e795da..9f8366e 100644 (file)
@@ -16,7 +16,7 @@ use FileHandle ();
 use File::Basename ();
 use File::Path ();
 use vars qw($VERSION);
-$VERSION = substr q$Revision: 1.38 $, 10;
+$VERSION = substr q$Revision: 1.46 $, 10;
 
 =head1 NAME
 
@@ -149,7 +149,7 @@ next question.
     print qq{
 
 How big should the disk cache be for keeping the build directories
-with all the intermediate files?
+with all the intermediate files\?
 
 };
 
@@ -174,6 +174,20 @@ disable the cache scanning with 'never'.
     } while ($ans ne 'atstart' && $ans ne 'never');
     $CPAN::Config->{scan_cache} = $ans;
 
+    print qq{
+
+To considerably speed up the initial CPAN shell startup, it is
+possible to use Storable to create a cache of metadata. If Storable
+is not available, the normal index mechanism will be used.
+
+};
+
+    defined($default = $CPAN::Config->{cache_metadata}) or $default = 1;
+    do {
+        $ans = prompt("Cache metadata (yes/no)?", ($default ? 'yes' : 'no'));
+    } while ($ans !~ /^\s*[yn]/i);
+    $CPAN::Config->{cache_metadata} = ($ans =~ /^\s*y/i ? 1 : 0);
+
     #
     # prerequisites_policy
     # Do we follow PREREQ_PM?
@@ -188,7 +202,7 @@ policy to one of the three values.
 
 };
 
-    $default = $CPAN::Config->{prerequisites_policy} || 'follow';
+    $default = $CPAN::Config->{prerequisites_policy} || 'ask';
     do {
       $ans =
          prompt("Policy on building prerequisites (follow, ask or ignore)?",
@@ -361,7 +375,8 @@ sub conf_sites {
     File::Copy::copy($m,$mby) or die "Could not update $mby: $!";
   }
   my $loopcount = 0;
-  while () {
+  local $^T = time;
+  while ($mby) {
     if ( ! -f $mby ){
       print qq{You have no $mby
   I\'m trying to fetch one
@@ -383,6 +398,7 @@ sub conf_sites {
     }
   }
   read_mirrored_by($mby);
+  bring_your_own();
 }
 
 sub find_exe {
@@ -424,7 +440,7 @@ sub picklist {
 }
 
 sub read_mirrored_by {
-    my($local) = @_;
+    my $local = shift or return;
     my(%all,$url,$expected_size,$default,$ans,$host,$dst,$country,$continent,@location);
     my $fh = FileHandle->new;
     $fh->open($local) or die "Couldn't open $local: $!";
@@ -512,25 +528,33 @@ http: -- that host a CPAN mirror.
 
     @urls = picklist (\@urls, $prompt, $default);
     foreach (@urls) { s/ \(.*\)//; }
-    %seen = map (($_ => 1), @urls);
+    push @{$CPAN::Config->{urllist}}, @urls;
+}
 
+sub bring_your_own {
+    my %seen = map (($_ => 1), @{$CPAN::Config->{urllist}});
+    my($ans,@urls);
     do {
-        $ans = prompt ("Enter another URL or RETURN to quit:", "");
+       my $prompt = "Enter another URL or RETURN to quit:";
+       unless (%seen) {
+           $prompt = qq{CPAN.pm needs at least one URL where it can fetch CPAN files from.
+
+Please enter your CPAN site:};
+       }
+        $ans = prompt ($prompt, "");
 
         if ($ans) {
-            $ans =~ s|/?$|/|; # has to end with one slash
+            $ans =~ s|/?\z|/|; # has to end with one slash
             $ans = "file:$ans" unless $ans =~ /:/; # without a scheme is a file:
             if ($ans =~ /^\w+:\/./) {
-               push @urls, $ans 
-                  unless $seen{$ans};
-            }
-            else {
+               push @urls, $ans unless $seen{$ans}++;
+            } else {
                 print qq{"$ans" doesn\'t look like an URL at first sight.
 I\'ll ignore it for now.  You can add it to $INC{'CPAN/MyConfig.pm'}
 later if you\'re sure it\'s right.\n};
             }
         }
-    } while $ans;
+    } while $ans || !%seen;
 
     push @{$CPAN::Config->{urllist}}, @urls;
     # xxx delete or comment these out when you're happy that it works