line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Dist::Zilla::Plugin::DualLife; # git description: v0.05-8-g1ba4908 |
2
|
|
|
|
|
|
|
# ABSTRACT: Distribute dual-life modules with Dist::Zilla |
3
|
|
|
|
|
|
|
# KEYWORDS: Makefile.PL core dual-life install INSTALLDIRS |
4
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
our $VERSION = '0.06'; |
6
|
|
|
|
|
|
|
|
7
|
5
|
|
|
5
|
|
9874697
|
use Moose; |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
28
|
|
8
|
5
|
|
|
5
|
|
20529
|
use List::Util qw(first min); |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
304
|
|
9
|
5
|
|
|
5
|
|
20
|
use namespace::autoclean; |
|
5
|
|
|
|
|
7
|
|
|
5
|
|
|
|
|
66
|
|
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
|
241901
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
6
|
|
|
19
|
|
27
|
my $makefile = first { $_->name eq 'Makefile.PL' } @{$self->zilla->files}; |
|
19
|
|
|
|
|
581
|
|
|
6
|
|
|
|
|
163
|
|
99
|
6
|
50
|
|
|
|
206
|
$self->log_fatal('No Makefile.PL found! Is [MakeMaker] at least version 5.022?') if not $makefile; |
100
|
|
|
|
|
|
|
|
101
|
6
|
|
|
|
|
169
|
my $entered = $self->entered_core; |
102
|
6
|
100
|
|
|
|
17
|
if (not $entered) |
103
|
|
|
|
|
|
|
{ |
104
|
4
|
|
|
|
|
6529
|
require Module::CoreList; |
105
|
4
|
|
|
|
|
88691
|
Module::CoreList->VERSION('2.19'); |
106
|
|
|
|
|
|
|
$entered = min( |
107
|
|
|
|
|
|
|
map { |
108
|
5
|
|
|
|
|
5234
|
$self->log_debug([ 'looking up %s in Module::CoreList...', $_->name ]); |
109
|
5
|
|
|
|
|
1744
|
my $mmd = $self->module_metadata_for_file($_); |
110
|
5
|
|
|
|
|
9833
|
my $module = ($mmd->packages_inside)[0]; |
111
|
5
|
|
|
|
|
43
|
Module::CoreList->first_release($module); |
112
|
4
|
|
|
|
|
14
|
} @{ $self->module_files } |
|
4
|
|
|
|
|
36
|
|
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
6
|
100
|
|
|
|
43935
|
if (not $self->eumm_bundled) |
117
|
|
|
|
|
|
|
{ |
118
|
|
|
|
|
|
|
# technically this only checks if the module is core, not dual-lifed, but a |
119
|
|
|
|
|
|
|
# separate repository shouldn't exist for non-dual modules anyway |
120
|
5
|
100
|
|
|
|
23
|
$self->log_fatal('this module is not dual-life!') if not $entered; |
121
|
|
|
|
|
|
|
|
122
|
4
|
100
|
|
|
|
15
|
if ($entered > 5.011000) { |
123
|
1
|
|
|
|
|
5
|
$self->log('this module entered core after 5.011 - nothing to do here'); |
124
|
1
|
|
|
|
|
204
|
return; |
125
|
|
|
|
|
|
|
} |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
4
|
|
|
|
|
8
|
my $dual_life_args = q[$WriteMakefileArgs{INSTALLDIRS} = 'perl']; |
129
|
|
|
|
|
|
|
|
130
|
4
|
100
|
|
|
|
114
|
if ( $self->eumm_bundled ) { |
131
|
1
|
|
|
|
|
9
|
$dual_life_args .= "\n if \"\$]\" <= 5.011000;\n\n"; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
else { |
134
|
3
|
|
|
|
|
12
|
$dual_life_args .= "\n if \"\$]\" >= $entered && \"\$]\" <= 5.011000;\n\n" |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
4
|
|
|
|
|
27
|
my $content = $makefile->content; |
138
|
|
|
|
|
|
|
|
139
|
4
|
50
|
|
|
|
405
|
$content =~ s/(?=WriteMakefile\s*\()/$dual_life_args/ |
140
|
|
|
|
|
|
|
or $self->log_fatal('Failed to insert INSTALLDIRS magic'); |
141
|
|
|
|
|
|
|
|
142
|
4
|
|
|
|
|
12
|
$makefile->content($content); |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
1; |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
__END__ |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=pod |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=encoding UTF-8 |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=head1 NAME |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
Dist::Zilla::Plugin::DualLife - Distribute dual-life modules with Dist::Zilla |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head1 VERSION |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
version 0.06 |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=head1 SYNOPSIS |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
In your dist.ini: |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
[DualLife] |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 DESCRIPTION |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Dual-life modules, which are modules distributed both as part of the perl core |
172
|
|
|
|
|
|
|
and on CPAN, sometimes need a little special treatment. This module tries |
173
|
|
|
|
|
|
|
provide that for modules built with C<Dist::Zilla>. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
Currently the only thing this module does is providing an C<INSTALLDIRS> option |
176
|
|
|
|
|
|
|
to C<ExtUtils::MakeMaker>'s C<WriteMakefile> function, so dual-life modules will |
177
|
|
|
|
|
|
|
be installed in the right section of C<@INC> depending on different versions of |
178
|
|
|
|
|
|
|
perl. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
As more things that need special handling for dual-life modules show up, this |
181
|
|
|
|
|
|
|
module will try to address them as well. |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
The options added to your C<Makefile.PL> by this module are roughly equivalent |
184
|
|
|
|
|
|
|
to: |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
'INSTALLDIRS' => ("$]" >= 5.009005 && "$]" <= 5.011000 ? 'perl' : 'site'), |
187
|
|
|
|
|
|
|
|
188
|
|
|
|
|
|
|
(assuming a module that entered core in 5.009005). |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
[DualLife] |
191
|
|
|
|
|
|
|
entered_core=5.006001 |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
=head2 entered_core |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
Indicates when the distribution joined core. This option is not normally |
198
|
|
|
|
|
|
|
needed, as L<Module::CoreList> is used to determine this. |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head2 eumm_bundled |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Boolean for distributions bundled with ExtUtils::MakeMaker. Prior to v5.12, |
203
|
|
|
|
|
|
|
bundled modules might get installed into the core library directory, so |
204
|
|
|
|
|
|
|
even if they didn't come into core until later, they need to be forced into |
205
|
|
|
|
|
|
|
core prior to v5.12 so they take precedence. |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
=for Pod::Coverage munge_files |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
=head1 SUPPORT |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
Bugs may be submitted through L<the RT bug tracker|https://rt.cpan.org/Public/Dist/Display.html?Name=Dist-Zilla-Plugin-DualLife> |
212
|
|
|
|
|
|
|
(or L<bug-Dist-Zilla-Plugin-DualLife@rt.cpan.org|mailto:bug-Dist-Zilla-Plugin-DualLife@rt.cpan.org>). |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
There is also a mailing list available for users of this distribution, at |
215
|
|
|
|
|
|
|
L<http://dzil.org/#mailing-list>. |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
There is also an irc channel available for users of this distribution, at |
218
|
|
|
|
|
|
|
L<C<#distzilla> on C<irc.perl.org>|irc://irc.perl.org/#distzilla>. |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=head1 AUTHOR |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=for stopwords Karen Etheridge David Golden |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
=over 4 |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
=item * |
231
|
|
|
|
|
|
|
|
232
|
|
|
|
|
|
|
Karen Etheridge <ether@cpan.org> |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
=item * |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
David Golden <dagolden@cpan.org> |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
=back |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENCE |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Florian Ragwitz. |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
245
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
=cut |