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