line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Install::Metadata; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
113437
|
use strict 'vars'; |
|
4
|
|
|
|
|
19
|
|
|
4
|
|
|
|
|
150
|
|
4
|
4
|
|
|
4
|
|
1360
|
use Module::Install::Base (); |
|
4
|
|
|
|
|
10
|
|
|
4
|
|
|
|
|
95
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
24
|
use vars qw{$VERSION @ISA $ISCORE}; |
|
4
|
|
|
|
|
18
|
|
|
4
|
|
|
|
|
296
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
4
|
|
|
4
|
|
19
|
$VERSION = '1.21'; |
9
|
4
|
|
|
|
|
71
|
@ISA = 'Module::Install::Base'; |
10
|
4
|
|
|
|
|
25222
|
$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
|
780
|
my $self = shift; |
170
|
10
|
100
|
|
|
|
41
|
return $self->{values}->{perl_version} unless @_; |
171
|
5
|
50
|
|
|
|
13
|
my $version = shift or die( |
172
|
|
|
|
|
|
|
"Did not provide a value to perl_version()" |
173
|
|
|
|
|
|
|
); |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
# Normalize the version |
176
|
5
|
|
|
|
|
13
|
$version = $self->_perl_version($version); |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
# We don't support the really old versions |
179
|
5
|
50
|
|
|
|
23
|
unless ( $version >= 5.005 ) { |
180
|
0
|
|
|
|
|
0
|
die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n"; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
5
|
|
|
|
|
18
|
$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
|
|
2385
|
if ( |
365
|
|
|
|
|
|
|
$_[0] =~ m/ |
366
|
|
|
|
|
|
|
^\s* |
367
|
|
|
|
|
|
|
(?:use|require) \s* |
368
|
|
|
|
|
|
|
v? |
369
|
|
|
|
|
|
|
([\d_\.]+) |
370
|
|
|
|
|
|
|
\s* ; |
371
|
|
|
|
|
|
|
/ixms |
372
|
|
|
|
|
|
|
) { |
373
|
2
|
|
|
|
|
8
|
my $perl_version = $1; |
374
|
2
|
|
|
|
|
4
|
$perl_version =~ s{_}{}g; |
375
|
2
|
|
|
|
|
7
|
return $perl_version; |
376
|
|
|
|
|
|
|
} else { |
377
|
1
|
|
|
|
|
4
|
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
|
0
|
0
|
|
|
|
0
|
? chr($Pod::Escapes::Name2character_number{$1}) |
|
|
0
|
|
|
|
|
|
417
|
0
|
|
|
|
|
0
|
: do { |
418
|
0
|
|
|
|
|
0
|
warn "Unknown escape: E<$1>"; |
419
|
|
|
|
|
|
|
"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
|
0
|
0
|
|
|
|
0
|
# Perl < 5.9.3) |
428
|
|
|
|
|
|
|
my $mapping = ($Pod::Text::VERSION < 2) |
429
|
|
|
|
|
|
|
? \%Pod::Text::HTML_Escapes |
430
|
0
|
|
|
|
|
0
|
: \%Pod::Text::ESCAPES; |
431
|
|
|
|
|
|
|
$author =~ s{ E<( (\d+) | ([A-Za-z]+) )> } |
432
|
|
|
|
|
|
|
{ |
433
|
|
|
|
|
|
|
defined $2 |
434
|
|
|
|
|
|
|
? chr($2) |
435
|
0
|
0
|
|
|
|
0
|
: defined $mapping->{$1} |
|
|
0
|
|
|
|
|
|
436
|
0
|
|
|
|
|
0
|
? $mapping->{$1} |
437
|
0
|
|
|
|
|
0
|
: do { |
438
|
|
|
|
|
|
|
warn "Unknown escape: E<$1>"; |
439
|
|
|
|
|
|
|
"E<$1>"; |
440
|
|
|
|
|
|
|
}; |
441
|
|
|
|
|
|
|
}gex; |
442
|
0
|
|
|
|
|
0
|
} |
443
|
0
|
|
|
|
|
0
|
else { |
444
|
|
|
|
|
|
|
$author =~ s{E<lt>}{<}g; |
445
|
0
|
|
|
|
|
0
|
$author =~ s{E<gt>}{>}g; |
446
|
|
|
|
|
|
|
} |
447
|
0
|
|
|
|
|
0
|
$self->author($author); |
448
|
|
|
|
|
|
|
} else { |
449
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
artistic => 'http://opensource.org/licenses/artistic-license.php', |
458
|
|
|
|
|
|
|
lgpl => 'http://opensource.org/licenses/lgpl-license.php', |
459
|
|
|
|
|
|
|
bsd => 'http://opensource.org/licenses/bsd-license.php', |
460
|
|
|
|
|
|
|
gpl => 'http://opensource.org/licenses/gpl-license.php', |
461
|
|
|
|
|
|
|
gpl2 => 'http://opensource.org/licenses/gpl-2.0.php', |
462
|
|
|
|
|
|
|
gpl3 => 'http://opensource.org/licenses/gpl-3.0.html', |
463
|
|
|
|
|
|
|
mit => 'http://opensource.org/licenses/mit-license.php', |
464
|
|
|
|
|
|
|
mozilla => 'http://opensource.org/licenses/mozilla1.1.php', |
465
|
|
|
|
|
|
|
open_source => undef, |
466
|
|
|
|
|
|
|
unrestricted => undef, |
467
|
|
|
|
|
|
|
restrictive => undef, |
468
|
|
|
|
|
|
|
unknown => undef, |
469
|
|
|
|
|
|
|
|
470
|
|
|
|
|
|
|
# these are not actually allowed in meta-spec v1.4 but are left here for compatibility: |
471
|
|
|
|
|
|
|
apache_1_1 => 'http://apache.org/licenses/LICENSE-1.1', |
472
|
|
|
|
|
|
|
artistic_2 => 'http://opensource.org/licenses/artistic-license-2.0.php', |
473
|
|
|
|
|
|
|
lgpl2 => 'http://opensource.org/licenses/lgpl-2.1.php', |
474
|
|
|
|
|
|
|
lgpl3 => 'http://opensource.org/licenses/lgpl-3.0.html', |
475
|
|
|
|
|
|
|
); |
476
|
0
|
|
|
0
|
0
|
0
|
|
477
|
0
|
0
|
|
|
|
0
|
sub license { |
478
|
0
|
0
|
|
|
|
0
|
my $self = shift; |
479
|
|
|
|
|
|
|
return $self->{values}->{license} unless @_; |
480
|
|
|
|
|
|
|
my $license = shift or die( |
481
|
0
|
|
0
|
|
|
0
|
'Did not provide a value to license()' |
482
|
0
|
|
|
|
|
0
|
); |
483
|
|
|
|
|
|
|
$license = __extract_license($license) || lc $license; |
484
|
|
|
|
|
|
|
$self->{values}->{license} = $license; |
485
|
0
|
0
|
|
|
|
0
|
|
486
|
0
|
|
|
|
|
0
|
# Automatically fill in license URLs |
487
|
|
|
|
|
|
|
if ( $license_urls{$license} ) { |
488
|
|
|
|
|
|
|
$self->resources( license => $license_urls{$license} ); |
489
|
0
|
|
|
|
|
0
|
} |
490
|
|
|
|
|
|
|
|
491
|
|
|
|
|
|
|
return 1; |
492
|
|
|
|
|
|
|
} |
493
|
9
|
|
|
9
|
|
5759
|
|
494
|
9
|
|
|
|
|
15
|
sub _extract_license { |
495
|
9
|
|
66
|
|
|
153
|
my $pod = shift; |
496
|
|
|
|
|
|
|
my $matched; |
497
|
|
|
|
|
|
|
return __extract_license( |
498
|
|
|
|
|
|
|
($matched) = $pod =~ m/ |
499
|
|
|
|
|
|
|
(=head \d \s+ L(?i:ICEN[CS]E|ICENSING)\b.*?) |
500
|
|
|
|
|
|
|
(=head \d.*|=cut.*|)\z |
501
|
|
|
|
|
|
|
/xms |
502
|
|
|
|
|
|
|
) || __extract_license( |
503
|
|
|
|
|
|
|
($matched) = $pod =~ m/ |
504
|
|
|
|
|
|
|
(=head \d \s+ (?:C(?i:OPYRIGHTS?)|L(?i:EGAL))\b.*?) |
505
|
|
|
|
|
|
|
(=head \d.*|=cut.*|)\z |
506
|
|
|
|
|
|
|
/xms |
507
|
|
|
|
|
|
|
); |
508
|
|
|
|
|
|
|
} |
509
|
14
|
100
|
|
14
|
|
158
|
|
510
|
9
|
|
|
|
|
68
|
sub __extract_license { |
511
|
|
|
|
|
|
|
my $license_text = shift or return; |
512
|
|
|
|
|
|
|
my @phrases = ( |
513
|
|
|
|
|
|
|
'(?:under )?the same (?:terms|license) as (?:perl|the perl (?:\d )?programming language)' => 'perl', 1, |
514
|
|
|
|
|
|
|
'(?:under )?the terms of (?:perl|the perl programming language) itself' => 'perl', 1, |
515
|
|
|
|
|
|
|
'Artistic and GPL' => 'perl', 1, |
516
|
|
|
|
|
|
|
'GNU general public license' => 'gpl', 1, |
517
|
|
|
|
|
|
|
'GNU public license' => 'gpl', 1, |
518
|
|
|
|
|
|
|
'GNU lesser general public license' => 'lgpl', 1, |
519
|
|
|
|
|
|
|
'GNU lesser public license' => 'lgpl', 1, |
520
|
|
|
|
|
|
|
'GNU library general public license' => 'lgpl', 1, |
521
|
|
|
|
|
|
|
'GNU library public license' => 'lgpl', 1, |
522
|
|
|
|
|
|
|
'GNU Free Documentation license' => 'unrestricted', 1, |
523
|
|
|
|
|
|
|
'GNU Affero General Public License' => 'open_source', 1, |
524
|
|
|
|
|
|
|
'(?:Free)?BSD license' => 'bsd', 1, |
525
|
|
|
|
|
|
|
'Artistic license 2\.0' => 'artistic_2', 1, |
526
|
|
|
|
|
|
|
'Artistic license' => 'artistic', 1, |
527
|
|
|
|
|
|
|
'Apache (?:Software )?license' => 'apache', 1, |
528
|
|
|
|
|
|
|
'GPL' => 'gpl', 1, |
529
|
|
|
|
|
|
|
'LGPL' => 'lgpl', 1, |
530
|
|
|
|
|
|
|
'BSD' => 'bsd', 1, |
531
|
|
|
|
|
|
|
'Artistic' => 'artistic', 1, |
532
|
|
|
|
|
|
|
'MIT' => 'mit', 1, |
533
|
|
|
|
|
|
|
'Mozilla Public License' => 'mozilla', 1, |
534
|
|
|
|
|
|
|
'Q Public License' => 'open_source', 1, |
535
|
|
|
|
|
|
|
'OpenSSL License' => 'unrestricted', 1, |
536
|
|
|
|
|
|
|
'SSLeay License' => 'unrestricted', 1, |
537
|
|
|
|
|
|
|
'zlib License' => 'open_source', 1, |
538
|
9
|
|
|
|
|
35
|
'proprietary' => 'proprietary', 0, |
539
|
38
|
|
|
|
|
220
|
); |
540
|
38
|
100
|
|
|
|
844
|
while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) { |
541
|
9
|
|
|
|
|
71
|
$pattern =~ s#\s+#\\s+#gs; |
542
|
|
|
|
|
|
|
if ( $license_text =~ /\b$pattern\b/i ) { |
543
|
|
|
|
|
|
|
return $license; |
544
|
0
|
|
|
|
|
0
|
} |
545
|
|
|
|
|
|
|
} |
546
|
|
|
|
|
|
|
return ''; |
547
|
|
|
|
|
|
|
} |
548
|
0
|
|
|
0
|
0
|
0
|
|
549
|
0
|
0
|
|
|
|
0
|
sub license_from { |
550
|
0
|
|
|
|
|
0
|
my $self = shift; |
551
|
|
|
|
|
|
|
if (my $license=_extract_license(Module::Install::_read($_[0]))) { |
552
|
0
|
|
|
|
|
0
|
$self->license($license); |
553
|
0
|
|
|
|
|
0
|
} else { |
554
|
|
|
|
|
|
|
warn "Cannot determine license info from $_[0]\n"; |
555
|
|
|
|
|
|
|
return 'unknown'; |
556
|
|
|
|
|
|
|
} |
557
|
|
|
|
|
|
|
} |
558
|
6
|
|
|
6
|
|
5089
|
|
559
|
|
|
|
|
|
|
sub _extract_bugtracker { |
560
|
|
|
|
|
|
|
my @links = $_[0] =~ m#L<( |
561
|
|
|
|
|
|
|
https?\Q://rt.cpan.org/\E[^>]+| |
562
|
|
|
|
|
|
|
https?\Q://github.com/\E[\w_]+/[\w_]+/issues| |
563
|
6
|
|
|
|
|
13
|
https?\Q://code.google.com/p/\E[\w_\-]+/issues/list |
564
|
6
|
|
|
|
|
17
|
)>#gx; |
565
|
6
|
|
|
|
|
15
|
my %links; |
566
|
6
|
|
|
|
|
30
|
@links{@links}=(); |
567
|
|
|
|
|
|
|
@links=keys %links; |
568
|
|
|
|
|
|
|
return @links; |
569
|
|
|
|
|
|
|
} |
570
|
0
|
|
|
0
|
0
|
0
|
|
571
|
0
|
|
|
|
|
0
|
sub bugtracker_from { |
572
|
0
|
|
|
|
|
0
|
my $self = shift; |
573
|
0
|
0
|
|
|
|
0
|
my $content = Module::Install::_read($_[0]); |
574
|
0
|
|
|
|
|
0
|
my @links = _extract_bugtracker($content); |
575
|
0
|
|
|
|
|
0
|
unless ( @links ) { |
576
|
|
|
|
|
|
|
warn "Cannot determine bugtracker info from $_[0]\n"; |
577
|
0
|
0
|
|
|
|
0
|
return 0; |
578
|
0
|
|
|
|
|
0
|
} |
579
|
0
|
|
|
|
|
0
|
if ( @links > 1 ) { |
580
|
|
|
|
|
|
|
warn "Found more than one bugtracker link in $_[0]\n"; |
581
|
|
|
|
|
|
|
return 0; |
582
|
|
|
|
|
|
|
} |
583
|
0
|
|
|
|
|
0
|
|
584
|
0
|
|
|
|
|
0
|
# Set the bugtracker |
585
|
|
|
|
|
|
|
bugtracker( $links[0] ); |
586
|
|
|
|
|
|
|
return 1; |
587
|
|
|
|
|
|
|
} |
588
|
0
|
|
|
0
|
0
|
0
|
|
589
|
0
|
|
|
|
|
0
|
sub requires_from { |
590
|
0
|
|
|
|
|
0
|
my $self = shift; |
591
|
0
|
|
|
|
|
0
|
my $content = Module::Install::_readperl($_[0]); |
592
|
0
|
|
|
|
|
0
|
my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+(v?[\d\.]+)/mg; |
593
|
0
|
|
|
|
|
0
|
while ( @requires ) { |
594
|
0
|
|
|
|
|
0
|
my $module = shift @requires; |
595
|
|
|
|
|
|
|
my $version = shift @requires; |
596
|
|
|
|
|
|
|
$self->requires( $module => $version ); |
597
|
|
|
|
|
|
|
} |
598
|
|
|
|
|
|
|
} |
599
|
0
|
|
|
0
|
0
|
0
|
|
600
|
0
|
|
|
|
|
0
|
sub test_requires_from { |
601
|
0
|
|
|
|
|
0
|
my $self = shift; |
602
|
0
|
|
|
|
|
0
|
my $content = Module::Install::_readperl($_[0]); |
603
|
0
|
|
|
|
|
0
|
my @requires = $content =~ m/^use\s+([^\W\d]\w*(?:::\w+)*)\s+([\d\.]+)/mg; |
604
|
0
|
|
|
|
|
0
|
while ( @requires ) { |
605
|
0
|
|
|
|
|
0
|
my $module = shift @requires; |
606
|
|
|
|
|
|
|
my $version = shift @requires; |
607
|
|
|
|
|
|
|
$self->test_requires( $module => $version ); |
608
|
|
|
|
|
|
|
} |
609
|
|
|
|
|
|
|
} |
610
|
|
|
|
|
|
|
|
611
|
|
|
|
|
|
|
# Convert triple-part versions (eg, 5.6.1 or 5.8.9) to |
612
|
|
|
|
|
|
|
# numbers (eg, 5.006001 or 5.008009). |
613
|
13
|
|
|
13
|
|
7170
|
# Also, convert double-part versions (eg, 5.8) |
614
|
13
|
|
|
|
|
88
|
sub _perl_version { |
|
6
|
|
|
|
|
57
|
|
615
|
13
|
|
100
|
|
|
61
|
my $v = $_[-1]; |
|
4
|
|
|
|
|
48
|
|
616
|
13
|
|
|
|
|
29
|
$v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e; |
617
|
13
|
|
|
|
|
24
|
$v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e; |
618
|
13
|
50
|
|
|
|
35
|
$v =~ s/(\.\d\d\d)000$/$1/; |
619
|
|
|
|
|
|
|
$v =~ s/_.+$//; |
620
|
0
|
|
|
|
|
0
|
if ( ref($v) ) { |
621
|
|
|
|
|
|
|
# Numify |
622
|
13
|
|
|
|
|
55
|
$v = $v + 0; |
623
|
|
|
|
|
|
|
} |
624
|
|
|
|
|
|
|
return $v; |
625
|
|
|
|
|
|
|
} |
626
|
0
|
|
|
0
|
0
|
|
|
627
|
0
|
|
|
|
|
|
sub add_metadata { |
628
|
0
|
|
|
|
|
|
my $self = shift; |
629
|
0
|
0
|
|
|
|
|
my %hash = @_; |
630
|
|
|
|
|
|
|
for my $key (keys %hash) { |
631
|
0
|
|
|
|
|
|
warn "add_metadata: $key is not prefixed with 'x_'.\n" . |
632
|
|
|
|
|
|
|
"Use appopriate function to add non-private metadata.\n" unless $key =~ /^x_/; |
633
|
|
|
|
|
|
|
$self->{values}->{$key} = $hash{$key}; |
634
|
|
|
|
|
|
|
} |
635
|
|
|
|
|
|
|
} |
636
|
|
|
|
|
|
|
|
637
|
|
|
|
|
|
|
|
638
|
|
|
|
|
|
|
###################################################################### |
639
|
|
|
|
|
|
|
# MYMETA Support |
640
|
0
|
|
|
0
|
0
|
|
|
641
|
|
|
|
|
|
|
sub WriteMyMeta { |
642
|
|
|
|
|
|
|
die "WriteMyMeta has been deprecated"; |
643
|
|
|
|
|
|
|
} |
644
|
0
|
|
|
0
|
0
|
|
|
645
|
|
|
|
|
|
|
sub write_mymeta_yaml { |
646
|
|
|
|
|
|
|
my $self = shift; |
647
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
648
|
0
|
|
|
|
|
|
# We need YAML::Tiny to write the MYMETA.yml file |
649
|
|
|
|
|
|
|
unless ( eval { require YAML::Tiny; 1; } ) { |
650
|
|
|
|
|
|
|
return 1; |
651
|
|
|
|
|
|
|
} |
652
|
0
|
0
|
|
|
|
|
|
653
|
|
|
|
|
|
|
# Generate the data |
654
|
|
|
|
|
|
|
my $meta = $self->_write_mymeta_data or return 1; |
655
|
0
|
|
|
|
|
|
|
656
|
0
|
|
|
|
|
|
# Save as the MYMETA.yml file |
657
|
|
|
|
|
|
|
print "Writing MYMETA.yml\n"; |
658
|
|
|
|
|
|
|
YAML::Tiny::DumpFile('MYMETA.yml', $meta); |
659
|
|
|
|
|
|
|
} |
660
|
0
|
|
|
0
|
0
|
|
|
661
|
|
|
|
|
|
|
sub write_mymeta_json { |
662
|
|
|
|
|
|
|
my $self = shift; |
663
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
664
|
0
|
|
|
|
|
|
# We need JSON to write the MYMETA.json file |
665
|
|
|
|
|
|
|
unless ( eval { require JSON; 1; } ) { |
666
|
|
|
|
|
|
|
return 1; |
667
|
|
|
|
|
|
|
} |
668
|
0
|
0
|
|
|
|
|
|
669
|
|
|
|
|
|
|
# Generate the data |
670
|
|
|
|
|
|
|
my $meta = $self->_write_mymeta_data or return 1; |
671
|
0
|
|
|
|
|
|
|
672
|
0
|
|
|
|
|
|
# Save as the MYMETA.yml file |
673
|
|
|
|
|
|
|
print "Writing MYMETA.json\n"; |
674
|
|
|
|
|
|
|
Module::Install::_write( |
675
|
|
|
|
|
|
|
'MYMETA.json', |
676
|
|
|
|
|
|
|
JSON->new->pretty(1)->canonical->encode($meta), |
677
|
|
|
|
|
|
|
); |
678
|
|
|
|
|
|
|
} |
679
|
0
|
|
|
0
|
|
|
|
680
|
|
|
|
|
|
|
sub _write_mymeta_data { |
681
|
|
|
|
|
|
|
my $self = shift; |
682
|
0
|
0
|
|
|
|
|
|
683
|
|
|
|
|
|
|
# If there's no existing META.yml there is nothing we can do |
684
|
|
|
|
|
|
|
return undef unless -f 'META.yml'; |
685
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
686
|
0
|
|
|
|
|
|
# We need Parse::CPAN::Meta to load the file |
687
|
|
|
|
|
|
|
unless ( eval { require Parse::CPAN::Meta; 1; } ) { |
688
|
|
|
|
|
|
|
return undef; |
689
|
|
|
|
|
|
|
} |
690
|
0
|
|
|
|
|
|
|
691
|
0
|
|
|
|
|
|
# Merge the perl version into the dependencies |
692
|
0
|
0
|
|
|
|
|
my $val = $self->Meta->{values}; |
693
|
0
|
|
0
|
|
|
|
my $perl = delete $val->{perl_version}; |
694
|
0
|
|
|
|
|
|
if ( $perl ) { |
695
|
|
|
|
|
|
|
$val->{requires} ||= []; |
696
|
|
|
|
|
|
|
my $requires = $val->{requires}; |
697
|
0
|
0
|
|
|
|
|
|
698
|
0
|
|
0
|
|
|
|
# Canonize to three-dot version after Perl 5.6 |
|
0
|
|
0
|
|
|
|
|
699
|
|
|
|
|
|
|
if ( $perl >= 5.006 ) { |
700
|
0
|
|
|
|
|
|
$perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e |
701
|
|
|
|
|
|
|
} |
702
|
|
|
|
|
|
|
unshift @$requires, [ perl => $perl ]; |
703
|
|
|
|
|
|
|
} |
704
|
0
|
|
|
|
|
|
|
705
|
0
|
|
|
|
|
|
# Load the advisory META.yml file |
706
|
|
|
|
|
|
|
my @yaml = Parse::CPAN::Meta::LoadFile('META.yml'); |
707
|
|
|
|
|
|
|
my $meta = $yaml[0]; |
708
|
0
|
|
|
|
|
|
|
709
|
0
|
|
|
|
|
|
# Overwrite the non-configure dependency hashes |
710
|
0
|
|
|
|
|
|
delete $meta->{requires}; |
711
|
0
|
0
|
|
|
|
|
delete $meta->{build_requires}; |
712
|
0
|
|
|
|
|
|
delete $meta->{recommends}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
713
|
|
|
|
|
|
|
if ( exists $val->{requires} ) { |
714
|
0
|
0
|
|
|
|
|
$meta->{requires} = { map { @$_ } @{ $val->{requires} } }; |
715
|
0
|
|
|
|
|
|
} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
716
|
|
|
|
|
|
|
if ( exists $val->{build_requires} ) { |
717
|
|
|
|
|
|
|
$meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } }; |
718
|
0
|
|
|
|
|
|
} |
719
|
|
|
|
|
|
|
|
720
|
|
|
|
|
|
|
return $meta; |
721
|
|
|
|
|
|
|
} |
722
|
|
|
|
|
|
|
|
723
|
|
|
|
|
|
|
1; |