| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::DualLife; # git description: v0.06-3-gb9840ff |
|
2
|
|
|
|
|
|
|
# ABSTRACT: Distribute dual-life modules with Dist::Zilla |
|
3
|
|
|
|
|
|
|
# KEYWORDS: Makefile.PL core dual-life install INSTALLDIRS |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.07'; |
|
6
|
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
6386575
|
use Moose; |
|
|
5
|
|
|
|
|
7
|
|
|
|
5
|
|
|
|
|
30
|
|
|
8
|
5
|
|
|
5
|
|
20140
|
use List::Util qw(first min); |
|
|
5
|
|
|
|
|
7
|
|
|
|
5
|
|
|
|
|
312
|
|
|
9
|
5
|
|
|
5
|
|
21
|
use namespace::autoclean; |
|
|
5
|
|
|
|
|
6
|
|
|
|
5
|
|
|
|
|
46
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
with |
|
12
|
|
|
|
|
|
|
'Dist::Zilla::Role::ModuleMetadata', |
|
13
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileMunger', |
|
14
|
|
|
|
|
|
|
'Dist::Zilla::Role::FileFinderUser' => { |
|
15
|
|
|
|
|
|
|
method => 'module_files', |
|
16
|
|
|
|
|
|
|
finder_arg_names => [ 'module_finder' ], |
|
17
|
|
|
|
|
|
|
default_finders => [ ':InstallModules' ], |
|
18
|
|
|
|
|
|
|
}, |
|
19
|
|
|
|
|
|
|
; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
|
22
|
|
|
|
|
|
|
#pod |
|
23
|
|
|
|
|
|
|
#pod In your dist.ini: |
|
24
|
|
|
|
|
|
|
#pod |
|
25
|
|
|
|
|
|
|
#pod [DualLife] |
|
26
|
|
|
|
|
|
|
#pod |
|
27
|
|
|
|
|
|
|
#pod =head1 DESCRIPTION |
|
28
|
|
|
|
|
|
|
#pod |
|
29
|
|
|
|
|
|
|
#pod Dual-life modules, which are modules distributed both as part of the perl core |
|
30
|
|
|
|
|
|
|
#pod and on CPAN, sometimes need a little special treatment. This module tries |
|
31
|
|
|
|
|
|
|
#pod provide that for modules built with C<Dist::Zilla>. |
|
32
|
|
|
|
|
|
|
#pod |
|
33
|
|
|
|
|
|
|
#pod Currently the only thing this module does is providing an C<INSTALLDIRS> option |
|
34
|
|
|
|
|
|
|
#pod to C<ExtUtils::MakeMaker>'s C<WriteMakefile> function, so dual-life modules will |
|
35
|
|
|
|
|
|
|
#pod be installed in the right section of C<@INC> depending on different versions of |
|
36
|
|
|
|
|
|
|
#pod perl. |
|
37
|
|
|
|
|
|
|
#pod |
|
38
|
|
|
|
|
|
|
#pod As more things that need special handling for dual-life modules show up, this |
|
39
|
|
|
|
|
|
|
#pod module will try to address them as well. |
|
40
|
|
|
|
|
|
|
#pod |
|
41
|
|
|
|
|
|
|
#pod The options added to your C<Makefile.PL> by this module are roughly equivalent |
|
42
|
|
|
|
|
|
|
#pod to: |
|
43
|
|
|
|
|
|
|
#pod |
|
44
|
|
|
|
|
|
|
#pod 'INSTALLDIRS' => ("$]" >= 5.009005 && "$]" <= 5.011000 ? 'perl' : 'site'), |
|
45
|
|
|
|
|
|
|
#pod |
|
46
|
|
|
|
|
|
|
#pod (assuming a module that entered core in 5.009005). |
|
47
|
|
|
|
|
|
|
#pod |
|
48
|
|
|
|
|
|
|
#pod [DualLife] |
|
49
|
|
|
|
|
|
|
#pod entered_core=5.006001 |
|
50
|
|
|
|
|
|
|
#pod |
|
51
|
|
|
|
|
|
|
#pod =for Pod::Coverage munge_files |
|
52
|
|
|
|
|
|
|
#pod |
|
53
|
|
|
|
|
|
|
#pod =attr entered_core |
|
54
|
|
|
|
|
|
|
#pod |
|
55
|
|
|
|
|
|
|
#pod Indicates when the distribution joined core. This option is not normally |
|
56
|
|
|
|
|
|
|
#pod needed, as L<Module::CoreList> is used to determine this. |
|
57
|
|
|
|
|
|
|
#pod |
|
58
|
|
|
|
|
|
|
#pod =cut |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
has entered_core => ( |
|
61
|
|
|
|
|
|
|
is => 'ro', |
|
62
|
|
|
|
|
|
|
isa => 'Str', |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
#pod =attr eumm_bundled |
|
66
|
|
|
|
|
|
|
#pod |
|
67
|
|
|
|
|
|
|
#pod Boolean for distributions bundled with ExtUtils::MakeMaker. Prior to v5.12, |
|
68
|
|
|
|
|
|
|
#pod bundled modules might get installed into the core library directory, so |
|
69
|
|
|
|
|
|
|
#pod even if they didn't come into core until later, they need to be forced into |
|
70
|
|
|
|
|
|
|
#pod core prior to v5.12 so they take precedence. |
|
71
|
|
|
|
|
|
|
#pod |
|
72
|
|
|
|
|
|
|
#pod =cut |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
has eumm_bundled => ( |
|
75
|
|
|
|
|
|
|
is => 'ro', |
|
76
|
|
|
|
|
|
|
isa => 'Bool', |
|
77
|
|
|
|
|
|
|
default => 0, |
|
78
|
|
|
|
|
|
|
); |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
around dump_config => sub |
|
81
|
|
|
|
|
|
|
{ |
|
82
|
|
|
|
|
|
|
my ($orig, $self) = @_; |
|
83
|
|
|
|
|
|
|
my $config = $self->$orig; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
$config->{+__PACKAGE__} = { |
|
86
|
|
|
|
|
|
|
$self->entered_core ? ( entered_core => $self->entered_core ) : (), |
|
87
|
|
|
|
|
|
|
eumm_bundled => $self->eumm_bundled ? 1 : 0, |
|
88
|
|
|
|
|
|
|
blessed($self) ne __PACKAGE__ ? ( version => $VERSION ) : (), |
|
89
|
|
|
|
|
|
|
}; |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
return $config; |
|
92
|
|
|
|
|
|
|
}; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub munge_files |
|
95
|
|
|
|
|
|
|
{ |
|
96
|
6
|
|
|
6
|
0
|
238278
|
my $self = shift; |
|
97
|
|
|
|
|
|
|
|
|
98
|
6
|
|
|
19
|
|
23
|
my $makefile = first { $_->name eq 'Makefile.PL' } @{$self->zilla->files}; |
|
|
19
|
|
|
|
|
558
|
|
|
|
6
|
|
|
|
|
156
|
|
|
99
|
6
|
50
|
|
|
|
203
|
$self->log_fatal('No Makefile.PL found! Is [MakeMaker] at least version 5.022?') if not $makefile; |
|
100
|
|
|
|
|
|
|
|
|
101
|
6
|
|
|
|
|
167
|
my $entered = $self->entered_core; |
|
102
|
6
|
100
|
|
|
|
16
|
if (not $entered) |
|
103
|
|
|
|
|
|
|
{ |
|
104
|
4
|
|
|
|
|
6417
|
require Module::CoreList; |
|
105
|
4
|
|
|
|
|
83547
|
Module::CoreList->VERSION('2.19'); |
|
106
|
|
|
|
|
|
|
$entered = min( |
|
107
|
|
|
|
|
|
|
map { |
|
108
|
5
|
|
|
|
|
4739
|
$self->log_debug([ 'looking up %s in Module::CoreList...', $_->name ]); |
|
109
|
5
|
|
|
|
|
1633
|
my $mmd = $self->module_metadata_for_file($_); |
|
110
|
5
|
|
|
|
|
9647
|
my $module = ($mmd->packages_inside)[0]; |
|
111
|
|
|
|
|
|
|
# this returns the empty list when the module is not in core, |
|
112
|
|
|
|
|
|
|
# so we don't have to worry about passing undefs to min(). |
|
113
|
5
|
|
|
|
|
40
|
Module::CoreList->first_release($module); |
|
114
|
4
|
|
|
|
|
15
|
} @{ $self->module_files } |
|
|
4
|
|
|
|
|
28
|
|
|
115
|
|
|
|
|
|
|
); |
|
116
|
|
|
|
|
|
|
} |
|
117
|
|
|
|
|
|
|
|
|
118
|
6
|
100
|
|
|
|
43545
|
if (not $self->eumm_bundled) |
|
119
|
|
|
|
|
|
|
{ |
|
120
|
|
|
|
|
|
|
# technically this only checks if the module is core, not dual-lifed, but a |
|
121
|
|
|
|
|
|
|
# separate repository shouldn't exist for non-dual modules anyway |
|
122
|
5
|
100
|
|
|
|
17
|
$self->log_fatal('this module is not dual-life!') if not $entered; |
|
123
|
|
|
|
|
|
|
|
|
124
|
4
|
100
|
|
|
|
18
|
if ($entered > 5.011000) { |
|
125
|
1
|
|
|
|
|
8
|
$self->log('this module entered core after 5.011 - nothing to do here'); |
|
126
|
1
|
|
|
|
|
215
|
return; |
|
127
|
|
|
|
|
|
|
} |
|
128
|
|
|
|
|
|
|
} |
|
129
|
|
|
|
|
|
|
|
|
130
|
4
|
|
|
|
|
9
|
my $dual_life_args = q[$WriteMakefileArgs{INSTALLDIRS} = 'perl']; |
|
131
|
|
|
|
|
|
|
|
|
132
|
4
|
100
|
|
|
|
107
|
if ( $self->eumm_bundled ) { |
|
133
|
1
|
|
|
|
|
4
|
$dual_life_args .= "\n if \"\$]\" <= 5.011000;\n\n"; |
|
134
|
|
|
|
|
|
|
} |
|
135
|
|
|
|
|
|
|
else { |
|
136
|
3
|
|
|
|
|
12
|
$dual_life_args .= "\n if \"\$]\" >= $entered && \"\$]\" <= 5.011000;\n\n" |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
4
|
|
|
|
|
21
|
my $content = $makefile->content; |
|
140
|
|
|
|
|
|
|
|
|
141
|
4
|
50
|
|
|
|
392
|
$content =~ s/(?=WriteMakefile\s*\()/$dual_life_args/ |
|
142
|
|
|
|
|
|
|
or $self->log_fatal('Failed to insert INSTALLDIRS magic'); |
|
143
|
|
|
|
|
|
|
|
|
144
|
4
|
|
|
|
|
13
|
$makefile->content($content); |
|
145
|
|
|
|
|
|
|
} |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
1; |
|
150
|
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
__END__ |
|
152
|
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=pod |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=encoding UTF-8 |
|
156
|
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 NAME |
|
158
|
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
Dist::Zilla::Plugin::DualLife - Distribute dual-life modules with Dist::Zilla |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 VERSION |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
version 0.07 |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
In your dist.ini: |
|
168
|
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
[DualLife] |
|
170
|
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
172
|
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
Dual-life modules, which are modules distributed both as part of the perl core |
|
174
|
|
|
|
|
|
|
and on CPAN, sometimes need a little special treatment. This module tries |
|
175
|
|
|
|
|
|
|
provide that for modules built with C<Dist::Zilla>. |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
Currently the only thing this module does is providing an C<INSTALLDIRS> option |
|
178
|
|
|
|
|
|
|
to C<ExtUtils::MakeMaker>'s C<WriteMakefile> function, so dual-life modules will |
|
179
|
|
|
|
|
|
|
be installed in the right section of C<@INC> depending on different versions of |
|
180
|
|
|
|
|
|
|
perl. |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
As more things that need special handling for dual-life modules show up, this |
|
183
|
|
|
|
|
|
|
module will try to address them as well. |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
The options added to your C<Makefile.PL> by this module are roughly equivalent |
|
186
|
|
|
|
|
|
|
to: |
|
187
|
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
'INSTALLDIRS' => ("$]" >= 5.009005 && "$]" <= 5.011000 ? 'perl' : 'site'), |
|
189
|
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
(assuming a module that entered core in 5.009005). |
|
191
|
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
[DualLife] |
|
193
|
|
|
|
|
|
|
entered_core=5.006001 |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head2 entered_core |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Indicates when the distribution joined core. This option is not normally |
|
200
|
|
|
|
|
|
|
needed, as L<Module::CoreList> is used to determine this. |
|
201
|
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
=head2 eumm_bundled |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
Boolean for distributions bundled with ExtUtils::MakeMaker. Prior to v5.12, |
|
205
|
|
|
|
|
|
|
bundled modules might get installed into the core library directory, so |
|
206
|
|
|
|
|
|
|
even if they didn't come into core until later, they need to be forced into |
|
207
|
|
|
|
|
|
|
core prior to v5.12 so they take precedence. |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=for Pod::Coverage munge_files |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=head1 SUPPORT |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-DualLife> |
|
214
|
|
|
|
|
|
|
(or L<bug-Dist-Zilla-Plugin-DualLife@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-DualLife@rt.cpan.org>). |
|
215
|
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
|
217
|
|
|
|
|
|
|
L<http://dzil.org/#mailing-list>. |
|
218
|
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
|
220
|
|
|
|
|
|
|
L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>. |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=head1 AUTHOR |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
|
225
|
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
|
227
|
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=for stopwords Karen Etheridge David Golden |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=over 4 |
|
231
|
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
=item * |
|
233
|
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
|
235
|
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
=item * |
|
237
|
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
David Golden <dagolden@cpan.org> |
|
239
|
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=back |
|
241
|
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
|
243
|
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Florian Ragwitz. |
|
245
|
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
247
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=cut |