| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package lazy; |
|
2
|
|
|
|
|
|
|
|
|
3
|
12
|
|
|
12
|
|
1123884
|
use strict; |
|
|
12
|
|
|
|
|
90
|
|
|
|
12
|
|
|
|
|
276
|
|
|
4
|
12
|
|
|
12
|
|
48
|
use warnings; |
|
|
12
|
|
|
|
|
12
|
|
|
|
12
|
|
|
|
|
480
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.000006'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
12
|
|
|
12
|
|
4320
|
use App::cpm 0.975; # CLI has no $VERSION |
|
|
12
|
|
|
|
|
1152
|
|
|
|
12
|
|
|
|
|
240
|
|
|
9
|
12
|
|
|
12
|
|
4374
|
use App::cpm::CLI; |
|
|
12
|
|
|
|
|
2338896
|
|
|
|
12
|
|
|
|
|
432
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Cargo-culted from App::cpm::CLI |
|
12
|
|
|
|
|
|
|
# Adding pass_through so that we don't have to keep up with all possible options |
|
13
|
12
|
|
|
|
|
108
|
use Getopt::Long qw( |
|
14
|
|
|
|
|
|
|
:config |
|
15
|
|
|
|
|
|
|
no_auto_abbrev |
|
16
|
|
|
|
|
|
|
no_ignore_case |
|
17
|
|
|
|
|
|
|
bundling |
|
18
|
|
|
|
|
|
|
pass_through |
|
19
|
12
|
|
|
12
|
|
96
|
); |
|
|
12
|
|
|
|
|
18
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
12
|
|
|
12
|
|
8340
|
use Module::Loaded qw( is_loaded ); |
|
|
12
|
|
|
|
|
6696
|
|
|
|
12
|
|
|
|
|
3546
|
|
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub import { |
|
24
|
12
|
|
|
12
|
|
96
|
shift; |
|
25
|
12
|
|
|
|
|
42
|
my @args = @_; |
|
26
|
|
|
|
|
|
|
|
|
27
|
12
|
|
|
|
|
18
|
my $is_global; |
|
28
|
|
|
|
|
|
|
my $local_lib; |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
{ |
|
31
|
12
|
|
|
|
|
18
|
local @ARGV = @args; |
|
|
12
|
|
|
|
|
24
|
|
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# Stolen from App::cpm::CLI::parse_options() |
|
34
|
12
|
|
|
|
|
54
|
GetOptions( |
|
35
|
|
|
|
|
|
|
'L|local-lib-contained=s' => \$local_lib, |
|
36
|
|
|
|
|
|
|
'g|global' => \$is_global, |
|
37
|
|
|
|
|
|
|
); |
|
38
|
|
|
|
|
|
|
} |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
# Generally assume a global install, which makes the invocation as |
|
41
|
|
|
|
|
|
|
# simple as: |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
# perl -Mlazy foo.pl |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
# However, if we're already using local::lib and --global has not been |
|
46
|
|
|
|
|
|
|
# explicitly set and no local::lib has been explicitly set, let's try |
|
47
|
|
|
|
|
|
|
# to DTRT and use the correct local::lib. |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# This allows us to do something like: |
|
50
|
|
|
|
|
|
|
# perl -Mlocal::lib -Mlazy foo.pl |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# This may or may not be a good idea. |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# Allowing --local-lib-contained to be passed is mostly useful for |
|
55
|
|
|
|
|
|
|
# testing. For real world cases, the user should specify the |
|
56
|
|
|
|
|
|
|
# local::lib via local::lib itself. |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
# perl -Mlocal::lib=my_local_lib -Mlazy foo.pl |
|
59
|
|
|
|
|
|
|
|
|
60
|
12
|
50
|
66
|
|
|
3690
|
if ( ( !$is_global && !$local_lib ) && is_loaded('local::lib') ) { |
|
|
|
100
|
66
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
61
|
0
|
|
|
|
|
0
|
my @paths = local::lib->new->active_paths; |
|
62
|
0
|
|
|
|
|
0
|
my $path = shift @paths; |
|
63
|
0
|
0
|
|
|
|
0
|
if ($path) { |
|
64
|
0
|
|
|
|
|
0
|
push @args, ( '-L', $path ); |
|
65
|
0
|
|
|
|
|
0
|
_print_msg_about_local_lib($path); |
|
66
|
|
|
|
|
|
|
} |
|
67
|
|
|
|
|
|
|
} |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
# Assume a global install if local::lib is not in use or has not been |
|
70
|
|
|
|
|
|
|
# explicitly invoked. |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
elsif ( !$is_global && !$local_lib ) { |
|
73
|
6
|
|
|
|
|
114
|
push @args, ('-g'); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
|
|
|
|
|
|
|
|
76
|
12
|
|
|
|
|
54
|
my $cpm = App::cpm::CLI->new; |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# Push the hook onto @INC and then re-add all of @INC again. This way, if |
|
79
|
|
|
|
|
|
|
# we got to the hook and tried to install, we can re-try @INC to see if the |
|
80
|
|
|
|
|
|
|
# module can now be used. |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
push @INC, sub { |
|
83
|
12
|
|
|
12
|
|
15876
|
shift; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Don't try to install if we're called inside an eval |
|
86
|
12
|
|
|
|
|
102
|
my @caller = caller(1); |
|
87
|
|
|
|
|
|
|
return |
|
88
|
12
|
50
|
33
|
|
|
174
|
if ( ( $caller[3] && $caller[3] =~ m{eval} ) |
|
|
|
|
33
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
89
|
|
|
|
|
|
|
|| ( $caller[1] && $caller[1] =~ m{eval} ) ); |
|
90
|
|
|
|
|
|
|
|
|
91
|
12
|
|
|
|
|
30
|
my $name = shift; |
|
92
|
12
|
|
|
|
|
24
|
$name =~ s{/}{::}g; |
|
93
|
12
|
|
|
|
|
24
|
$name =~ s{\.pm\z}{}; |
|
94
|
|
|
|
|
|
|
|
|
95
|
12
|
|
|
|
|
78
|
$cpm->run( 'install', @args, $name ); |
|
96
|
2
|
|
|
|
|
3189258
|
return 1; |
|
97
|
12
|
|
|
|
|
12666
|
}, @INC; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _print_msg_about_local_lib { |
|
101
|
0
|
|
|
0
|
|
|
my $path = shift; |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
print <<"EOF"; |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
******** |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
You haven't included any arguments for App::cpm via lazy, but you've |
|
108
|
|
|
|
|
|
|
loaded local::lib, so we're going to install all modules into: |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
$path |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
If you do not want to do this, you can explicitly invoke a global install via: |
|
113
|
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
perl -Mlazy=-g path/to/script.pl |
|
115
|
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
or, from inside your code: |
|
117
|
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
use lazy qw( -g ); |
|
119
|
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
If you would like to install to a different local lib: |
|
121
|
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
perl -Mlocal::lib=my_local_lib -Mlazy path/to/script.pl |
|
123
|
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
or, from inside your code: |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
use local::lib qw( my_local_lib ); |
|
127
|
|
|
|
|
|
|
use lazy; |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
******** |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
EOF |
|
132
|
|
|
|
|
|
|
} |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
1; |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# ABSTRACT: Lazily install missing Perl modules |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
__END__ |