line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package lib::xi; |
2
|
2
|
|
|
2
|
|
74702
|
use 5.008_001; |
|
2
|
|
|
|
|
8
|
|
|
2
|
|
|
|
|
90
|
|
3
|
2
|
|
|
2
|
|
13
|
use strict; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
78
|
|
4
|
2
|
|
|
2
|
|
12
|
use warnings FATAL => 'all'; |
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
238
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '1.03'; |
7
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
13
|
use File::Spec (); |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
48
|
|
9
|
2
|
|
|
2
|
|
11
|
use Config (); |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
6454
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our $VERBOSE; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
# modules which dosn't exist in CPAN |
14
|
|
|
|
|
|
|
our %IGNORE = map { $_ => 1 } ( |
15
|
|
|
|
|
|
|
'Encode/ConfigLocal.pm', |
16
|
|
|
|
|
|
|
'Devel/StackTraceFrame.pm', |
17
|
|
|
|
|
|
|
'Log/Agent.pm', # used in Storable.pm |
18
|
|
|
|
|
|
|
); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub new { |
21
|
2
|
|
|
2
|
0
|
7
|
my($class, %args) = @_; |
22
|
2
|
|
|
|
|
8
|
return bless \%args, $class; |
23
|
|
|
|
|
|
|
} |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
sub run_perl { |
26
|
2
|
|
|
2
|
0
|
6
|
my(@args) = @_; |
27
|
|
|
|
|
|
|
|
28
|
8
|
100
|
|
|
|
34
|
my %std_inc = map { $_ => 1 } |
|
12
|
|
|
|
|
7010
|
|
29
|
2
|
|
|
|
|
37
|
grep { defined($_) && length } @Config::Config{qw( |
30
|
|
|
|
|
|
|
sitelibexp sitearchexp |
31
|
|
|
|
|
|
|
venderlibexp venderarchexp |
32
|
|
|
|
|
|
|
privlibexp archlibexp |
33
|
|
|
|
|
|
|
)}; |
34
|
18
|
50
|
|
|
|
278
|
my @non_std_inc = map { File::Spec->rel2abs($_) } |
|
26
|
|
|
|
|
128
|
|
35
|
2
|
|
|
|
|
13
|
grep { defined($_) && not $std_inc{$_} } @INC; |
36
|
|
|
|
|
|
|
|
37
|
2
|
|
|
|
|
6
|
system($^X, (map { "-I$_" } @non_std_inc), @args); |
|
18
|
|
|
|
|
384533995
|
|
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub cpanm_command { |
41
|
2
|
|
|
2
|
0
|
4
|
my($self) = @_; |
42
|
2
|
|
|
|
|
3
|
return('cpanm', @{ $self->{cpanm_opts} }); |
|
2
|
|
|
|
|
20
|
|
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# must be fully-qualified; othewise implied main::INC. |
46
|
|
|
|
|
|
|
sub lib::xi::INC { |
47
|
2
|
|
|
2
|
0
|
5313
|
my($self, $file) = @_; |
48
|
|
|
|
|
|
|
|
49
|
2
|
50
|
|
|
|
13
|
return if $IGNORE{$file}; |
50
|
|
|
|
|
|
|
|
51
|
2
|
|
|
|
|
6
|
my $module = $file; |
52
|
2
|
|
|
|
|
23
|
$module =~ s/\.pm \z//xms; |
53
|
2
|
|
|
|
|
8
|
$module =~ s{/}{::}xmsg; |
54
|
|
|
|
|
|
|
|
55
|
2
|
|
|
|
|
12
|
my @cmd = ($self->cpanm_command, $module); |
56
|
2
|
50
|
|
|
|
8
|
if($VERBOSE) { |
57
|
0
|
|
0
|
|
|
0
|
print STDERR "# PERL_CPANM_OPT: ", ($ENV{PERL_CPANM_OPT} || '') ,"\n"; |
58
|
0
|
|
|
|
|
0
|
print STDERR "# COMMAND: @cmd\n"; |
59
|
|
|
|
|
|
|
} |
60
|
2
|
50
|
|
|
|
10
|
if(run_perl('-S', @cmd) == 0) { |
61
|
2
|
|
|
|
|
32
|
foreach my $lib (grep {defined} @{ $self->{myinc} }) { |
|
26
|
|
|
|
|
90
|
|
|
2
|
|
|
|
|
62
|
|
62
|
17
|
100
|
|
|
|
807
|
if(open my $inh, '<', "$lib/$file") { |
63
|
2
|
|
|
|
|
33
|
$INC{$file} = "$lib/$file"; |
64
|
2
|
|
|
|
|
6886
|
return $inh; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# fall back to the default behavior (Can't locate Foo.pm ...) |
70
|
0
|
|
|
|
|
0
|
return; |
71
|
|
|
|
|
|
|
} |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub import { |
74
|
2
|
|
|
2
|
|
22
|
my($class, @cpanm_opts) = @_; |
75
|
|
|
|
|
|
|
|
76
|
2
|
|
|
|
|
5
|
my $install_dir; |
77
|
|
|
|
|
|
|
|
78
|
2
|
100
|
66
|
|
|
20
|
if(@cpanm_opts && $cpanm_opts[0] !~ /^-/) { |
79
|
1
|
|
|
|
|
11
|
require File::Spec; |
80
|
1
|
|
|
|
|
3
|
my $base; |
81
|
1
|
50
|
33
|
|
|
40
|
if($0 ne '-e' && -e $0) { |
82
|
1
|
|
|
|
|
31
|
my($volume, $dir, undef) = File::Spec->splitpath($0); |
83
|
1
|
|
|
|
|
32
|
$base = File::Spec->catpath($volume, $dir, ''); |
84
|
|
|
|
|
|
|
} |
85
|
1
|
|
|
|
|
70
|
$install_dir = File::Spec->rel2abs(shift(@cpanm_opts), $base); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
2
|
|
|
|
|
3
|
my @myinc; |
89
|
|
|
|
|
|
|
|
90
|
2
|
100
|
|
|
|
8
|
if($install_dir) { |
91
|
1
|
|
|
|
|
17
|
@myinc = ( |
92
|
|
|
|
|
|
|
"$install_dir/lib/perl5/$Config::Config{archname}", |
93
|
|
|
|
|
|
|
"$install_dir/lib/perl5", |
94
|
|
|
|
|
|
|
); |
95
|
1
|
|
|
|
|
5
|
unshift @INC, @myinc; |
96
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
3
|
unshift @cpanm_opts, '-l', $install_dir; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
2
|
|
|
|
|
4
|
$VERBOSE = scalar grep { $_ eq '-v' } @cpanm_opts; |
|
2
|
|
|
|
|
5
|
|
101
|
|
|
|
|
|
|
|
102
|
2
|
100
|
|
|
|
14
|
push @INC, $class->new( |
103
|
|
|
|
|
|
|
install_dir => $install_dir, |
104
|
|
|
|
|
|
|
myinc => $install_dir ? \@myinc : \@INC, |
105
|
|
|
|
|
|
|
cpanm_opts => \@cpanm_opts, |
106
|
|
|
|
|
|
|
); |
107
|
2
|
|
|
|
|
39
|
return; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
0
|
|
|
0
|
0
|
|
sub install_dir { $_[0]->{install_dir} } # for testing |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
__END__ |