sync blead with Update Archive::Extract 0.34
[p5sagit/p5-mst-13.2.git] / lib / CPAN.pm
index 9b5e0b3..1196cb0 100644 (file)
@@ -2,7 +2,7 @@
 # vim: ts=4 sts=4 sw=4:
 use strict;
 package CPAN;
-$CPAN::VERSION = '1.93_51';
+$CPAN::VERSION = '1.9402';
 $CPAN::VERSION =~ s/_//;
 
 # we need to run chdir all over and we would get at wrong libraries
@@ -25,7 +25,7 @@ use CPAN::Debug;
 use CPAN::Distribution;
 use CPAN::Distrostatus;
 use CPAN::FTP;
-use CPAN::Index;
+use CPAN::Index 1.93; # https://rt.cpan.org/Ticket/Display.html?id=43349
 use CPAN::InfoObj;
 use CPAN::Module;
 use CPAN::Prompt;
@@ -248,7 +248,7 @@ sub soft_chdir_with_alternatives ($);
 sub _uniq {
     my(@list) = @_;
     my %seen;
-    return map { !$seen{$_} } @list;
+    return grep { !$seen{$_}++ } @list;
 }
 
 #-> sub CPAN::shell ;
@@ -313,7 +313,7 @@ sub shell {
         $CPAN::Frontend->myprint(
                                  sprintf qq{
 cpan shell -- CPAN exploration and modules installation (v%s)
-ReadLine support %s
+Enter 'h' for help.
 
 },
                                  $CPAN::VERSION,
@@ -351,7 +351,8 @@ ReadLine support %s
         } elsif (/^\!/) {
             s/^\!//;
             my($eval) = $_;
-            package CPAN::Eval;
+            package
+                CPAN::Eval; # hide from the indexer
             use strict;
             use vars qw($import_done);
             CPAN->import(':DEFAULT') unless $import_done++;
@@ -373,14 +374,22 @@ ReadLine support %s
                 @line = _redirect(@line);
                 CPAN::Shell->$command(@line)
               };
+            my $command_error = $@;
             _unredirect;
-            if ($@) {
-                my $err = "$@";
-                if ($err =~ /\S/) {
-                    require Carp;
-                    require Dumpvalue;
-                    my $dv = Dumpvalue->new(tick => '"');
-                    Carp::cluck(sprintf "Catching error: %s", $dv->stringify($err));
+            my $reported_error;
+            if ($command_error) {
+                my $err = $command_error;
+                if (ref $err and $err->isa('CPAN::Exception::blocked_urllist')) {
+                    $CPAN::Frontend->mywarn("Client not fully configured, please proceed with configuring.$err");
+                    $reported_error = ref $err;
+                } else {
+                    # I'd prefer never to arrive here and make all errors exception objects
+                    if ($err =~ /\S/) {
+                        require Carp;
+                        require Dumpvalue;
+                        my $dv = Dumpvalue->new(tick => '"');
+                        Carp::cluck(sprintf "Catching error: %s", $dv->stringify($err));
+                    }
                 }
             }
             if ($command =~ /^(
@@ -400,7 +409,13 @@ ReadLine support %s
                              |upgrade
                             )$/x) {
                 # only commands that tell us something about failed distros
-                CPAN::Shell->failed($CPAN::CurrentCommandId,1);
+                # eval necessary for people without an urllist
+                eval {CPAN::Shell->failed($CPAN::CurrentCommandId,1);};
+                if (my $err = $@) {
+                    unless (ref $err and $reported_error eq ref $err) {
+                        die $@;
+                    }
+                }
             }
             soft_chdir_with_alternatives(\@cwd);
             $CPAN::Frontend->myprint("\n");
@@ -992,12 +1007,16 @@ sub has_usable {
                                   ],
                'Archive::Tar' => [
                                   sub {require Archive::Tar;
-                                       unless (CPAN::Version->vge(Archive::Tar::->VERSION, 1.00)) {
+                                       unless (CPAN::Version->vge(Archive::Tar::->VERSION, 1.50)) {
                                             for ("Will not use Archive::Tar, need 1.00\n") {
                                                 $CPAN::Frontend->mywarn($_);
                                                 die $_;
                                             }
                                        }
+                                       unless (CPAN::Version->vge(Archive::Tar::->VERSION, 1.50)) {
+                                            my $atv = Archive::Tar->VERSION;
+                                            $CPAN::Frontend->mywarn("You have Archive::Tar $atv, but 1.50 or later is recommended. Please upgrade.\n");
+                                       }
                                   },
                                  ],
                'File::Temp' => [
@@ -2097,7 +2116,7 @@ C<ask/no>, CPAN.pm asks the user and sets the default accordingly.
 still considered beta quality)
 
 Distributions on CPAN usually behave according to what we call the
-CPAN mantra. Or since the event of Module::Build, we should talk about
+CPAN mantra. Or since the advent of Module::Build we should talk about
 two mantras:
 
     perl Makefile.PL     perl Build.PL
@@ -3441,8 +3460,7 @@ You will most probably also want to configure something like this:
                     INSTALLSCRIPT=~/myperl/bin \
                     INSTALLBIN=~/myperl/bin"
 
-and then (oh joy) the equivalent command for Module::Build. That would
-be
+and then the equivalent command for Module::Build, which is
 
   o conf mbuildpl_arg "--lib=~/myperl/lib \
                     --installman1dir=~/myperl/man/man1 \