line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package App::installdeps; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
2157
|
use strict; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
75
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
102
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# ABSTRACT: A tiny script to install dependent modules |
7
|
|
|
|
|
|
|
our $VERSION = 'v0.0.3'; # VERSION |
8
|
|
|
|
|
|
|
|
9
|
2
|
|
|
2
|
|
5500
|
use Getopt::Std; |
|
2
|
|
|
|
|
102
|
|
|
2
|
|
|
|
|
137
|
|
10
|
2
|
|
|
2
|
|
11
|
use Getopt::Config::FromPod; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
41
|
|
11
|
2
|
|
|
2
|
|
1720
|
use Pod::Usage; |
|
2
|
|
|
|
|
43180
|
|
|
2
|
|
|
|
|
280
|
|
12
|
|
|
|
|
|
|
|
13
|
2
|
|
|
2
|
|
1972
|
use Module::ExtractUse; |
|
2
|
|
|
|
|
284422
|
|
|
2
|
|
|
|
|
75
|
|
14
|
2
|
|
|
2
|
|
24
|
use File::Find; |
|
2
|
|
|
|
|
5
|
|
|
2
|
|
|
|
|
159
|
|
15
|
2
|
|
|
2
|
|
11
|
use version 0.77; |
|
2
|
|
|
|
|
54
|
|
|
2
|
|
|
|
|
14
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub _exists |
18
|
|
|
|
|
|
|
{ |
19
|
36
|
|
|
36
|
|
65
|
my $module = shift; |
20
|
36
|
50
|
|
|
|
107
|
unless($module =~ /\.pm$/) { |
21
|
36
|
|
|
|
|
120
|
$module =~ s@::@/@g; |
22
|
36
|
|
|
|
|
70
|
$module .= '.pm'; |
23
|
|
|
|
|
|
|
} |
24
|
36
|
|
|
|
|
72
|
for my $prefix (@INC) { |
25
|
267
|
|
|
|
|
462
|
my $path = "$prefix/$module"; |
26
|
267
|
100
|
|
|
|
6368
|
return $path if -e $path; |
27
|
|
|
|
|
|
|
} |
28
|
13
|
|
|
|
|
30
|
return; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _process |
32
|
|
|
|
|
|
|
{ |
33
|
24
|
|
|
24
|
|
24674
|
local (@ARGV) = @_; |
34
|
|
|
|
|
|
|
|
35
|
24
|
|
|
|
|
38
|
my %opts; |
36
|
24
|
|
|
|
|
245
|
getopts(Getopt::Config::FromPod->string, \%opts); |
37
|
24
|
50
|
|
|
|
395265
|
pod2usage(-verbose => 2) if exists $opts{h}; |
38
|
24
|
50
|
|
|
|
129
|
pod2usage(-msg => 'At least one argument MUST be specified', -verbose => 0, -exitval => 1) if ! @ARGV; |
39
|
24
|
|
100
|
|
|
193
|
$opts{i} ||= 'cpanm'; |
40
|
|
|
|
|
|
|
|
41
|
24
|
|
|
|
|
375
|
my $p = Module::ExtractUse->new; |
42
|
|
|
|
|
|
|
|
43
|
24
|
|
|
|
|
318
|
while(my $arg = shift @ARGV) { |
44
|
27
|
100
|
|
|
|
15963
|
if(-f $arg) { $p->extract_use($arg); } |
|
21
|
50
|
|
|
|
112
|
|
45
|
|
|
|
|
|
|
elsif(-d $arg) { |
46
|
|
|
|
|
|
|
find({ no_chdir => 1, wanted => sub { |
47
|
18
|
100
|
|
18
|
|
24014
|
$p->extract_use($_) if -f $_; |
48
|
6
|
|
|
|
|
607
|
}}, $arg); |
49
|
|
|
|
|
|
|
} else { |
50
|
0
|
|
|
|
|
0
|
warn "can't recognize argument: $arg"; |
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
24
|
|
|
|
|
122357
|
my @target; |
54
|
|
|
|
|
|
|
my %checked; |
55
|
24
|
100
|
50
|
|
|
62
|
my @candidate = keys %{exists $opts{r} ? $p->used_out_of_eval || {}: $p->used || {}}; |
|
24
|
|
50
|
|
|
177
|
|
56
|
24
|
|
|
|
|
371
|
while(my $candidate = shift @candidate) { |
57
|
72
|
100
|
|
|
|
300
|
next if version::is_lax($candidate); |
58
|
68
|
|
|
|
|
1326
|
my $path; |
59
|
68
|
100
|
100
|
|
|
371
|
$path = _exists($candidate) if ! exists $opts{u} || exists $opts{R}; |
60
|
68
|
100
|
100
|
|
|
574
|
next if exists $opts{x} && $candidate =~ /$opts{x}/; |
61
|
63
|
100
|
100
|
|
|
375
|
next if ! exists $opts{X} && $candidate =~ /\$/; |
62
|
49
|
50
|
|
|
|
113
|
next if exists $checked{$candidate}; |
63
|
49
|
|
|
|
|
94
|
$checked{$candidate} = 1; |
64
|
49
|
100
|
100
|
|
|
167
|
if(defined $path && exists $opts{R}) { |
65
|
4
|
|
|
|
|
66
|
my $pp = Module::ExtractUse->new; |
66
|
4
|
|
|
|
|
43
|
$pp->extract_use($path); |
67
|
4
|
100
|
50
|
|
|
31850
|
push @candidate, grep { ! exists $checked{$_} } keys %{exists $opts{r} ? $pp->used_out_of_eval || {} : $pp->used || {}}; |
|
10
|
|
50
|
|
|
111
|
|
|
4
|
|
|
|
|
35
|
|
68
|
|
|
|
|
|
|
} |
69
|
49
|
100
|
100
|
|
|
248
|
next if ! exists $opts{u} && defined $path; |
70
|
30
|
|
|
|
|
155
|
push @target, $candidate; |
71
|
|
|
|
|
|
|
} |
72
|
24
|
|
|
|
|
514
|
return (\%opts, \@target); |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub run |
76
|
|
|
|
|
|
|
{ |
77
|
0
|
0
|
0
|
0
|
1
|
|
shift if @_ && eval { $_[0]->isa(__PACKAGE__) }; |
|
0
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
my ($opts, $target) = _process(@_); |
79
|
|
|
|
|
|
|
|
80
|
0
|
0
|
|
|
|
|
if($opts->{n}) { |
81
|
0
|
|
|
|
|
|
print join(' ', @$target), "\n"; |
82
|
|
|
|
|
|
|
} else { |
83
|
0
|
|
|
|
|
|
print $opts->{i},' ',join(' ', @$target), "\n"; |
84
|
0
|
|
|
|
|
|
system $opts->{i},@$target; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
1; |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
__END__ |