line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Install::Metadata; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
15219
|
use strict 'vars'; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
101
|
|
4
|
4
|
|
|
4
|
|
1001
|
use Module::Install::Base (); |
|
4
|
|
|
|
|
6
|
|
|
4
|
|
|
|
|
64
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
13
|
use vars qw{$VERSION @ISA $ISCORE}; |
|
4
|
|
|
|
|
4
|
|
|
4
|
|
|
|
|
247
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
4
|
|
|
4
|
|
11
|
$VERSION = '1.18'; |
9
|
4
|
|
|
|
|
38
|
@ISA = 'Module::Install::Base'; |
10
|
4
|
|
|
|
|
14219
|
$ISCORE = 1; |
11
|
|
|
|
|
|
|
} |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
my @boolean_keys = qw{ |
14
|
|
|
|
|
|
|
sign |
15
|
|
|
|
|
|
|
}; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
my @scalar_keys = qw{ |
18
|
|
|
|
|
|
|
name |
19
|
|
|
|
|
|
|
module_name |
20
|
|
|
|
|
|
|
abstract |
21
|
|
|
|
|
|
|
version |
22
|
|
|
|
|
|
|
distribution_type |
23
|
|
|
|
|
|
|
tests |
24
|
|
|
|
|
|
|
installdirs |
25
|
|
|
|
|
|
|
}; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my @tuple_keys = qw{ |
28
|
|
|
|
|
|
|
configure_requires |
29
|
|
|
|
|
|
|
build_requires |
30
|
|
|
|
|
|
|
requires |
31
|
|
|
|
|
|
|
recommends |
32
|
|
|
|
|
|
|
bundles |
33
|
|
|
|
|
|
|
resources |
34
|
|
|
|
|
|
|
}; |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
my @resource_keys = qw{ |
37
|
|
|
|
|
|
|
homepage |
38
|
|
|
|
|
|
|
bugtracker |
39
|
|
|
|
|
|
|
repository |
40
|
|
|
|
|
|
|
}; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my @array_keys = qw{ |
43
|
|
|
|
|
|
|
keywords |
44
|
|
|
|
|
|
|
author |
45
|
|
|
|
|
|
|
}; |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
*authors = \&author; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
0
|
0
|
0
|
sub Meta { shift } |
50
|
0
|
|
|
0
|
0
|
0
|
sub Meta_BooleanKeys { @boolean_keys } |
51
|
0
|
|
|
0
|
0
|
0
|
sub Meta_ScalarKeys { @scalar_keys } |
52
|
0
|
|
|
0
|
0
|
0
|
sub Meta_TupleKeys { @tuple_keys } |
53
|
0
|
|
|
0
|
0
|
0
|
sub Meta_ResourceKeys { @resource_keys } |
54
|
0
|
|
|
0
|
0
|
0
|
sub Meta_ArrayKeys { @array_keys } |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
foreach my $key ( @boolean_keys ) { |
57
|
|
|
|
|
|
|
*$key = sub { |
58
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
59
|
0
|
0
|
0
|
|
|
0
|
if ( defined wantarray and not @_ ) { |
60
|
0
|
|
|
|
|
0
|
return $self->{values}->{$key}; |
61
|
|
|
|
|
|
|
} |
62
|
0
|
0
|
|
|
|
0
|
$self->{values}->{$key} = ( @_ ? $_[0] : 1 ); |
63
|
0
|
|
|
|
|
0
|
return $self; |
64
|
|
|
|
|
|
|
}; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
foreach my $key ( @scalar_keys ) { |
68
|
|
|
|
|
|
|
*$key = sub { |
69
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
70
|
0
|
0
|
0
|
|
|
0
|
return $self->{values}->{$key} if defined wantarray and !@_; |
71
|
0
|
|
|
|
|
0
|
$self->{values}->{$key} = shift; |
72
|
0
|
|
|
|
|
0
|
return $self; |
73
|
|
|
|
|
|
|
}; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
foreach my $key ( @array_keys ) { |
77
|
|
|
|
|
|
|
*$key = sub { |
78
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
79
|
0
|
0
|
0
|
|
|
0
|
return $self->{values}->{$key} if defined wantarray and !@_; |
80
|
0
|
|
0
|
|
|
0
|
$self->{values}->{$key} ||= []; |
81
|
0
|
|
|
|
|
0
|
push @{$self->{values}->{$key}}, @_; |
|
0
|
|
|
|
|
0
|
|
82
|
0
|
|
|
|
|
0
|
return $self; |
83
|
|
|
|
|
|
|
}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
foreach my $key ( @resource_keys ) { |
87
|
|
|
|
|
|
|
*$key = sub { |
88
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
89
|
0
|
0
|
|
|
|
0
|
unless ( @_ ) { |
90
|
0
|
0
|
|
|
|
0
|
return () unless $self->{values}->{resources}; |
91
|
0
|
|
|
|
|
0
|
return map { $_->[1] } |
92
|
0
|
|
|
|
|
0
|
grep { $_->[0] eq $key } |
93
|
0
|
|
|
|
|
0
|
@{ $self->{values}->{resources} }; |
|
0
|
|
|
|
|
0
|
|
94
|
|
|
|
|
|
|
} |
95
|
0
|
0
|
|
|
|
0
|
return $self->{values}->{resources}->{$key} unless @_; |
96
|
0
|
0
|
|
|
|
0
|
my $uri = shift or die( |
97
|
|
|
|
|
|
|
"Did not provide a value to $key()" |
98
|
|
|
|
|
|
|
); |
99
|
0
|
|
|
|
|
0
|
$self->resources( $key => $uri ); |
100
|
0
|
|
|
|
|
0
|
return 1; |
101
|
|
|
|
|
|
|
}; |
102
|
|
|
|
|
|
|
} |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
foreach my $key ( grep { $_ ne "resources" } @tuple_keys) { |
105
|
|
|
|
|
|
|
*$key = sub { |
106
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
107
|
0
|
0
|
|
|
|
0
|
return $self->{values}->{$key} unless @_; |
108
|
0
|
|
|
|
|
0
|
my @added; |
109
|
0
|
|
|
|
|
0
|
while ( @_ ) { |
110
|
0
|
0
|
|
|
|
0
|
my $module = shift or last; |
111
|
0
|
|
0
|
|
|
0
|
my $version = shift || 0; |
112
|
0
|
|
|
|
|
0
|
push @added, [ $module, $version ]; |
113
|
|
|
|
|
|
|
} |
114
|
0
|
|
|
|
|
0
|
push @{ $self->{values}->{$key} }, @added; |
|
0
|
|
|
|
|
0
|
|
115
|
0
|
|
|
|
|
0
|
return map {@$_} @added; |
|
0
|
|
|
|
|
0
|
|
116
|
|
|
|
|
|
|
}; |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# Resource handling |
120
|
|
|
|
|
|
|
my %lc_resource = map { $_ => 1 } qw{ |
121
|
|
|
|
|
|
|
homepage |
122
|
|
|
|
|
|
|
license |
123
|
|
|
|
|
|
|
bugtracker |
124
|
|
|
|
|
|
|
repository |
125
|
|
|
|
|
|
|
}; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub resources { |
128
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
129
|
0
|
|
|
|
|
0
|
while ( @_ ) { |
130
|
0
|
0
|
|
|
|
0
|
my $name = shift or last; |
131
|
0
|
0
|
|
|
|
0
|
my $value = shift or next; |
132
|
0
|
0
|
0
|
|
|
0
|
if ( $name eq lc $name and ! $lc_resource{$name} ) { |
133
|
0
|
|
|
|
|
0
|
die("Unsupported reserved lowercase resource '$name'"); |
134
|
|
|
|
|
|
|
} |
135
|
0
|
|
0
|
|
|
0
|
$self->{values}->{resources} ||= []; |
136
|
0
|
|
|
|
|
0
|
push @{ $self->{values}->{resources} }, [ $name, $value ]; |
|
0
|
|
|
|
|
0
|
|
137
|
|
|
|
|
|
|
} |
138
|
0
|
|
|
|
|
0
|
$self->{values}->{resources}; |
139
|
|
|
|
|
|
|
} |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
# Aliases for build_requires that will have alternative |
142
|
|
|
|
|
|
|
# meanings in some future version of META.yml. |
143
|
0
|
|
|
0
|
0
|
0
|
sub test_requires { shift->build_requires(@_) } |
144
|
0
|
|
|
0
|
0
|
0
|
sub install_requires { shift->build_requires(@_) } |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
# Aliases for installdirs options |
147
|
0
|
|
|
0
|
0
|
0
|
sub install_as_core { $_[0]->installdirs('perl') } |
148
|
0
|
|
|
0
|
0
|
0
|
sub install_as_cpan { $_[0]->installdirs('site') } |
149
|
0
|
|
|
0
|
0
|
0
|
sub install_as_site { $_[0]->installdirs('site') } |
150
|
0
|
|
|
0
|
0
|
0
|
sub install_as_vendor { $_[0]->installdirs('vendor') } |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
sub dynamic_config { |
153
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
154
|
0
|
0
|
|
|
|
0
|
my $value = @_ ? shift : 1; |
155
|
0
|
0
|
|
|
|
0
|
if ( $self->{values}->{dynamic_config} ) { |
156
|
|
|
|
|
|
|
# Once dynamic we never change to static, for safety |
157
|
0
|
|
|
|
|
0
|
return 0; |
158
|
|
|
|
|
|
|
} |
159
|
0
|
0
|
|
|
|
0
|
$self->{values}->{dynamic_config} = $value ? 1 : 0; |
160
|
0
|
|
|
|
|
0
|
return 1; |
161
|
|
|
|
|
|
|
} |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
# Convenience command |
164
|
|
|
|
|
|
|
sub static_config { |
165
|
0
|
|
|
0
|
0
|
0
|
shift->dynamic_config(0); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
sub perl_version { |
169
|
10
|
|
|
10
|
0
|
404
|
my $self = shift; |
170
|
10
|
100
|
|
|
|
29
|
return $self->{values}->{perl_version} unless @_; |
171
|
5
|
50
|
|
|
|
8
|
my $version = shift or die( |
172
|
|
|
|
|
|
|
"Did not provide a value to perl_version()" |
173
|
|
|
|
|
|
|
); |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# Normalize the version |
176
|
5
|
|
|
|
|
9
|
$version = $self->_perl_version($version); |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# We don't support the really old versions |
179
|
5
|
50
|
|
|
|
15
|
unless ( $version >= 5.005 ) { |
180
|
0
|
|
|
|
|
0
|
die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n"; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
5
|
|
|
|
|
14
|
$self->{values}->{perl_version} = $version; |
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
sub all_from { |
187
|
0
|
|
|
0
|
0
|
0
|
my ( $self, $file ) = @_; |
188
|
|
|
|
|
|
|
|
189
|
0
|
0
|
|
|
|
0
|
unless ( defined($file) ) { |
190
|
0
|
0
|
|
|
|
0
|
my $name = $self->name or die( |
191
|
|
|
|
|
|
|
"all_from called with no args without setting name() first" |
192
|
|
|
|
|
|
|
); |
193
|
0
|
|
|
|
|
0
|
$file = join('/', 'lib', split(/-/, $name)) . '.pm'; |
194
|
0
|
0
|
|
|
|
0
|
$file =~ s{.*/}{} unless -e $file; |
195
|
0
|
0
|
|
|
|
0
|
unless ( -e $file ) { |
196
|
0
|
|
|
|
|
0
|
die("all_from cannot find $file from $name"); |
197
|
|
|
|
|
|
|
} |
198
|
|
|
|
|
|
|
} |
199
|
0
|
0
|
|
|
|
0
|
unless ( -f $file ) { |
200
|
0
|
|
|
|
|
0
|
die("The path '$file' does not exist, or is not a file"); |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
0
|
|
|
|
|
0
|
$self->{values}{all_from} = $file; |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
# Some methods pull from POD instead of code. |
206
|
|
|
|
|
|
|
# If there is a matching .pod, use that instead |
207
|
0
|
|
|
|
|
0
|
my $pod = $file; |
208
|
0
|
|
|
|
|
0
|
$pod =~ s/\.pm$/.pod/i; |
209
|
0
|
0
|
|
|
|
0
|
$pod = $file unless -e $pod; |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
# Pull the different values |
212
|
0
|
0
|
|
|
|
0
|
$self->name_from($file) unless $self->name; |
213
|
0
|
0
|
|
|
|
0
|
$self->version_from($file) unless $self->version; |
214
|
0
|
0
|
|
|
|
0
|
$self->perl_version_from($file) unless $self->perl_version; |
215
|
0
|
0
|
|
|
|
0
|
$self->author_from($pod) unless @{$self->author || []}; |
|
0
|
0
|
|
|
|
0
|
|
216
|
0
|
0
|
|
|
|
0
|
$self->license_from($pod) unless $self->license; |
217
|
0
|
0
|
|
|
|
0
|
$self->abstract_from($pod) unless $self->abstract; |
218
|
|
|
|
|
|
|
|
219
|
0
|
|
|
|
|
0
|
return 1; |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
sub provides { |
223
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
224
|
0
|
|
0
|
|
|
0
|
my $provides = ( $self->{values}->{provides} ||= {} ); |
225
|
0
|
0
|
|
|
|
0
|
%$provides = (%$provides, @_) if @_; |
226
|
0
|
|
|
|
|
0
|
return $provides; |
227
|
|
|
|
|
|
|
} |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
sub auto_provides { |
230
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
231
|
0
|
0
|
|
|
|
0
|
return $self unless $self->is_admin; |
232
|
0
|
0
|
|
|
|
0
|
unless (-e 'MANIFEST') { |
233
|
0
|
|
|
|
|
0
|
warn "Cannot deduce auto_provides without a MANIFEST, skipping\n"; |
234
|
0
|
|
|
|
|
0
|
return $self; |
235
|
|
|
|
|
|
|
} |
236
|
|
|
|
|
|
|
# Avoid spurious warnings as we are not checking manifest here. |
237
|
0
|
|
|
0
|
|
0
|
local $SIG{__WARN__} = sub {1}; |
|
0
|
|
|
|
|
0
|
|
238
|
0
|
|
|
|
|
0
|
require ExtUtils::Manifest; |
239
|
0
|
|
|
0
|
|
0
|
local *ExtUtils::Manifest::manicheck = sub { return }; |
|
0
|
|
|
|
|
0
|
|
240
|
|
|
|
|
|
|
|
241
|
0
|
|
|
|
|
0
|
require Module::Build; |
242
|
0
|
|
|
|
|
0
|
my $build = Module::Build->new( |
243
|
|
|
|
|
|
|
dist_name => $self->name, |
244
|
|
|
|
|
|
|
dist_version => $self->version, |
245
|
|
|
|
|
|
|
license => $self->license, |
246
|
|
|
|
|
|
|
); |
247
|
0
|
0
|
|
|
|
0
|
$self->provides( %{ $build->find_dist_packages || {} } ); |
|
0
|
|
|
|
|
0
|
|
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
|
250
|
|
|
|
|
|
|
sub feature { |
251
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
252
|
0
|
|
|
|
|
0
|
my $name = shift; |
253
|
0
|
|
0
|
|
|
0
|
my $features = ( $self->{values}->{features} ||= [] ); |
254
|
0
|
|
|
|
|
0
|
my $mods; |
255
|
|
|
|
|
|
|
|
256
|
0
|
0
|
0
|
|
|
0
|
if ( @_ == 1 and ref( $_[0] ) ) { |
257
|
|
|
|
|
|
|
# The user used ->feature like ->features by passing in the second |
258
|
|
|
|
|
|
|
# argument as a reference. Accomodate for that. |
259
|
0
|
|
|
|
|
0
|
$mods = $_[0]; |
260
|
|
|
|
|
|
|
} else { |
261
|
0
|
|
|
|
|
0
|
$mods = \@_; |
262
|
|
|
|
|
|
|
} |
263
|
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
0
|
my $count = 0; |
265
|
|
|
|
|
|
|
push @$features, ( |
266
|
|
|
|
|
|
|
$name => [ |
267
|
|
|
|
|
|
|
map { |
268
|
0
|
0
|
|
|
|
0
|
ref($_) ? ( ref($_) eq 'HASH' ) ? %$_ : @$_ : $_ |
|
0
|
0
|
|
|
|
0
|
|
269
|
|
|
|
|
|
|
} @$mods |
270
|
|
|
|
|
|
|
] |
271
|
|
|
|
|
|
|
); |
272
|
|
|
|
|
|
|
|
273
|
0
|
|
|
|
|
0
|
return @$features; |
274
|
|
|
|
|
|
|
} |
275
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
sub features { |
277
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
278
|
0
|
|
|
|
|
0
|
while ( my ( $name, $mods ) = splice( @_, 0, 2 ) ) { |
279
|
0
|
|
|
|
|
0
|
$self->feature( $name, @$mods ); |
280
|
|
|
|
|
|
|
} |
281
|
|
|
|
|
|
|
return $self->{values}->{features} |
282
|
0
|
0
|
|
|
|
0
|
? @{ $self->{values}->{features} } |
|
0
|
|
|
|
|
0
|
|
283
|
|
|
|
|
|
|
: (); |
284
|
|
|
|
|
|
|
} |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
sub no_index { |
287
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
288
|
0
|
|
|
|
|
0
|
my $type = shift; |
289
|
0
|
0
|
|
|
|
0
|
push @{ $self->{values}->{no_index}->{$type} }, @_ if $type; |
|
0
|
|
|
|
|
0
|
|
290
|
0
|
|
|
|
|
0
|
return $self->{values}->{no_index}; |
291
|
|
|
|
|
|
|
} |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
sub read { |
294
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
295
|
0
|
|
|
|
|
0
|
$self->include_deps( 'YAML::Tiny', 0 ); |
296
|
|
|
|
|
|
|
|
297
|
0
|
|
|
|
|
0
|
require YAML::Tiny; |
298
|
0
|
|
|
|
|
0
|
my $data = YAML::Tiny::LoadFile('META.yml'); |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
# Call methods explicitly in case user has already set some values. |
301
|
0
|
|
|
|
|
0
|
while ( my ( $key, $value ) = each %$data ) { |
302
|
0
|
0
|
|
|
|
0
|
next unless $self->can($key); |
303
|
0
|
0
|
|
|
|
0
|
if ( ref $value eq 'HASH' ) { |
304
|
0
|
|
|
|
|
0
|
while ( my ( $module, $version ) = each %$value ) { |
305
|
0
|
|
|
|
|
0
|
$self->can($key)->($self, $module => $version ); |
306
|
|
|
|
|
|
|
} |
307
|
|
|
|
|
|
|
} else { |
308
|
0
|
|
|
|
|
0
|
$self->can($key)->($self, $value); |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
} |
311
|
0
|
|
|
|
|
0
|
return $self; |
312
|
|
|
|
|
|
|
} |
313
|
|
|
|
|
|
|
|
314
|
|
|
|
|
|
|
sub write { |
315
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
316
|
0
|
0
|
|
|
|
0
|
return $self unless $self->is_admin; |
317
|
0
|
|
|
|
|
0
|
$self->admin->write_meta; |
318
|
0
|
|
|
|
|
0
|
return $self; |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
|
321
|
|
|
|
|
|
|
sub version_from { |
322
|
0
|
|
|
0
|
0
|
0
|
require ExtUtils::MM_Unix; |
323
|
0
|
|
|
|
|
0
|
my ( $self, $file ) = @_; |
324
|
0
|
|
|
|
|
0
|
$self->version( ExtUtils::MM_Unix->parse_version($file) ); |
325
|
|
|
|
|
|
|
|
326
|
|
|
|
|
|
|
# for version integrity check |
327
|
0
|
|
|
|
|
0
|
$self->makemaker_args( VERSION_FROM => $file ); |
328
|
|
|
|
|
|
|
} |
329
|
|
|
|
|
|
|
|
330
|
|
|
|
|
|
|
sub abstract_from { |
331
|
0
|
|
|
0
|
0
|
0
|
require ExtUtils::MM_Unix; |
332
|
0
|
|
|
|
|
0
|
my ( $self, $file ) = @_; |
333
|
0
|
|
|
|
|
0
|
$self->abstract( |
334
|
|
|
|
|
|
|
bless( |
335
|
|
|
|
|
|
|
{ DISTNAME => $self->name }, |
336
|
|
|
|
|
|
|
'ExtUtils::MM_Unix' |
337
|
|
|
|
|
|
|
)->parse_abstract($file) |
338
|
|
|
|
|
|
|
); |
339
|
|
|
|
|
|
|
} |
340
|
|
|
|
|
|
|
|
341
|
|
|
|
|
|
|
# Add both distribution and module name |
342
|
|
|
|
|
|
|
sub name_from { |
343
|
0
|
|
|
0
|
0
|
0
|
my ($self, $file) = @_; |
344
|
0
|
0
|
|
|
|
0
|
if ( |
345
|
|
|
|
|
|
|
Module::Install::_read($file) =~ m/ |
346
|
|
|
|
|
|
|
^ \s* |
347
|
|
|
|
|
|
|
package \s* |
348
|
|
|
|
|
|
|
([\w:]+) |
349
|
|
|
|
|
|
|
[\s|;]* |
350
|
|
|
|
|
|
|
/ixms |
351
|
|
|
|
|
|
|
) { |
352
|
0
|
|
|
|
|
0
|
my ($name, $module_name) = ($1, $1); |
353
|
0
|
|
|
|
|
0
|
$name =~ s{::}{-}g; |
354
|
0
|
|
|
|
|
0
|
$self->name($name); |
355
|
0
|
0
|
|
|
|
0
|
unless ( $self->module_name ) { |
356
|
0
|
|
|
|
|
0
|
$self->module_name($module_name); |
357
|
|
|
|
|
|
|
} |
358
|
|
|
|
|
|
|
} else { |
359
|
0
|
|
|
|
|
0
|
die("Cannot determine name from $file\n"); |
360
|
|
|
|
|
|
|
} |
361
|
|
|
|
|
|
|
} |
362
|
|
|
|
|
|
|
|
363
|
|
|
|
|
|
|
sub _extract_perl_version { |
364
|
3
|
100
|
|
3
|
|
797
|
if ( |
365
|
|
|
|
|
|
|
$_[0] =~ m/ |
366
|
|
|
|
|
|
|
^\s* |
367
|
|
|
|
|
|
|
(?:use|require) \s* |
368
|
|
|
|
|
|
|
v? |
369
|
|
|
|
|
|
|
([\d_\.]+) |
370
|
|
|
|
|
|
|
\s* ; |
371
|
|
|
|
|
|
|
/ixms |
372
|
|
|
|
|
|
|
) { |
373
|
2
|
|
|
|
|
4
|
my $perl_version = $1; |
374
|
2
|
|
|
|
|
2
|
$perl_version =~ s{_}{}g; |
375
|
2
|
|
|
|
|
4
|
return $perl_version; |
376
|
|
|
|
|
|
|
} else { |
377
|
1
|
|
|
|
|
2
|
return; |
378
|
|
|
|
|
|
|
} |
379
|
|
|
|
|
|
|
} |
380
|
|
|
|
|
|
|
|
381
|
|
|
|
|
|
|
sub perl_version_from { |
382
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
383
|
0
|
|
|
|
|
0
|
my $perl_version=_extract_perl_version(Module::Install::_read($_[0])); |
384
|
0
|
0
|
|
|
|
0
|
if ($perl_version) { |
385
|
0
|
|
|
|
|
0
|
$self->perl_version($perl_version); |
386
|
|
|
|
|
|
|
} else { |
387
|
0
|
|
|
|
|
0
|
warn "Cannot determine perl version info from $_[0]\n"; |
388
|
0
|
|
|
|
|
0
|
return; |
389
|
|
|
|
|
|
|
} |
390
|
|
|
|
|
|
|
} |
391
|
|
|
|
|
|
|
|
392
|
|
|
|
|
|
|
sub author_from { |
393
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
394
|
0
|
|
|
|
|
0
|
my $content = Module::Install::_read($_[0]); |
395
|
0
|
0
|
|
|
|
0
|
if ($content =~ m/ |
396
|
|
|
|
|
|
|
=head \d \s+ (?:authors?)\b \s* |
397
|
|
|
|
|
|
|
([^\n]*) |
398
|
|
|
|
|
|
|
| |
399
|
|
|
|
|
|
|
=head \d \s+ (?:licen[cs]e|licensing|copyright|legal)\b \s* |
400
|
|
|
|
|
|
|
.*? copyright .*? \d\d\d[\d.]+ \s* (?:\bby\b)? \s* |
401
|
|
|
|
|
|
|
([^\n]*) |
402
|
|
|
|
|
|
|
/ixms) { |
403
|
0
|
|
0
|
|
|
0
|
my $author = $1 || $2; |
404
|
|
|
|
|
|
|
|
405
|
|
|
|
|
|
|
# XXX: ugly but should work anyway... |
406
|
0
|
0
|
0
|
|
|
0
|
if (eval "require Pod::Escapes; 1") { |
|
|
0
|
|
|
|
|
|
407
|
|
|
|
|
|
|
# Pod::Escapes has a mapping table. |
408
|
|
|
|
|
|
|
# It's in core of perl >= 5.9.3, and should be installed |
409
|
|
|
|
|
|
|
# as one of the Pod::Simple's prereqs, which is a prereq |
410
|
|
|
|
|
|
|
# of Pod::Text 3.x (see also below). |
411
|
0
|
|
|
|
|
0
|
$author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } |
412
|
|
|
|
|
|
|
{ |
413
|
|
|
|
|
|
|
defined $2 |
414
|
|
|
|
|
|
|
? chr($2) |
415
|
|
|
|
|
|
|
: defined $Pod::Escapes::Name2character_number{$1} |
416
|
|
|
|
|
|
|
? chr($Pod::Escapes::Name2character_number{$1}) |
417
|
0
|
0
|
|
|
|
0
|
: do { |
|
|
0
|
|
|
|
|
|
418
|
0
|
|
|
|
|
0
|
warn "Unknown escape: E<$1>"; |
419
|
0
|
|
|
|
|
0
|
"E<$1>"; |
420
|
|
|
|
|
|
|
}; |
421
|
|
|
|
|
|
|
}gex; |
422
|
|
|
|
|
|
|
} |
423
|
|
|
|
|
|
|
elsif (eval "require Pod::Text; 1" && $Pod::Text::VERSION < 3) { |
424
|
|
|
|
|
|
|
# Pod::Text < 3.0 has yet another mapping table, |
425
|
|
|
|
|
|
|
# though the table name of 2.x and 1.x are different. |
426
|
|
|
|
|
|
|
# (1.x is in core of Perl < 5.6, 2.x is in core of |
427
|
|
|
|
|
|
|
# Perl < 5.9.3) |
428
|
0
|
0
|
|
|
|
0
|
my $mapping = ($Pod::Text::VERSION < 2) |
429
|
|
|
|
|
|
|
? \%Pod::Text::HTML_Escapes |
430
|
|
|
|
|
|
|
: \%Pod::Text::ESCAPES; |
431
|
0
|
|
|
|
|
0
|
$author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } |
432
|
|
|
|
|
|
|
{ |
433
|
|
|
|
|
|
|
defined $2 |
434
|
|
|
|
|
|
|
? chr($2) |
435
|
|
|
|
|
|
|
: defined $mapping->{$1} |
436
|
|
|
|
|
|
|
? $mapping->{$1} |
437
|
0
|
0
|
|
|
|
0
|
: do { |
|
|
0
|
|
|
|
|
|
438
|
0
|
|
|
|
|
0
|
warn "Unknown escape: E<$1>"; |
439
|
0
|
|
|
|
|
0
|
"E<$1>"; |
440
|
|
|
|
|
|
|
}; |
441
|
|
|
|
|
|
|
}gex; |
442
|
|
|
|
|
|
|
} |
443
|
|
|
|
|
|
|
else { |
444
|
0
|
|
|
|
|
0
|
$author =~ s{E}{<}g; |
445
|
0
|
|
|
|
|
0
|
$author =~ s{E}{>}g; |
446
|
|
|
|
|
|
|
} |
447
|
0
|
|
|
|
|
0
|
$self->author($author); |
448
|
|
|
|
|
|
|
} else { |
449
|
0
|
|
|
|
|
0
|
warn "Cannot determine author info from $_[0]\n"; |
450
|
|
|
|
|
|
|
} |
451
|
|
|
|
|
|
|
} |
452
|
|
|
|
|
|
|
|
453
|
|
|
|
|
|
|
#Stolen from M::B |
454
|
|
|
|
|
|
|
my %license_urls = ( |
455
|
|
|
|
|
|
|
perl => 'http://dev.perl.org/licenses/', |
456
|
|
|
|
|
|
|
apache => 'http://apache.org/licenses/LICENSE-2.0', |
457
|
|
|
|
|
|
|
apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1', |
458
|
|
|
|
|
|
|
artistic => 'http://opensource.org/licenses/artistic-license.php', |
459
|
|
|
|
|
|
|
artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php', |
460
|
|
|
|
|
|
|
lgpl => 'http://opensource.org/licenses/lgpl-license.php', |
461
|
|
|
|
|
|
|
lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php', |
462
|
|
|
|
|
|
|
lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html', |
463
|
|
|
|
|
|
|
bsd => 'http://opensource.org/licenses/bsd-license.php', |
464
|
|
|
|
|
|
|
gpl => 'http://opensource.org/licenses/gpl-license.php', |
465
|
|
|
|
|
|
|
gpl2 => 'http://opensource.org/licenses/gpl-2.0.php', |
466
|
|
|
|
|
|
|
gpl3 => 'http://opensource.org/licenses/gpl-3.0.html', |
467
|
|
|
|
|
|
|
mit => 'http://opensource.org/licenses/mit-license.php', |
468
|
|
|
|
|
|
|
mozilla => 'http://opensource.org/licenses/mozilla1.1.php', |
469
|
|
|
|
|
|
|
open_source => undef, |
470
|
|
|
|
|
|
|
unrestricted => undef, |
471
|
|
|
|
|
|
|
restrictive => undef, |
472
|
|
|
|
|
|
|
unknown => undef, |
473
|
|
|
|
|
|
|
); |
474
|
|
|
|
|
|
|
|
475
|
|
|
|
|
|
|
sub license { |
476
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
477
|
0
|
0
|
|
|
|
0
|
return $self->{values}->{license} unless @_; |
478
|
0
|
0
|
|
|
|
0
|
my $license = shift or die( |
479
|
|
|
|
|
|
|
'Did not provide a value to license()' |
480
|
|
|
|
|
|
|
); |
481
|
0
|
|
0
|
|
|
0
|
$license = __extract_license($license) || lc $license; |
482
|
0
|
|
|
|
|
0
|
$self->{values}->{license} = $license; |
483
|
|
|
|
|
|
|
|
484
|
|
|
|
|
|
|
# Automatically fill in license URLs |
485
|
0
|
0
|
|
|
|
0
|
if ( $license_urls{$license} ) { |
486
|
0
|
|
|
|
|
0
|
$self->resources( license => $license_urls{$license} ); |
487
|
|
|
|
|
|
|
} |
488
|
|
|
|
|
|
|
|
489
|
0
|
|
|
|
|
0
|
return 1; |
490
|
|
|
|
|
|
|
} |
491
|
|
|
|
|
|
|
|
492
|
|
|
|
|
|
|
sub _extract_license { |
493
|
9
|
|
|
9
|
|
2003
|
my $pod = shift; |
494
|
9
|
|
|
|
|
7
|
my $matched; |
495
|
9
|
|
66
|
|
|
100
|
return __extract_license( |
496
|
|
|
|
|
|
|
($matched) = $pod =~ m/ |
497
|
|
|
|
|
|
|
(=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) |
498
|
|
|
|
|
|
|
(=head \d.*|=cut.*|)\z |
499
|
|
|
|
|
|
|
/xms |
500
|
|
|
|
|
|
|
) || __extract_license( |
501
|
|
|
|
|
|
|
($matched) = $pod =~ m/ |
502
|
|
|
|
|
|
|
(=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) |
503
|
|
|
|
|
|
|
(=head \d.*|=cut.*|)\z |
504
|
|
|
|
|
|
|
/xms |
505
|
|
|
|
|
|
|
); |
506
|
|
|
|
|
|
|
} |
507
|
|
|
|
|
|
|
|
508
|
|
|
|
|
|
|
sub __extract_license { |
509
|
14
|
100
|
|
14
|
|
103
|
my $license_text = shift or return; |
510
|
9
|
|
|
|
|
62
|
my @phrases = ( |
511
|
|
|
|
|
|
|
'(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1, |
512
|
|
|
|
|
|
|
'(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1, |
513
|
|
|
|
|
|
|
'Artistic and GPL' => 'perl', 1, |
514
|
|
|
|
|
|
|
'GNU general public license' => 'gpl', 1, |
515
|
|
|
|
|
|
|
'GNU public license' => 'gpl', 1, |
516
|
|
|
|
|
|
|
'GNU lesser general public license' => 'lgpl', 1, |
517
|
|
|
|
|
|
|
'GNU lesser public license' => 'lgpl', 1, |
518
|
|
|
|
|
|
|
'GNU library general public license' => 'lgpl', 1, |
519
|
|
|
|
|
|
|
'GNU library public license' => 'lgpl', 1, |
520
|
|
|
|
|
|
|
'GNU Free Documentation license' => 'unrestricted', 1, |
521
|
|
|
|
|
|
|
'GNU Affero General Public License' => 'open_source', 1, |
522
|
|
|
|
|
|
|
'(?:Free)?BSD license' => 'bsd', 1, |
523
|
|
|
|
|
|
|
'Artistic license 2\.0' => 'artistic_2', 1, |
524
|
|
|
|
|
|
|
'Artistic license' => 'artistic', 1, |
525
|
|
|
|
|
|
|
'Apache (?:Software )?license' => 'apache', 1, |
526
|
|
|
|
|
|
|
'GPL' => 'gpl', 1, |
527
|
|
|
|
|
|
|
'LGPL' => 'lgpl', 1, |
528
|
|
|
|
|
|
|
'BSD' => 'bsd', 1, |
529
|
|
|
|
|
|
|
'Artistic' => 'artistic', 1, |
530
|
|
|
|
|
|
|
'MIT' => 'mit', 1, |
531
|
|
|
|
|
|
|
'Mozilla Public License' => 'mozilla', 1, |
532
|
|
|
|
|
|
|
'Q Public License' => 'open_source', 1, |
533
|
|
|
|
|
|
|
'OpenSSL License' => 'unrestricted', 1, |
534
|
|
|
|
|
|
|
'SSLeay License' => 'unrestricted', 1, |
535
|
|
|
|
|
|
|
'zlib License' => 'open_source', 1, |
536
|
|
|
|
|
|
|
'proprietary' => 'proprietary', 0, |
537
|
|
|
|
|
|
|
); |
538
|
9
|
|
|
|
|
27
|
while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) { |
539
|
38
|
|
|
|
|
127
|
$pattern =~ s#\s+#\\s+#gs; |
540
|
38
|
100
|
|
|
|
558
|
if ( $license_text =~ /\b$pattern\b/i ) { |
541
|
9
|
|
|
|
|
50
|
return $license; |
542
|
|
|
|
|
|
|
} |
543
|
|
|
|
|
|
|
} |
544
|
0
|
|
|
|
|
0
|
return ''; |
545
|
|
|
|
|
|
|
} |
546
|
|
|
|
|
|
|
|
547
|
|
|
|
|
|
|
sub license_from { |
548
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
549
|
0
|
0
|
|
|
|
0
|
if (my $license=_extract_license(Module::Install::_read($_[0]))) { |
550
|
0
|
|
|
|
|
0
|
$self->license($license); |
551
|
|
|
|
|
|
|
} else { |
552
|
0
|
|
|
|
|
0
|
warn "Cannot determine license info from $_[0]\n"; |
553
|
0
|
|
|
|
|
0
|
return 'unknown'; |
554
|
|
|
|
|
|
|
} |
555
|
|
|
|
|
|
|
} |
556
|
|
|
|
|
|
|
|
557
|
|
|
|
|
|
|
sub _extract_bugtracker { |
558
|
6
|
|
|
6
|
|
1940
|
my @links = $_[0] =~ m#L<( |
559
|
|
|
|
|
|
|
https?\Q://rt.cpan.org/\E[^>]+| |
560
|
|
|
|
|
|
|
https?\Q://github.com/\E[\w_]+/[\w_]+/issues| |
561
|
|
|
|
|
|
|
https?\Q://code.google.com/p/\E[\w_\-]+/issues/list |
562
|
|
|
|
|
|
|
)>#gx; |
563
|
6
|
|
|
|
|
6
|
my %links; |
564
|
6
|
|
|
|
|
12
|
@links{@links}=(); |
565
|
6
|
|
|
|
|
11
|
@links=keys %links; |
566
|
6
|
|
|
|
|
15
|
return @links; |
567
|
|
|
|
|
|
|
} |
568
|
|
|
|
|
|
|
|
569
|
|
|
|
|
|
|
sub bugtracker_from { |
570
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
571
|
0
|
|
|
|
|
0
|
my $content = Module::Install::_read($_[0]); |
572
|
0
|
|
|
|
|
0
|
my @links = _extract_bugtracker($content); |
573
|
0
|
0
|
|
|
|
0
|
unless ( @links ) { |
574
|
0
|
|
|
|
|
0
|
warn "Cannot determine bugtracker info from $_[0]\n"; |
575
|
0
|
|
|
|
|
0
|
return 0; |
576
|
|
|
|
|
|
|
} |
577
|
0
|
0
|
|
|
|
0
|
if ( @links > 1 ) { |
578
|
0
|
|
|
|
|
0
|
warn "Found more than one bugtracker link in $_[0]\n"; |
579
|
0
|
|
|
|
|
0
|
return 0; |
580
|
|
|
|
|
|
|
} |
581
|
|
|
|
|
|
|
|
582
|
|
|
|
|
|
|
# Set the bugtracker |
583
|
0
|
|
|
|
|
0
|
bugtracker( $links[0] ); |
584
|
0
|
|
|
|
|
0
|
return 1; |
585
|
|
|
|
|
|
|
} |
586
|
|
|
|
|
|
|
|
587
|
|
|
|
|
|
|
sub requires_from { |
588
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
589
|
0
|
|
|
|
|
0
|
my $content = Module::Install::_readperl($_[0]); |
590
|
0
|
|
|
|
|
0
|
my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg; |
591
|
0
|
|
|
|
|
0
|
while ( @requires ) { |
592
|
0
|
|
|
|
|
0
|
my $module = shift @requires; |
593
|
0
|
|
|
|
|
0
|
my $version = shift @requires; |
594
|
0
|
|
|
|
|
0
|
$self->requires( $module => $version ); |
595
|
|
|
|
|
|
|
} |
596
|
|
|
|
|
|
|
} |
597
|
|
|
|
|
|
|
|
598
|
|
|
|
|
|
|
sub test_requires_from { |
599
|
0
|
|
|
0
|
0
|
0
|
my $self = shift; |
600
|
0
|
|
|
|
|
0
|
my $content = Module::Install::_readperl($_[0]); |
601
|
0
|
|
|
|
|
0
|
my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; |
602
|
0
|
|
|
|
|
0
|
while ( @requires ) { |
603
|
0
|
|
|
|
|
0
|
my $module = shift @requires; |
604
|
0
|
|
|
|
|
0
|
my $version = shift @requires; |
605
|
0
|
|
|
|
|
0
|
$self->test_requires( $module => $version ); |
606
|
|
|
|
|
|
|
} |
607
|
|
|
|
|
|
|
} |
608
|
|
|
|
|
|
|
|
609
|
|
|
|
|
|
|
# Convert triple-part versions (eg, 5.6.1 or 5.8.9) to |
610
|
|
|
|
|
|
|
# numbers (eg, 5.006001 or 5.008009). |
611
|
|
|
|
|
|
|
# Also, convert double-part versions (eg, 5.8) |
612
|
|
|
|
|
|
|
sub _perl_version { |
613
|
13
|
|
|
13
|
|
2439
|
my $v = $_[-1]; |
614
|
13
|
|
|
|
|
47
|
$v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e; |
|
6
|
|
|
|
|
36
|
|
615
|
13
|
|
100
|
|
|
26
|
$v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e; |
|
4
|
|
|
|
|
32
|
|
616
|
13
|
|
|
|
|
14
|
$v =~ s/(\.\d\d\d)000$/$1/; |
617
|
13
|
|
|
|
|
12
|
$v =~ s/_.+$//; |
618
|
13
|
50
|
|
|
|
22
|
if ( ref($v) ) { |
619
|
|
|
|
|
|
|
# Numify |
620
|
0
|
|
|
|
|
0
|
$v = $v + 0; |
621
|
|
|
|
|
|
|
} |
622
|
13
|
|
|
|
|
41
|
return $v; |
623
|
|
|
|
|
|
|
} |
624
|
|
|
|
|
|
|
|
625
|
|
|
|
|
|
|
sub add_metadata { |
626
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
627
|
0
|
|
|
|
|
|
my %hash = @_; |
628
|
0
|
|
|
|
|
|
for my $key (keys %hash) { |
629
|
0
|
0
|
|
|
|
|
warn "add_metadata: $key is not prefixed with 'x_'.\n" . |
630
|
|
|
|
|
|
|
"Use appopriate function to add non-private metadata.\n" unless $key =~ /^x_/; |
631
|
0
|
|
|
|
|
|
$self->{values}->{$key} = $hash{$key}; |
632
|
|
|
|
|
|
|
} |
633
|
|
|
|
|
|
|
} |
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
###################################################################### |
637
|
|
|
|
|
|
|
# MYMETA Support |
638
|
|
|
|
|
|
|
|
639
|
|
|
|
|
|
|
sub WriteMyMeta { |
640
|
0
|
|
|
0
|
0
|
|
die "WriteMyMeta has been deprecated"; |
641
|
|
|
|
|
|
|
} |
642
|
|
|
|
|
|
|
|
643
|
|
|
|
|
|
|
sub write_mymeta_yaml { |
644
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
645
|
|
|
|
|
|
|
|
646
|
|
|
|
|
|
|
# We need YAML::Tiny to write the MYMETA.yml file |
647
|
0
|
0
|
|
|
|
|
unless ( eval { require YAML::Tiny; 1; } ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
648
|
0
|
|
|
|
|
|
return 1; |
649
|
|
|
|
|
|
|
} |
650
|
|
|
|
|
|
|
|
651
|
|
|
|
|
|
|
# Generate the data |
652
|
0
|
0
|
|
|
|
|
my $meta = $self->_write_mymeta_data or return 1; |
653
|
|
|
|
|
|
|
|
654
|
|
|
|
|
|
|
# Save as the MYMETA.yml file |
655
|
0
|
|
|
|
|
|
print "Writing MYMETA.yml\n"; |
656
|
0
|
|
|
|
|
|
YAML::Tiny::DumpFile('MYMETA.yml', $meta); |
657
|
|
|
|
|
|
|
} |
658
|
|
|
|
|
|
|
|
659
|
|
|
|
|
|
|
sub write_mymeta_json { |
660
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
661
|
|
|
|
|
|
|
|
662
|
|
|
|
|
|
|
# We need JSON to write the MYMETA.json file |
663
|
0
|
0
|
|
|
|
|
unless ( eval { require JSON; 1; } ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
664
|
0
|
|
|
|
|
|
return 1; |
665
|
|
|
|
|
|
|
} |
666
|
|
|
|
|
|
|
|
667
|
|
|
|
|
|
|
# Generate the data |
668
|
0
|
0
|
|
|
|
|
my $meta = $self->_write_mymeta_data or return 1; |
669
|
|
|
|
|
|
|
|
670
|
|
|
|
|
|
|
# Save as the MYMETA.yml file |
671
|
0
|
|
|
|
|
|
print "Writing MYMETA.json\n"; |
672
|
0
|
|
|
|
|
|
Module::Install::_write( |
673
|
|
|
|
|
|
|
'MYMETA.json', |
674
|
|
|
|
|
|
|
JSON->new->pretty(1)->canonical->encode($meta), |
675
|
|
|
|
|
|
|
); |
676
|
|
|
|
|
|
|
} |
677
|
|
|
|
|
|
|
|
678
|
|
|
|
|
|
|
sub _write_mymeta_data { |
679
|
0
|
|
|
0
|
|
|
my $self = shift; |
680
|
|
|
|
|
|
|
|
681
|
|
|
|
|
|
|
# If there's no existing META.yml there is nothing we can do |
682
|
0
|
0
|
|
|
|
|
return undef unless -f 'META.yml'; |
683
|
|
|
|
|
|
|
|
684
|
|
|
|
|
|
|
# We need Parse::CPAN::Meta to load the file |
685
|
0
|
0
|
|
|
|
|
unless ( eval { require Parse::CPAN::Meta; 1; } ) { |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
686
|
0
|
|
|
|
|
|
return undef; |
687
|
|
|
|
|
|
|
} |
688
|
|
|
|
|
|
|
|
689
|
|
|
|
|
|
|
# Merge the perl version into the dependencies |
690
|
0
|
|
|
|
|
|
my $val = $self->Meta->{values}; |
691
|
0
|
|
|
|
|
|
my $perl = delete $val->{perl_version}; |
692
|
0
|
0
|
|
|
|
|
if ( $perl ) { |
693
|
0
|
|
0
|
|
|
|
$val->{requires} ||= []; |
694
|
0
|
|
|
|
|
|
my $requires = $val->{requires}; |
695
|
|
|
|
|
|
|
|
696
|
|
|
|
|
|
|
# Canonize to three-dot version after Perl 5.6 |
697
|
0
|
0
|
|
|
|
|
if ( $perl >= 5.006 ) { |
698
|
0
|
|
0
|
|
|
|
$perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e |
|
0
|
|
0
|
|
|
|
|
699
|
|
|
|
|
|
|
} |
700
|
0
|
|
|
|
|
|
unshift @$requires, [ perl => $perl ]; |
701
|
|
|
|
|
|
|
} |
702
|
|
|
|
|
|
|
|
703
|
|
|
|
|
|
|
# Load the advisory META.yml file |
704
|
0
|
|
|
|
|
|
my @yaml = Parse::CPAN::Meta::LoadFile('META.yml'); |
705
|
0
|
|
|
|
|
|
my $meta = $yaml[0]; |
706
|
|
|
|
|
|
|
|
707
|
|
|
|
|
|
|
# Overwrite the non-configure dependency hashes |
708
|
0
|
|
|
|
|
|
delete $meta->{requires}; |
709
|
0
|
|
|
|
|
|
delete $meta->{build_requires}; |
710
|
0
|
|
|
|
|
|
delete $meta->{recommends}; |
711
|
0
|
0
|
|
|
|
|
if ( exists $val->{requires} ) { |
712
|
0
|
|
|
|
|
|
$meta->{requires} = { map { @$_ } @{ $val->{requires} } }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
} |
714
|
0
|
0
|
|
|
|
|
if ( exists $val->{build_requires} ) { |
715
|
0
|
|
|
|
|
|
$meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
} |
717
|
|
|
|
|
|
|
|
718
|
0
|
|
|
|
|
|
return $meta; |
719
|
|
|
|
|
|
|
} |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
1; |