line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Module::Install::Metadata; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
78027
|
use strict 'vars'; |
|
4
|
|
|
|
|
29
|
|
|
4
|
|
|
|
|
132
|
|
4
|
4
|
|
|
4
|
|
1234
|
use Module::Install::Base (); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
84
|
|
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
23
|
use vars qw{$VERSION @ISA $ISCORE}; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
254
|
|
7
|
|
|
|
|
|
|
BEGIN { |
8
|
4
|
|
|
4
|
|
14
|
$VERSION = '1.19'; |
9
|
4
|
|
|
|
|
96
|
@ISA = 'Module::Install::Base'; |
10
|
4
|
|
|
|
|
20031
|
$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
|
655
|
my $self = shift; |
170
|
10
|
100
|
|
|
|
34
|
return $self->{values}->{perl_version} unless @_; |
171
|
5
|
50
|
|
|
|
11
|
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
|
|
|
|
18
|
unless ( $version >= 5.005 ) { |
180
|
0
|
|
|
|
|
0
|
die "Module::Install only supports 5.005 or newer (use ExtUtils::MakeMaker)\n"; |
181
|
|
|
|
|
|
|
} |
182
|
|
|
|
|
|
|
|
183
|
5
|
|
|
|
|
15
|
$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
|
|
1639
|
if ( |
365
|
|
|
|
|
|
|
$_[0] =~ m/ |
366
|
|
|
|
|
|
|
^\s* |
367
|
|
|
|
|
|
|
(?:use|require) \s* |
368
|
|
|
|
|
|
|
v? |
369
|
|
|
|
|
|
|
([\d_\.]+) |
370
|
|
|
|
|
|
|
\s* ; |
371
|
|
|
|
|
|
|
/ixms |
372
|
|
|
|
|
|
|
) { |
373
|
2
|
|
|
|
|
7
|
my $perl_version = $1; |
374
|
2
|
|
|
|
|
4
|
$perl_version =~ s{_}{}g; |
375
|
2
|
|
|
|
|
7
|
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
|
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}{<}g; |
445
|
0
|
|
|
|
|
0
|
$author =~ s{E}{>}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
|
|
|
|
|
|
|
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
|
0
|
|
|
0
|
0
|
0
|
|
475
|
0
|
0
|
|
|
|
0
|
sub license { |
476
|
0
|
0
|
|
|
|
0
|
my $self = shift; |
477
|
|
|
|
|
|
|
return $self->{values}->{license} unless @_; |
478
|
|
|
|
|
|
|
my $license = shift or die( |
479
|
0
|
|
0
|
|
|
0
|
'Did not provide a value to license()' |
480
|
0
|
|
|
|
|
0
|
); |
481
|
|
|
|
|
|
|
$license = __extract_license($license) || lc $license; |
482
|
|
|
|
|
|
|
$self->{values}->{license} = $license; |
483
|
0
|
0
|
|
|
|
0
|
|
484
|
0
|
|
|
|
|
0
|
# Automatically fill in license URLs |
485
|
|
|
|
|
|
|
if ( $license_urls{$license} ) { |
486
|
|
|
|
|
|
|
$self->resources( license => $license_urls{$license} ); |
487
|
0
|
|
|
|
|
0
|
} |
488
|
|
|
|
|
|
|
|
489
|
|
|
|
|
|
|
return 1; |
490
|
|
|
|
|
|
|
} |
491
|
9
|
|
|
9
|
|
5304
|
|
492
|
9
|
|
|
|
|
17
|
sub _extract_license { |
493
|
9
|
|
66
|
|
|
140
|
my $pod = shift; |
494
|
|
|
|
|
|
|
my $matched; |
495
|
|
|
|
|
|
|
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
|
14
|
100
|
|
14
|
|
154
|
|
508
|
9
|
|
|
|
|
96
|
sub __extract_license { |
509
|
|
|
|
|
|
|
my $license_text = shift or return; |
510
|
|
|
|
|
|
|
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
|
9
|
|
|
|
|
37
|
'proprietary' => 'proprietary', 0, |
537
|
38
|
|
|
|
|
223
|
); |
538
|
38
|
100
|
|
|
|
730
|
while ( my ($pattern, $license, $osi) = splice(@phrases, 0, 3) ) { |
539
|
9
|
|
|
|
|
71
|
$pattern =~ s#\s+#\\s+#gs; |
540
|
|
|
|
|
|
|
if ( $license_text =~ /\b$pattern\b/i ) { |
541
|
|
|
|
|
|
|
return $license; |
542
|
0
|
|
|
|
|
0
|
} |
543
|
|
|
|
|
|
|
} |
544
|
|
|
|
|
|
|
return ''; |
545
|
|
|
|
|
|
|
} |
546
|
0
|
|
|
0
|
0
|
0
|
|
547
|
0
|
0
|
|
|
|
0
|
sub license_from { |
548
|
0
|
|
|
|
|
0
|
my $self = shift; |
549
|
|
|
|
|
|
|
if (my $license=_extract_license(Module::Install::_read($_[0]))) { |
550
|
0
|
|
|
|
|
0
|
$self->license($license); |
551
|
0
|
|
|
|
|
0
|
} else { |
552
|
|
|
|
|
|
|
warn "Cannot determine license info from $_[0]\n"; |
553
|
|
|
|
|
|
|
return 'unknown'; |
554
|
|
|
|
|
|
|
} |
555
|
|
|
|
|
|
|
} |
556
|
6
|
|
|
6
|
|
5191
|
|
557
|
|
|
|
|
|
|
sub _extract_bugtracker { |
558
|
|
|
|
|
|
|
my @links = $_[0] =~ m#L<( |
559
|
|
|
|
|
|
|
https?\Q://rt.cpan.org/\E[^>]+| |
560
|
|
|
|
|
|
|
https?\Q://github.com/\E[\w_]+/[\w_]+/issues| |
561
|
6
|
|
|
|
|
13
|
https?\Q://code.google.com/p/\E[\w_\-]+/issues/list |
562
|
6
|
|
|
|
|
22
|
)>#gx; |
563
|
6
|
|
|
|
|
19
|
my %links; |
564
|
6
|
|
|
|
|
28
|
@links{@links}=(); |
565
|
|
|
|
|
|
|
@links=keys %links; |
566
|
|
|
|
|
|
|
return @links; |
567
|
|
|
|
|
|
|
} |
568
|
0
|
|
|
0
|
0
|
0
|
|
569
|
0
|
|
|
|
|
0
|
sub bugtracker_from { |
570
|
0
|
|
|
|
|
0
|
my $self = shift; |
571
|
0
|
0
|
|
|
|
0
|
my $content = Module::Install::_read($_[0]); |
572
|
0
|
|
|
|
|
0
|
my @links = _extract_bugtracker($content); |
573
|
0
|
|
|
|
|
0
|
unless ( @links ) { |
574
|
|
|
|
|
|
|
warn "Cannot determine bugtracker info from $_[0]\n"; |
575
|
0
|
0
|
|
|
|
0
|
return 0; |
576
|
0
|
|
|
|
|
0
|
} |
577
|
0
|
|
|
|
|
0
|
if ( @links > 1 ) { |
578
|
|
|
|
|
|
|
warn "Found more than one bugtracker link in $_[0]\n"; |
579
|
|
|
|
|
|
|
return 0; |
580
|
|
|
|
|
|
|
} |
581
|
0
|
|
|
|
|
0
|
|
582
|
0
|
|
|
|
|
0
|
# Set the bugtracker |
583
|
|
|
|
|
|
|
bugtracker( $links[0] ); |
584
|
|
|
|
|
|
|
return 1; |
585
|
|
|
|
|
|
|
} |
586
|
0
|
|
|
0
|
0
|
0
|
|
587
|
0
|
|
|
|
|
0
|
sub requires_from { |
588
|
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
|
|
|
|
|
|
|
my $version = shift @requires; |
594
|
|
|
|
|
|
|
$self->requires( $module => $version ); |
595
|
|
|
|
|
|
|
} |
596
|
|
|
|
|
|
|
} |
597
|
0
|
|
|
0
|
0
|
0
|
|
598
|
0
|
|
|
|
|
0
|
sub test_requires_from { |
599
|
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
|
|
|
|
|
|
|
my $version = shift @requires; |
605
|
|
|
|
|
|
|
$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
|
13
|
|
|
13
|
|
3232
|
# Also, convert double-part versions (eg, 5.8) |
612
|
13
|
|
|
|
|
68
|
sub _perl_version { |
|
6
|
|
|
|
|
34
|
|
613
|
13
|
|
100
|
|
|
33
|
my $v = $_[-1]; |
|
4
|
|
|
|
|
35
|
|
614
|
13
|
|
|
|
|
19
|
$v =~ s/^([1-9])\.([1-9]\d?\d?)$/sprintf("%d.%03d",$1,$2)/e; |
615
|
13
|
|
|
|
|
22
|
$v =~ s/^([1-9])\.([1-9]\d?\d?)\.(0|[1-9]\d?\d?)$/sprintf("%d.%03d%03d",$1,$2,$3 || 0)/e; |
616
|
13
|
50
|
|
|
|
26
|
$v =~ s/(\.\d\d\d)000$/$1/; |
617
|
|
|
|
|
|
|
$v =~ s/_.+$//; |
618
|
0
|
|
|
|
|
0
|
if ( ref($v) ) { |
619
|
|
|
|
|
|
|
# Numify |
620
|
13
|
|
|
|
|
38
|
$v = $v + 0; |
621
|
|
|
|
|
|
|
} |
622
|
|
|
|
|
|
|
return $v; |
623
|
|
|
|
|
|
|
} |
624
|
0
|
|
|
0
|
0
|
|
|
625
|
0
|
|
|
|
|
|
sub add_metadata { |
626
|
0
|
|
|
|
|
|
my $self = shift; |
627
|
0
|
0
|
|
|
|
|
my %hash = @_; |
628
|
|
|
|
|
|
|
for my $key (keys %hash) { |
629
|
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
|
|
|
|
|
|
|
$self->{values}->{$key} = $hash{$key}; |
632
|
|
|
|
|
|
|
} |
633
|
|
|
|
|
|
|
} |
634
|
|
|
|
|
|
|
|
635
|
|
|
|
|
|
|
|
636
|
|
|
|
|
|
|
###################################################################### |
637
|
|
|
|
|
|
|
# MYMETA Support |
638
|
0
|
|
|
0
|
0
|
|
|
639
|
|
|
|
|
|
|
sub WriteMyMeta { |
640
|
|
|
|
|
|
|
die "WriteMyMeta has been deprecated"; |
641
|
|
|
|
|
|
|
} |
642
|
0
|
|
|
0
|
0
|
|
|
643
|
|
|
|
|
|
|
sub write_mymeta_yaml { |
644
|
|
|
|
|
|
|
my $self = shift; |
645
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
646
|
0
|
|
|
|
|
|
# We need YAML::Tiny to write the MYMETA.yml file |
647
|
|
|
|
|
|
|
unless ( eval { require YAML::Tiny; 1; } ) { |
648
|
|
|
|
|
|
|
return 1; |
649
|
|
|
|
|
|
|
} |
650
|
0
|
0
|
|
|
|
|
|
651
|
|
|
|
|
|
|
# Generate the data |
652
|
|
|
|
|
|
|
my $meta = $self->_write_mymeta_data or return 1; |
653
|
0
|
|
|
|
|
|
|
654
|
0
|
|
|
|
|
|
# Save as the MYMETA.yml file |
655
|
|
|
|
|
|
|
print "Writing MYMETA.yml\n"; |
656
|
|
|
|
|
|
|
YAML::Tiny::DumpFile('MYMETA.yml', $meta); |
657
|
|
|
|
|
|
|
} |
658
|
0
|
|
|
0
|
0
|
|
|
659
|
|
|
|
|
|
|
sub write_mymeta_json { |
660
|
|
|
|
|
|
|
my $self = shift; |
661
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
662
|
0
|
|
|
|
|
|
# We need JSON to write the MYMETA.json file |
663
|
|
|
|
|
|
|
unless ( eval { require JSON; 1; } ) { |
664
|
|
|
|
|
|
|
return 1; |
665
|
|
|
|
|
|
|
} |
666
|
0
|
0
|
|
|
|
|
|
667
|
|
|
|
|
|
|
# Generate the data |
668
|
|
|
|
|
|
|
my $meta = $self->_write_mymeta_data or return 1; |
669
|
0
|
|
|
|
|
|
|
670
|
0
|
|
|
|
|
|
# Save as the MYMETA.yml file |
671
|
|
|
|
|
|
|
print "Writing MYMETA.json\n"; |
672
|
|
|
|
|
|
|
Module::Install::_write( |
673
|
|
|
|
|
|
|
'MYMETA.json', |
674
|
|
|
|
|
|
|
JSON->new->pretty(1)->canonical->encode($meta), |
675
|
|
|
|
|
|
|
); |
676
|
|
|
|
|
|
|
} |
677
|
0
|
|
|
0
|
|
|
|
678
|
|
|
|
|
|
|
sub _write_mymeta_data { |
679
|
|
|
|
|
|
|
my $self = shift; |
680
|
0
|
0
|
|
|
|
|
|
681
|
|
|
|
|
|
|
# If there's no existing META.yml there is nothing we can do |
682
|
|
|
|
|
|
|
return undef unless -f 'META.yml'; |
683
|
0
|
0
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
684
|
0
|
|
|
|
|
|
# We need Parse::CPAN::Meta to load the file |
685
|
|
|
|
|
|
|
unless ( eval { require Parse::CPAN::Meta; 1; } ) { |
686
|
|
|
|
|
|
|
return undef; |
687
|
|
|
|
|
|
|
} |
688
|
0
|
|
|
|
|
|
|
689
|
0
|
|
|
|
|
|
# Merge the perl version into the dependencies |
690
|
0
|
0
|
|
|
|
|
my $val = $self->Meta->{values}; |
691
|
0
|
|
0
|
|
|
|
my $perl = delete $val->{perl_version}; |
692
|
0
|
|
|
|
|
|
if ( $perl ) { |
693
|
|
|
|
|
|
|
$val->{requires} ||= []; |
694
|
|
|
|
|
|
|
my $requires = $val->{requires}; |
695
|
0
|
0
|
|
|
|
|
|
696
|
0
|
|
0
|
|
|
|
# Canonize to three-dot version after Perl 5.6 |
|
0
|
|
0
|
|
|
|
|
697
|
|
|
|
|
|
|
if ( $perl >= 5.006 ) { |
698
|
0
|
|
|
|
|
|
$perl =~ s{^(\d+)\.(\d\d\d)(\d*)}{join('.', $1, int($2||0), int($3||0))}e |
699
|
|
|
|
|
|
|
} |
700
|
|
|
|
|
|
|
unshift @$requires, [ perl => $perl ]; |
701
|
|
|
|
|
|
|
} |
702
|
0
|
|
|
|
|
|
|
703
|
0
|
|
|
|
|
|
# Load the advisory META.yml file |
704
|
|
|
|
|
|
|
my @yaml = Parse::CPAN::Meta::LoadFile('META.yml'); |
705
|
|
|
|
|
|
|
my $meta = $yaml[0]; |
706
|
0
|
|
|
|
|
|
|
707
|
0
|
|
|
|
|
|
# Overwrite the non-configure dependency hashes |
708
|
0
|
|
|
|
|
|
delete $meta->{requires}; |
709
|
0
|
0
|
|
|
|
|
delete $meta->{build_requires}; |
710
|
0
|
|
|
|
|
|
delete $meta->{recommends}; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
711
|
|
|
|
|
|
|
if ( exists $val->{requires} ) { |
712
|
0
|
0
|
|
|
|
|
$meta->{requires} = { map { @$_ } @{ $val->{requires} } }; |
713
|
0
|
|
|
|
|
|
} |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
714
|
|
|
|
|
|
|
if ( exists $val->{build_requires} ) { |
715
|
|
|
|
|
|
|
$meta->{build_requires} = { map { @$_ } @{ $val->{build_requires} } }; |
716
|
0
|
|
|
|
|
|
} |
717
|
|
|
|
|
|
|
|
718
|
|
|
|
|
|
|
return $meta; |
719
|
|
|
|
|
|
|
} |
720
|
|
|
|
|
|
|
|
721
|
|
|
|
|
|
|
1; |