This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Updates CPAN.pm to ANDK/CPAN-2.21-TRIAL.tar.gz
authorAndreas Koenig <root@dubravka.in-berlin.de>
Thu, 27 Sep 2018 06:06:34 +0000 (06:06 +0000)
committerJames E Keenan <jkeenan@cpan.org>
Thu, 27 Sep 2018 11:55:04 +0000 (07:55 -0400)
Porting/Maintainers.pl
cpan/CPAN/lib/App/Cpan.pm
cpan/CPAN/lib/CPAN.pm
cpan/CPAN/lib/CPAN/Distribution.pm
cpan/CPAN/lib/CPAN/Mirrors.pm
cpan/CPAN/lib/CPAN/Plugin.pm
cpan/CPAN/lib/CPAN/Shell.pm

index 6d8a900..c23af8d 100755 (executable)
@@ -246,7 +246,7 @@ use File::Glob qw(:case);
     },
 
     'CPAN' => {
-        'DISTRIBUTION' => 'ANDK/CPAN-2.20-TRIAL.tar.gz',
+        'DISTRIBUTION' => 'ANDK/CPAN-2.21-TRIAL.tar.gz',
         'FILES'        => q[cpan/CPAN],
         'EXCLUDED'     => [
             qr{^distroprefs/},
index 8754912..ddf492b 100644 (file)
@@ -6,7 +6,7 @@ use vars qw($VERSION);
 
 use if $] < 5.008 => 'IO::Scalar';
 
-$VERSION = '1.67';
+$VERSION = '1.671';
 
 =head1 NAME
 
@@ -120,6 +120,8 @@ Load the file that has the CPAN configuration data. This should have the
 same format as the standard F<CPAN/Config.pm> file, which defines
 C<$CPAN::Config> as an anonymous hash.
 
+If the file does not exist, C<cpan> dies.
+
 =item -J
 
 Dump the configuration in the same format that CPAN.pm uses. This is useful
@@ -289,7 +291,7 @@ use CPAN 1.80 (); # needs no test
 use Config;
 use autouse Cwd => qw(cwd);
 use autouse 'Data::Dumper' => qw(Dumper);
-use File::Spec::Functions;
+use File::Spec::Functions qw(catfile file_name_is_absolute rel2abs);
 use File::Basename;
 use Getopt::Std;
 
@@ -1101,12 +1103,14 @@ sub _shell
 
 sub _load_config # -j
        {
-       my $file = shift || '';
+       my $argument = shift;
+
+       my $file = file_name_is_absolute( $argument ) ? $argument : rel2abs( $argument );
+       croak( "cpan config file [$file] for -j does not exist!\n" ) unless -e $file;
 
        # should I clear out any existing config here?
        $CPAN::Config = {};
        delete $INC{'CPAN/Config.pm'};
-       croak( "Config file [$file] does not exist!\n" ) unless -e $file;
 
        my $rc = eval "require '$file'";
 
@@ -1165,9 +1169,9 @@ sub _download
 
                $logger->debug( "Inst file would be $path\n" );
 
-               $paths{$arg} = _get_file( _make_path( $path ) );
+               $paths{$module} = _get_file( _make_path( $path ) );
 
-               $logger->info( "Downloaded [$arg] to [$paths{$module}]" );
+               $logger->info( "Downloaded [$arg] to [$paths{$arg}]" );
                }
 
        return \%paths;
@@ -1191,7 +1195,9 @@ sub _get_file
                {
                my $fetch_path = join "/", $site, $path;
                $logger->debug( "Trying $fetch_path" );
-           last if LWP::Simple::getstore( $fetch_path, $store_path );
+               my $status_code = LWP::Simple::getstore( $fetch_path, $store_path );
+               last if( 200 <= $status_code and $status_code <= 300 );
+               $logger->warn( "Could not get [$fetch_path]: Status code $status_code" );
                }
 
        return $store_path;
@@ -1679,13 +1685,15 @@ where this script ends up with a .bat extension
 
 David Golden helps integrate this into the C<CPAN.pm> repos.
 
+Jim Keenan fixed up various issues with _download
+
 =head1 AUTHOR
 
 brian d foy, C<< <bdfoy@cpan.org> >>
 
 =head1 COPYRIGHT
 
-Copyright (c) 2001-2015, brian d foy, All Rights Reserved.
+Copyright (c) 2001-2018, brian d foy, All Rights Reserved.
 
 You may redistribute this under the same terms as Perl itself.
 
index 1f69119..dd86f26 100644 (file)
@@ -2,7 +2,7 @@
 # vim: ts=4 sts=4 sw=4:
 use strict;
 package CPAN;
-$CPAN::VERSION = '2.20';
+$CPAN::VERSION = '2.21';
 $CPAN::VERSION =~ s/_//;
 
 # we need to run chdir all over and we would get at wrong libraries
@@ -284,7 +284,7 @@ sub shell {
         }
         if (my $histfile = $CPAN::Config->{'histfile'}) {{
             unless ($term->can("AddHistory")) {
-                $CPAN::Frontend->mywarn("Terminal does not support AddHistory.\n");
+                $CPAN::Frontend->mywarn("Terminal does not support AddHistory.\n\nTo fix enter>  install Term::ReadLine::Perl\n\n");
                 last;
             }
             $META->readhist($term,$histfile);
@@ -488,7 +488,7 @@ Trying '$root' as temporary haven.
         push @$cwd, $root;
     }
     while () {
-        if (chdir $cwd->[0]) {
+        if (chdir "$cwd->[0]") {
             return;
         } else {
             if (@$cwd>1) {
index 72101af..36f4951 100644 (file)
@@ -8,7 +8,7 @@ use CPAN::InfoObj;
 use File::Path ();
 @CPAN::Distribution::ISA = qw(CPAN::InfoObj);
 use vars qw($VERSION);
-$VERSION = "2.19";
+$VERSION = "2.21";
 
 # no prepare, because prepare is not a command on the shell command line
 # TODO: clear instance cache on reload
@@ -559,7 +559,8 @@ See also http://rt.cpan.org/Ticket/Display.html?id=38932\n");
         $CPAN::Frontend->mydie("Cannot create directory $builddir: $@");
     }
     my $packagedir;
-    my $eexist = $CPAN::META->has_usable("Errno") ? &Errno::EEXIST : undef;
+    my $eexist = ($CPAN::META->has_usable("Errno") && defined &Errno::EEXIST)
+        ? &Errno::EEXIST : undef;
     for(my $suffix = 0; ; $suffix++) {
         $packagedir = File::Spec->catdir($builddir, "$tdir_base-$suffix");
         my $parent = $builddir;
@@ -1658,7 +1659,7 @@ sub force {
   my $methodmatch = 0;
   my $ldebug = 0;
  PHASE: for my $phase (qw(unknown get make test install)) { # order matters
-      $methodmatch = 1 if $fforce || $phase eq $method;
+      $methodmatch = 1 if $fforce || ($method && $phase eq $method);
       next unless $methodmatch;
     ATTRIBUTE: for my $att (@{$phase_map{$phase}}) {
           if ($phase eq "get") {
@@ -1721,14 +1722,20 @@ sub isa_perl {
   my $file = File::Basename::basename($self->id);
   if ($file =~ m{ ^ perl
                   (
-                   -5\.\d+\.\d+
+                   -(5\.\d+\.\d+)
                    |
-                   5[._-]00[0-5](_[0-4][0-9])?
+                   (5)[._-](00[0-5](?:_[0-4][0-9])?)
                   )
                   \.tar[._-](?:gz|bz2)
                   (?!\n)\Z
                 }xs) {
-    return "$1.$3";
+    my $perl_version;
+    if ($2) {
+        $perl_version = $2;
+    } else {
+        $perl_version = "$3.$4";
+    }
+    return $perl_version;
   } elsif ($self->cpan_comment
            &&
            $self->cpan_comment =~ /isa_perl\(.+?\)/) {
@@ -2898,8 +2905,10 @@ sub unsat_prereq {
                 next NEED;
             }
 
+            my $sufficient_file = exists $prereq_pm->{requires}{$need_module}
+                ? $inst_file : $available_file;
             # if they have not specified a version, we accept any installed one
-            if ( $available_file
+            if ( $sufficient_file
                 and ( # a few quick short circuits
                      not defined $need_version
                      or $need_version eq '0'    # "==" would trigger warning when not numeric
@@ -3491,8 +3500,21 @@ sub _exe_files {
     if (-f $buildparams) {
         CPAN->debug("Found '$buildparams'") if $CPAN::DEBUG;
         my $x = do $buildparams;
-        for my $sf (@{$x->[2]{script_files} || []}) {
-            push @exe_files, $sf;
+        for my $sf ($x->[2]{script_files}) {
+            if (my $reftype = ref $sf) {
+                if ($reftype eq "ARRAY") {
+                    push @exe_files, @$sf;
+                }
+                elsif ($reftype eq "HASH") {
+                    push @exe_files, keys %$sf;
+                }
+                else {
+                    $CPAN::Frontend->mywarn("Invalid reftype $reftype for Build.PL 'script_files'\n");
+                }
+            }
+            elsif (defined $sf) {
+                push @exe_files, $sf;
+            }
         }
     }
     return \@exe_files;
@@ -3773,7 +3795,7 @@ sub clean {
             push @e, "make clean already called once";
         $CPAN::Frontend->myprint(join "", map {"  $_\n"} @e) and return if @e;
     }
-    chdir $self->{build_dir} or
+    chdir "$self->{build_dir}" or
         Carp::confess("Couldn't chdir to $self->{build_dir}: $!");
     $self->debug("Changed directory to $self->{build_dir}") if $CPAN::DEBUG;
 
@@ -4401,6 +4423,17 @@ sub reports {
         $CPAN::Frontend->mydie("File::Temp not installed; cannot continue");
     }
 
+    my $format;
+    if ($CPAN::META->has_inst("YAML::XS") || $CPAN::META->has_inst("YAML::Syck")){
+        $format = 'yaml';
+    }
+    elsif (!$format && $CPAN::META->has_inst("JSON::PP") ) {
+        $format = 'json';
+    }
+    else {
+        $CPAN::Frontend->mydie("JSON::PP not installed, cannot continue");
+    }
+
     my $d = CPAN::DistnameInfo->new($pathname);
 
     my $dist      = $d->dist;      # "CPAN-DistnameInfo"
@@ -4410,7 +4443,7 @@ sub reports {
     my $cpanid    = $d->cpanid;    # "GBARR"
     my $distvname = $d->distvname; # "CPAN-DistnameInfo-0.02"
 
-    my $url = sprintf "http://www.cpantesters.org/show/%s.yaml", $dist;
+    my $url = sprintf "http://www.cpantesters.org/show/%s.%s", $dist, $format;
 
     CPAN::LWP::UserAgent->config;
     my $Ua;
@@ -4424,19 +4457,25 @@ sub reports {
         $CPAN::Frontend->mydie(sprintf "Could not download '%s': %s\n", $url, $resp->code);
     }
     $CPAN::Frontend->myprint("DONE\n\n");
-    my $yaml = $resp->content;
-    # what a long way round!
-    my $fh = File::Temp->new(
-                             dir      => File::Spec->tmpdir,
-                             template => 'cpan_reports_XXXX',
-                             suffix => '.yaml',
-                             unlink => 0,
-                            );
-    my $tfilename = $fh->filename;
-    print $fh $yaml;
-    close $fh or $CPAN::Frontend->mydie("Could not close '$tfilename': $!");
-    my $unserialized = CPAN->_yaml_loadfile($tfilename)->[0];
-    unlink $tfilename or $CPAN::Frontend->mydie("Could not unlink '$tfilename': $!");
+    my $unserialized;
+    if ( $format eq 'yaml' ) {
+        my $yaml = $resp->content;
+        # what a long way round!
+        my $fh = File::Temp->new(
+                                 dir      => File::Spec->tmpdir,
+                                 template => 'cpan_reports_XXXX',
+                                 suffix => '.yaml',
+                                 unlink => 0,
+                                );
+        my $tfilename = $fh->filename;
+        print $fh $yaml;
+        close $fh or $CPAN::Frontend->mydie("Could not close '$tfilename': $!");
+        $unserialized = CPAN->_yaml_loadfile($tfilename)->[0];
+        unlink $tfilename or $CPAN::Frontend->mydie("Could not unlink '$tfilename': $!");
+    } else {
+        require JSON::PP;
+        $unserialized = JSON::PP->new->utf8->decode($resp->content);
+    }
     my %other_versions;
     my $this_version_seen;
     for my $rep (@$unserialized) {
@@ -4469,7 +4508,7 @@ Reports for other versions:\n");
             $CPAN::Frontend->myprint(" $v\: $other_versions{$v}\n");
         }
     }
-    $url =~ s/\.yaml/.html/;
+    $url = substr($url,0,-4) . 'html';
     $CPAN::Frontend->myprint("See $url for details\n");
 }
 
index 4ceca04..29bb721 100644 (file)
@@ -34,7 +34,7 @@ CPAN::Mirrors - Get CPAN mirror information and select a fast one
 package CPAN::Mirrors;
 use strict;
 use vars qw($VERSION $urllist $silent);
-$VERSION = "2.12";
+$VERSION = "2.21";
 
 use Carp;
 use FileHandle;
@@ -390,7 +390,7 @@ sub find_best_continents {
         RANDOM: while ( @mirrors && @tests < $n && $tries++ < 15 ) {
             my $m = splice( @mirrors, int(rand(@mirrors)), 1 );
            if( $self->_try_a_ping( $args{seen}, $m, $args{ping_cache_limit} ) ) {
-                $self->get_mirrors_timings( [ $m ], @args{qw(seen callback)} );
+                $self->get_mirrors_timings( [ $m ], $args{seen}, $args{callback} );
                 next RANDOM unless defined $args{seen}{$m->hostname}->rtt;
             }
             printf "\t%s -> %0.2f ms\n",
index 77ad19b..458d87a 100644 (file)
@@ -3,7 +3,7 @@ package CPAN::Plugin;
 use strict;
 use warnings;
 
-our $VERSION = '0.96';
+our $VERSION = '0.97';
 
 require CPAN;
 
@@ -119,7 +119,7 @@ See L<CPAN/"Plugin support">.
 =head2 plugin_requires
 
 returns list of packages given plugin requires for functionality.
-This list is evaluated using C<CPAN->use_inst> method.
+This list is evaluated using C<< CPAN->use_inst >> method.
 
 =head2 distribution_object
 
index 423131c..b5d8892 100644 (file)
@@ -47,7 +47,7 @@ use vars qw(
              "CPAN/Tarzip.pm",
              "CPAN/Version.pm",
             );
-$VERSION = "5.5007";
+$VERSION = "5.5008";
 # record the initial timestamp for reload.
 $reload = { map {$INC{$_} ? ($_,(stat $INC{$_})[9]) : ()} @relo };
 @CPAN::Shell::ISA = qw(CPAN::Debug);
@@ -562,7 +562,7 @@ sub reload {
     $self->debug("self[$self]command[$command]arg[@arg]") if $CPAN::DEBUG;
     if ($command =~ /^cpan$/i) {
         my $redef = 0;
-        chdir $CPAN::iCwd if $CPAN::iCwd; # may fail
+        chdir "$CPAN::iCwd" if $CPAN::iCwd; # may fail
         my $failed;
       MFILE: for my $f (@relo) {
             next unless exists $INC{$f};