| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Shipwright::Script::Requires; |
|
2
|
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
709
|
use strict; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
24
|
|
|
4
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
24
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
5
|
use base qw/App::CLI::Command Shipwright::Base Shipwright::Script/; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
152
|
|
|
7
|
|
|
|
|
|
|
__PACKAGE__->mk_accessors( |
|
8
|
|
|
|
|
|
|
qw/skip skip_recommends skip_all_recommends version as_graph min_perl_version |
|
9
|
|
|
|
|
|
|
include_dual_lifed/ |
|
10
|
|
|
|
|
|
|
); |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
6
|
use Shipwright; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
4
|
|
|
13
|
1
|
|
|
1
|
|
24
|
use Shipwright::Util; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
69
|
|
|
14
|
1
|
|
|
1
|
|
5
|
use File::Spec::Functions qw/catfile catdir/; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
577
|
|
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub options { |
|
17
|
|
|
|
|
|
|
( |
|
18
|
0
|
|
|
0
|
0
|
|
'skip=s' => 'skip', |
|
19
|
|
|
|
|
|
|
'skip-recommends=s' => 'skip_recommends', |
|
20
|
|
|
|
|
|
|
'skip-all-recommends' => 'skip_all_recommends', |
|
21
|
|
|
|
|
|
|
'version=s' => 'version', |
|
22
|
|
|
|
|
|
|
'as-graph' => 'as_graph', |
|
23
|
|
|
|
|
|
|
'min-perl-version=s' => 'min_perl_version', |
|
24
|
|
|
|
|
|
|
'include-dual-lifed' => 'include_dual_lifed', |
|
25
|
|
|
|
|
|
|
); |
|
26
|
|
|
|
|
|
|
} |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub run { |
|
29
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
30
|
0
|
|
|
|
|
|
my $source = shift; |
|
31
|
0
|
0
|
|
|
|
|
confess_or_die "we need source arg\n" unless $source; |
|
32
|
|
|
|
|
|
|
|
|
33
|
0
|
|
0
|
|
|
|
$self->skip( { map { $_ => 1 } split /\s*,\s*/, $self->skip || '' } ); |
|
|
0
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
$self->skip_recommends( |
|
35
|
0
|
|
0
|
|
|
|
{ map { $_ => 1 } split /\s*,\s*/, $self->skip_recommends || '' } ); |
|
|
0
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $deps = {}; |
|
38
|
0
|
|
|
|
|
|
my $shipwright = Shipwright->new( |
|
39
|
|
|
|
|
|
|
source => $source, |
|
40
|
|
|
|
|
|
|
skip_all_recommends => $self->skip_all_recommends, |
|
41
|
|
|
|
|
|
|
min_perl_version => $self->min_perl_version, |
|
42
|
|
|
|
|
|
|
include_dual_lifed => $self->include_dual_lifed, |
|
43
|
|
|
|
|
|
|
skip => $self->skip, |
|
44
|
|
|
|
|
|
|
version => $self->version, |
|
45
|
|
|
|
|
|
|
skip_recommends => $self->skip_recommends, |
|
46
|
|
|
|
|
|
|
); |
|
47
|
0
|
|
|
|
|
|
my $name = $source; |
|
48
|
0
|
|
|
|
|
|
$name =~ s/^cpan://; |
|
49
|
0
|
|
|
|
|
|
$source = $shipwright->source->run(); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
next |
|
52
|
0
|
0
|
|
|
|
|
unless $source; # if running the source returned undef, we should skip |
|
53
|
|
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
$self->_requires( $source, $deps, $name ); |
|
55
|
|
|
|
|
|
|
|
|
56
|
0
|
|
|
|
|
|
my $out; |
|
57
|
0
|
0
|
|
|
|
|
if ( $self->as_graph ) { |
|
58
|
0
|
|
|
|
|
|
$out = 'digraph g { |
|
59
|
|
|
|
|
|
|
graph [ overlap = scale, rankdir= LR ]; |
|
60
|
|
|
|
|
|
|
node [ fontsize = "18", shape = record, fontsize = 18 ]; |
|
61
|
|
|
|
|
|
|
'; |
|
62
|
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
for my $module ( keys %$deps ) { |
|
64
|
0
|
|
|
|
|
|
$out .= |
|
65
|
|
|
|
|
|
|
qq{ "$module" [shape = record, fontsize = 18, label = "$module" ];\n}; |
|
66
|
0
|
|
|
|
|
|
for my $dep ( keys %{ $deps->{$module} } ) { |
|
|
0
|
|
|
|
|
|
|
|
67
|
0
|
|
|
|
|
|
$out .= qq{"$module" -> "$dep";\n}; |
|
68
|
|
|
|
|
|
|
} |
|
69
|
|
|
|
|
|
|
} |
|
70
|
0
|
|
|
|
|
|
$out .= "\n};"; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
else { |
|
73
|
0
|
|
|
|
|
|
$out = dump_yaml($deps); |
|
74
|
|
|
|
|
|
|
} |
|
75
|
0
|
|
|
|
|
|
$self->log->fatal($out); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
# _import_req: import required dists for a dist |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _requires { |
|
81
|
0
|
|
|
0
|
|
|
my $self = shift; |
|
82
|
0
|
|
|
|
|
|
my $source = shift; |
|
83
|
0
|
|
|
|
|
|
my $deps = shift; |
|
84
|
0
|
|
|
|
|
|
my $name = shift; |
|
85
|
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
my $dir = parent_dir($source); |
|
87
|
0
|
|
|
|
|
|
my $map_file = catfile( $dir, 'map.yml' ); |
|
88
|
0
|
|
|
|
|
|
my $map = load_yaml_file($map_file); |
|
89
|
0
|
|
|
|
|
|
my $reverse_map = { reverse %$map }; |
|
90
|
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
opendir my ($d), $dir; |
|
92
|
0
|
|
|
|
|
|
my @sources = readdir $d; |
|
93
|
0
|
|
|
|
|
|
close $d; |
|
94
|
|
|
|
|
|
|
|
|
95
|
0
|
|
|
|
|
|
my $require_file = catfile( $source, '__require.yml' ); |
|
96
|
0
|
0
|
|
|
|
|
if ( -e $require_file ) { |
|
97
|
0
|
|
|
|
|
|
my $d = load_yaml_file($require_file); |
|
98
|
0
|
|
|
|
|
|
for my $type ( keys %$d ) { |
|
99
|
0
|
|
|
|
|
|
for my $dep ( keys %{ $d->{$type} } ) { |
|
|
0
|
|
|
|
|
|
|
|
100
|
0
|
|
|
|
|
|
my $dep_source = catdir( $dir, $dep ); |
|
101
|
0
|
|
0
|
|
|
|
my $dep_module = $reverse_map->{$dep} || $dep; |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
0
|
|
|
|
$deps->{$name} ||= {}; |
|
104
|
0
|
0
|
|
|
|
|
if ( exists $deps->{$name}{$dep_module} ) { |
|
105
|
0
|
|
|
|
|
|
my $old = $deps->{$name}{$dep_module}; |
|
106
|
0
|
|
|
|
|
|
my $new = $d->{$type}{$dep}{version}; |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
my $old_v = version->new($old); |
|
109
|
0
|
|
|
|
|
|
my $new_v = version->new($new); |
|
110
|
|
|
|
|
|
|
|
|
111
|
0
|
0
|
|
|
|
|
if ( $new_v->numify > $old_v->numify ) { |
|
112
|
|
|
|
|
|
|
$deps->{$name}{$dep_module} = |
|
113
|
0
|
|
|
|
|
|
$d->{$type}{$dep}{version}; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
else { |
|
117
|
0
|
|
|
|
|
|
$deps->{$name}{$dep_module} = $d->{$type}{$dep}{version}; |
|
118
|
|
|
|
|
|
|
} |
|
119
|
|
|
|
|
|
|
|
|
120
|
0
|
0
|
|
|
|
|
next if $deps->{$dep_module}; |
|
121
|
0
|
|
|
|
|
|
$self->_requires( $dep_source, $deps, $dep_module ); |
|
122
|
|
|
|
|
|
|
} |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
} |
|
125
|
|
|
|
|
|
|
else { |
|
126
|
0
|
|
|
|
|
|
$self->log->warn("failed to find requirments of $source"); |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
} |
|
130
|
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
1; |
|
132
|
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
__END__ |