use if $] < 5.008 => 'IO::Scalar';
-$VERSION = '1.67';
+$VERSION = '1.671';
=head1 NAME
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
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;
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'";
$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;
{
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;
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.
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
$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;
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") {
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\(.+?\)/) {
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
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;
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;
$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"
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;
$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) {
$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");
}