Skip to content
This repository was archived by the owner on Jun 1, 2023. It is now read-only.

Commit 54ec1f3

Browse files
committed
CPAN: Update to 2.17-TRIAL2 with cperl support
See andk/cpanpm#109
1 parent b6ce966 commit 54ec1f3

File tree

14 files changed

+214
-72
lines changed

14 files changed

+214
-72
lines changed

Porting/Maintainers.pl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ package Maintainers;
329329
},
330330

331331
'CPAN' => {
332-
'DISTRIBUTION' => 'ANDK/CPAN-2.14.tar.gz',
332+
'DISTRIBUTION' => 'ANDK/CPAN-2.17.tar.gz',
333333
'FILES' => q[cpan/CPAN],
334334
'EXCLUDED' => [
335335
qr{^distroprefs/},
@@ -363,7 +363,8 @@ package Maintainers;
363363
t/perlcriticrc
364364
t/yaml_code.yml
365365
),
366-
],
366+
],
367+
# https://github.com/andk/cpanpm/pull/109
367368
'CUSTOMIZED' => [
368369
qw( lib/CPAN.pm lib/CPAN/FirstTime.pm lib/CPAN/Distribution.pm
369370
lib/CPAN/Version.pm lib/App/Cpan.pm ),

cpan/CPAN/lib/App/Cpan.pm

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use vars qw($VERSION);
66

77
use if $] < 5.008 => 'IO::Scalar';
88

9-
$VERSION = '1.64_01';
9+
$VERSION = '1.66';
1010

1111
=head1 NAME
1212
@@ -549,9 +549,20 @@ sub AUTOLOAD { 1 }
549549
sub DESTROY { 1 }
550550
}
551551

