line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Devel::Required; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# set version information |
4
|
|
|
|
|
|
|
$VERSION= '0.16'; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
# make sure we do everything by the book from now on |
7
|
3
|
|
|
3
|
|
572851
|
use strict; |
|
3
|
|
|
|
|
29
|
|
|
3
|
|
|
|
|
92
|
|
8
|
3
|
|
|
3
|
|
18
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
144
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
# initializations |
11
|
|
|
|
|
|
|
my @TEXT; # list with text-file conversion |
12
|
|
|
|
|
|
|
my @POD; # list with pod-file conversion |
13
|
|
|
|
|
|
|
my $INSTALLATION; # any installation information |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# replace WriteMakefile with our own copy |
16
|
|
|
|
|
|
|
BEGIN { |
17
|
3
|
|
|
3
|
|
16
|
no warnings 'redefine'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
118
|
|
18
|
3
|
|
|
3
|
|
16
|
no strict 'refs'; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
1613
|
|
19
|
3
|
|
|
3
|
|
20
|
my $subname= caller() . '::WriteMakefile'; |
20
|
3
|
|
|
|
|
6
|
my $old= \&{$subname}; |
|
3
|
|
|
|
|
9
|
|
21
|
|
|
|
|
|
|
*$subname= sub { |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
# perform the old sub with parameters |
24
|
5
|
|
|
5
|
|
210693
|
@_= @_; # quick fix for brokennes in 5.9.5, as suggested by rgs |
25
|
5
|
|
|
|
|
30
|
$old->( @_ ); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
# initializations |
28
|
5
|
|
|
|
|
641540
|
my $pod; # pod filename to change |
29
|
|
|
|
|
|
|
my $modules; # hash reference to the module info |
30
|
5
|
|
|
|
|
0
|
my $required; # required text to replace |
31
|
5
|
|
|
|
|
0
|
my $version; # version text to replace |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
# each key and value pair passed to original WriteMakefile |
34
|
5
|
|
|
|
|
77
|
while (@_) { |
35
|
14
|
|
|
|
|
189
|
my ( $key, $value )= ( shift, shift ); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
# main module file |
38
|
14
|
100
|
|
|
|
83
|
if ( $key eq 'VERSION_FROM' ) { |
|
|
100
|
|
|
|
|
|
39
|
5
|
|
|
|
|
27
|
$pod= $value; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# required modules hash ref |
43
|
|
|
|
|
|
|
elsif ($key eq 'PREREQ_PM') { |
44
|
4
|
|
|
|
|
20
|
$modules= $value; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=for Explanation: |
48
|
|
|
|
|
|
|
Anything we don't handle is simply ignored. |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
# use E::M's logic to obtain version information |
55
|
5
|
|
|
|
|
74
|
($version)= _slurp('Makefile') =~ m#\nVERSION = (\d+\.\d+)#s; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# text to insert |
58
|
|
|
|
|
|
|
$required= join $/, |
59
|
6
|
|
100
|
|
|
93
|
map {" $_ (".($modules->{$_} || 'any').")"} |
60
|
3
|
|
|
|
|
26
|
sort {lc $a cmp lc $b} |
61
|
5
|
100
|
|
|
|
39
|
keys %{$modules} |
|
4
|
|
|
|
|
71
|
|
62
|
|
|
|
|
|
|
if $modules; |
63
|
5
|
|
100
|
|
|
53
|
$required ||= " (none)"; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# convert all text files that matter |
66
|
5
|
100
|
|
|
|
51
|
foreach ( grep { -s } @TEXT ? @TEXT : 'README' ) { |
|
5
|
|
|
|
|
125
|
|
67
|
5
|
50
|
|
|
|
73
|
_convert( $_, "Version:$/", " $version", "$/$/" ) |
68
|
|
|
|
|
|
|
if $version; |
69
|
5
|
|
|
|
|
68
|
_convert( $_, "Required Modules:$/", $required, "$/$/" ); |
70
|
5
|
100
|
|
|
|
47
|
_convert( $_, "Installation:$/", $INSTALLATION, "$/$/$/" ) |
71
|
|
|
|
|
|
|
if $INSTALLATION; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# convert all pod files that matter |
75
|
5
|
50
|
|
|
|
44
|
foreach ( grep { -s } @POD ? @POD : ($pod ? ($pod) : () ) ) { |
|
5
|
100
|
|
|
|
82
|
|
76
|
5
|
50
|
|
|
|
77
|
_convert( |
77
|
|
|
|
|
|
|
$_, |
78
|
|
|
|
|
|
|
"=head1 VERSION$/", |
79
|
|
|
|
|
|
|
"$/This documentation describes version $version.$/", |
80
|
|
|
|
|
|
|
"$/=" |
81
|
|
|
|
|
|
|
) if $version; |
82
|
5
|
|
|
|
|
116
|
_convert( $_, "=head1 REQUIRED MODULES$/", "$/$required$/", "$/=" ); |
83
|
5
|
100
|
|
|
|
68
|
_convert( $_, "=head1 INSTALLATION$/", "$/$INSTALLATION$/", "$/=") |
84
|
|
|
|
|
|
|
if $INSTALLATION; |
85
|
|
|
|
|
|
|
} |
86
|
3
|
|
|
|
|
1673
|
}; |
87
|
|
|
|
|
|
|
} #BEGIN |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# satisfy -require- |
90
|
|
|
|
|
|
|
1; |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
93
|
|
|
|
|
|
|
# |
94
|
|
|
|
|
|
|
# Standard Perl features |
95
|
|
|
|
|
|
|
# |
96
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
97
|
|
|
|
|
|
|
# IN: 1 class (ignored) |
98
|
|
|
|
|
|
|
# 2..N key/value pairs |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub import { |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
# lose the class |
103
|
4
|
|
|
4
|
|
4669
|
shift; |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
# for all key value pairs |
106
|
4
|
|
|
|
|
3132
|
while (@_) { |
107
|
4
|
|
|
|
|
24
|
my ( $type, $value )= ( shift, shift ); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
# set up text file processing |
110
|
4
|
100
|
|
|
|
23
|
if ( $type eq 'text' ) { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
111
|
1
|
50
|
|
|
|
1912
|
push @TEXT, ref $value ? @{$value} : ($value); |
|
0
|
|
|
|
|
0
|
|
112
|
|
|
|
|
|
|
} |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# set up pod file processing |
115
|
|
|
|
|
|
|
elsif ( $type eq 'pod' ) { |
116
|
1
|
50
|
|
|
|
6
|
push @POD,ref $value ? @{$value} : ($value); |
|
0
|
|
|
|
|
0
|
|
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
# set up maint/blead installation information |
120
|
|
|
|
|
|
|
elsif ( $type eq 'maint_blead' ) { |
121
|
1
|
|
|
|
|
10
|
$INSTALLATION= <<"INSTALLATION"; |
122
|
|
|
|
|
|
|
This distribution contains two versions of the code: one maintenance version |
123
|
|
|
|
|
|
|
for versions of perl < $value (known as 'maint'), and the version currently in |
124
|
|
|
|
|
|
|
development (known as 'blead'). The standard build for your perl version is: |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
perl Makefile.PL |
127
|
|
|
|
|
|
|
make |
128
|
|
|
|
|
|
|
make test |
129
|
|
|
|
|
|
|
make install |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
This will try to test and install the "blead" version of the code. If the |
132
|
|
|
|
|
|
|
Perl version does not support the "blead" version, then the running of the |
133
|
|
|
|
|
|
|
Makefile.PL will *fail*. In such a case, one can force the installing of |
134
|
|
|
|
|
|
|
the "maint" version of the code by doing: |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
perl Makefile.PL maint |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Alternately, if you want automatic selection behavior, you can set the |
139
|
|
|
|
|
|
|
AUTO_SELECT_MAINT_OR_BLEAD environment variable to a true value. On Unix-like |
140
|
|
|
|
|
|
|
systems like so: |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
AUTO_SELECT_MAINT_OR_BLEAD=1 perl Makefile.PL |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
If your perl does not support the "blead" version of the code, then it will |
145
|
|
|
|
|
|
|
automatically install the "maint" version of the code. |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
Please note that any additional parameters will simply be passed on to the |
148
|
|
|
|
|
|
|
underlying Makefile.PL processing. |
149
|
|
|
|
|
|
|
INSTALLATION |
150
|
1
|
|
|
|
|
1998
|
chomp $INSTALLATION; |
151
|
|
|
|
|
|
|
} |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
# huh? |
154
|
|
|
|
|
|
|
else { |
155
|
1
|
|
|
|
|
11
|
die qq{Don't know how to handle "$type"\n}; |
156
|
|
|
|
|
|
|
} |
157
|
|
|
|
|
|
|
} |
158
|
|
|
|
|
|
|
} #import |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
161
|
|
|
|
|
|
|
# |
162
|
|
|
|
|
|
|
# Internal subroutines |
163
|
|
|
|
|
|
|
# |
164
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
165
|
|
|
|
|
|
|
# _convert |
166
|
|
|
|
|
|
|
# |
167
|
|
|
|
|
|
|
# Perform the indicated conversion on the specified file |
168
|
|
|
|
|
|
|
# |
169
|
|
|
|
|
|
|
# IN: 1 filename |
170
|
|
|
|
|
|
|
# 2 string before to match |
171
|
|
|
|
|
|
|
# 3 string to insert between before and after |
172
|
|
|
|
|
|
|
# 4 string to match with after |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub _convert { |
175
|
22
|
|
|
22
|
|
166
|
my ( $filename, $before, $text, $after )= @_; |
176
|
22
|
|
|
|
|
45
|
local $_; |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=for Explanation: |
179
|
|
|
|
|
|
|
We want to make sure that this also runs on pre 5.6 perl's, so we're |
180
|
|
|
|
|
|
|
using old style open() |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
# there is something to process |
185
|
22
|
50
|
|
|
|
59
|
if ( my $contents= $_= _slurp($filename) ) { |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
# found and replaced text |
188
|
22
|
50
|
|
|
|
722
|
if ( s#$before(?:.*?)$after#$before$text$after#s ) { |
189
|
|
|
|
|
|
|
|
190
|
|
|
|
|
|
|
# same as before (no action) |
191
|
22
|
100
|
|
|
|
6859
|
if ($_ eq $contents) { |
|
|
50
|
|
|
|
|
|
192
|
|
|
|
|
|
|
} |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
# successfully saved file with changes |
195
|
|
|
|
|
|
|
elsif ( open( OUT, ">$filename" ) ) { |
196
|
16
|
|
|
|
|
128
|
print OUT $_; |
197
|
16
|
50
|
|
|
|
1089
|
close OUT |
198
|
|
|
|
|
|
|
or die qq{Problem flushing "$filename": $!\n}; |
199
|
16
|
50
|
|
|
|
396
|
die qq{Did not properly install "$filename"\n} |
200
|
|
|
|
|
|
|
unless -s $filename == length; |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
# could not save file |
204
|
|
|
|
|
|
|
else { |
205
|
0
|
|
|
|
|
0
|
warn qq{Could not open "$filename" for writing: $!\n}; |
206
|
|
|
|
|
|
|
} |
207
|
|
|
|
|
|
|
} |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
# couldn't replace |
210
|
|
|
|
|
|
|
else { |
211
|
0
|
|
|
|
|
0
|
$before =~ s#\s+$##s; |
212
|
0
|
|
|
|
|
0
|
warn qq{Could not find text marker "$before" in "$filename"\n}; |
213
|
|
|
|
|
|
|
} |
214
|
|
|
|
|
|
|
} |
215
|
|
|
|
|
|
|
} #_convert |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
218
|
|
|
|
|
|
|
# _slurp |
219
|
|
|
|
|
|
|
# |
220
|
|
|
|
|
|
|
# Return contents of given filename, a poor man's perl6 slurp(). Warns if |
221
|
|
|
|
|
|
|
# it could not open the specified file |
222
|
|
|
|
|
|
|
# |
223
|
|
|
|
|
|
|
# IN: 1 filename |
224
|
|
|
|
|
|
|
# OUT: 1 file contents |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
sub _slurp { |
227
|
27
|
|
|
27
|
|
66
|
my ($filename)= @_; |
228
|
27
|
|
|
|
|
39
|
my $contents; |
229
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
# there is something to process |
231
|
27
|
50
|
|
|
|
783
|
if ( open( IN, $filename ) ) { |
232
|
27
|
|
|
|
|
67
|
$contents= do { local $/; }; |
|
27
|
|
|
|
|
149
|
|
|
27
|
|
|
|
|
913
|
|
233
|
27
|
|
|
|
|
286
|
close IN; |
234
|
|
|
|
|
|
|
} |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
# couldn't read file |
237
|
|
|
|
|
|
|
else { |
238
|
0
|
|
|
|
|
0
|
warn qq{Could not open "$filename" for reading: $!\n}; |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
27
|
|
|
|
|
265
|
return $contents; |
242
|
|
|
|
|
|
|
} #_slurp |
243
|
|
|
|
|
|
|
|
244
|
|
|
|
|
|
|
#------------------------------------------------------------------------------- |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
__END__ |