552+
# load a module without searching the default entry for the current
553+
# directory
554+
sub _safe_load_module {
555+
my $name = shift;
556+
557+
local @INC = @INC;
558+
pop @INC if $INC[-1] eq '.';
559+
560+
eval "require $name; 1";
561+
}
562+
552563
sub _init_logger
553564
{
554-
my $log4perl_loaded = eval "require Log::Log4perl; 1";
565+
my $log4perl_loaded = _safe_load_module("Log::Log4perl");
555566

556567
unless( $log4perl_loaded )
557568
{
@@ -1020,9 +1031,9 @@ sub _load_local_lib # -I
10201031
{
10211032
$logger->debug( "Loading local::lib" );
10221033

1023-
my $rc = eval { require local::lib; 1; };
1034+
my $rc = _safe_load_module("local::lib");
10241035
unless( $rc ) {
1025-
$logger->die( "Could not load local::lib" );
1036+
$logger->logdie( "Could not load local::lib" );
10261037
}
10271038

10281039
local::lib->import;
@@ -1034,7 +1045,7 @@ sub _use_these_mirrors # -M
10341045
{
10351046
$logger->debug( "Setting per session mirrors" );
10361047
unless( $_[0] ) {
1037-
$logger->die( "The -M switch requires a comma-separated list of mirrors" );
1048+
$logger->logdie( "The -M switch requires a comma-separated list of mirrors" );
10381049
}
10391050

10401051
$CPAN::Config->{urllist} = [ split /,/, $_[0] ];
@@ -1160,7 +1171,7 @@ sub _get_file
11601171
{
11611172
my $path = shift;
11621173

1163-
my $loaded = eval "require LWP::Simple; 1;";
1174+
my $loaded = _safe_load_module("LWP::Simple");
11641175
croak "You need LWP::Simple to use features that fetch files from CPAN\n"
11651176
unless $loaded;
11661177

@@ -1182,7 +1193,7 @@ sub _gitify
11821193
{
11831194
my $args = shift;
11841195

1185-
my $loaded = eval "require Archive::Extract; 1;";
1196+
my $loaded = _safe_load_module("Archive::Extract");
11861197
croak "You need Archive::Extract to use features that gitify distributions\n"
11871198
unless $loaded;
11881199

@@ -1245,7 +1256,7 @@ sub _show_Changes
12451256
sub _get_changes_file
12461257
{
12471258
croak "Reading Changes files requires LWP::Simple and URI\n"
1248-
unless eval "require LWP::Simple; require URI; 1";
1259+
unless _safe_load_module("LWP::Simple") && _safe_load_module("URI");
12491260

12501261
my $url = shift;
12511262

@@ -1336,7 +1347,8 @@ sub _show_out_of_date
13361347

13371348
foreach my $module ( @$modules )
13381349
{
1339-
next unless $module->inst_file;
1350+
next unless $module = _expand_module($module);
1351+
next unless $module->inst_file;
13401352
next if $module->uptodate;
13411353
printf "%-40s %.4f %.4f\n",
13421354
$module->id,
@@ -1479,8 +1491,10 @@ sub _path_to_module
14791491
sub _expand_module
14801492
{
14811493
my( $module ) = @_;
1482-
my $class = $module =~ /^Bundle::/ ? "Bundle" : "Module";
1483-
my $expanded = CPAN::Shell->expand( $class, $module );
1494+
1495+
my $expanded = CPAN::Shell->expandany( $module );
1496+
return $expanded if $expanded;
1497+
$expanded = CPAN::Shell->expand( "Module", $module );
14841498
unless( defined $expanded ) {
14851499
$logger->error( "Could not expand [$module]. Check the module name." );
14861500
my $threshold = (

cpan/CPAN/lib/CPAN.pm

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
# vim: ts=4 sts=4 sw=4:
33
use strict;
44
package CPAN;
5-
$CPAN::VERSION = '2.14c'; # fixed for cperl
5+
$CPAN::VERSION = '2.17_01'; # with cperl support
66
$CPAN::VERSION =~ s/_//;
7-
$CPAN::VERSION =~ s/c$//;
87

98
# we need to run chdir all over and we would get at wrong libraries
109
# there
@@ -15,8 +14,6 @@ BEGIN {
1514
$inc = File::Spec->rel2abs($inc) unless ref $inc;
1615
}
1716
}
18-
# make sure we can install any modules from CPAN without patching them
19-
$ENV{PERL_USE_UNSAFE_INC} = 1;
2017
$SIG{WINCH} = 'IGNORE' if exists $SIG{WINCH};
2118
}
2219
use CPAN::Author;
@@ -66,6 +63,7 @@ use Text::Wrap ();
6663
sub find_perl ();
6764
sub anycwd ();
6865
sub _uniq;
66+
my $CPERL = $Config::Config{usecperl};
6967

7068
no lib ".";
7169

@@ -208,6 +206,8 @@ sub soft_chdir_with_alternatives ($);
208206
}
209207
$autoload_recursion--;
210208
}
209+
# make sure we can install any modules from CPAN without patching them
210+
$ENV{PERL_USE_UNSAFE_INC} = 1;
211211
}
212212

213213
{
@@ -520,9 +520,10 @@ sub _flock {
520520
}
521521

522522
sub _yaml_module () {
523-
my $yaml_module = $CPAN::Config->{yaml_module} || "YAML::XS";
523+
my $dflt = $CPERL ? "YAML::XS" : "YAML";
524+
my $yaml_module = $CPAN::Config->{yaml_module} || $dflt;
524525
if (
525-
$yaml_module ne "YAML::XS"
526+
$yaml_module ne $dflt
526527
&&
527528
!$CPAN::META->has_inst($yaml_module)
528529
) {
@@ -1084,6 +1085,16 @@ sub has_usable {
10841085
},
10851086
],
10861087
'Net::FTP' => [
1088+
sub {
1089+
my $var = $CPAN::Config->{ftp_proxy} || $ENV{ftp_proxy};
1090+
if ($var and $var =~ /^http:/i) {
1091+
# rt #110833
1092+
for ("Net::FTP cannot handle http proxy") {
1093+
$CPAN::Frontend->mywarn($_);
1094+
die $_;
1095+
}
1096+
}
1097+
},
10871098
sub {require Net::FTP},
10881099
sub {require Net::Config},
10891100
],
@@ -1138,6 +1149,8 @@ sub has_usable {
11381149
]
11391150
};
11401151
if ($usable->{$mod}) {
1152+
local @INC = @INC;
1153+
pop @INC if $INC[-1] eq '.';
11411154
for my $c (0..$#{$usable->{$mod}}) {
11421155
my $code = $usable->{$mod}[$c];
11431156
my $ret = eval { &$code() };
@@ -1180,6 +1193,8 @@ sub has_inst {
11801193
$CPAN::META->{dontload_hash}{$mod}||=1; # unsafe meta access, ok
11811194
return 0;
11821195
}
1196+
local @INC = @INC;
1197+
pop @INC if $INC[-1] eq '.';
11831198
my $file = $mod;
11841199
my $obj;
11851200
$file =~ s|::|/|g;
@@ -2127,6 +2142,9 @@ currently defined:
21272142
bzip2 path to external prg
21282143
cache_metadata use serializer to cache metadata
21292144
check_sigs if signatures should be verified
2145+
cleanup_after_install
2146+
remove build directory immediately after a
2147+
successful install
21302148
colorize_debug Term::ANSIColor attributes for debugging output
21312149
colorize_output boolean if Term::ANSIColor should colorize output
21322150
colorize_print Term::ANSIColor attributes for normal output

cpan/CPAN/lib/CPAN/Bundle.pm

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use CPAN::Module;
88
use vars qw(
99
$VERSION
1010
);
11-
$VERSION = "5.5001";
11+
$VERSION = "5.5002";
1212

1313
sub look {
1414
my $self = shift;
@@ -39,7 +39,12 @@ sub color_cmd_tmps {
3939
&& $color==1
4040
&& $self->{incommandcolor}==$color;
4141
if ($depth>=$CPAN::MAX_RECURSION) {
42-
die(CPAN::Exception::RecursiveDependency->new($ancestors));
42+
my $e = CPAN::Exception::RecursiveDependency->new($ancestors);
43+
if ($e->is_resolvable) {
44+
return $self->{incommandcolor}=2;
45+
} else {
46+
die $e;
47+
}
4348
}
4449
# warn "color_cmd_tmps $depth $color " . $self->id; # sleep 1;
4550

0 commit comments

Comments
 (0)