line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package ExtUtils::Command::MM; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
require 5.006; |
4
|
|
|
|
|
|
|
|
5
|
2
|
|
|
2
|
|
25498
|
use strict; |
|
2
|
|
|
|
|
10
|
|
|
2
|
|
|
|
|
60
|
|
6
|
2
|
|
|
2
|
|
13
|
use warnings; |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
265
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
|
|
|
|
|
|
our @ISA = qw(Exporter); |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
our @EXPORT = qw(test_harness pod2man perllocal_install uninstall |
12
|
|
|
|
|
|
|
warn_if_old_packlist test_s cp_nonempty); |
13
|
|
|
|
|
|
|
our $VERSION = '7.70'; |
14
|
|
|
|
|
|
|
$VERSION =~ tr/_//d; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
my $Is_VMS = $^O eq 'VMS'; |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub mtime { |
19
|
2
|
|
|
2
|
|
13
|
no warnings 'redefine'; |
|
2
|
|
|
|
|
23
|
|
|
2
|
|
|
|
|
2597
|
|
20
|
0
|
|
|
0
|
0
|
0
|
local $@; |
21
|
|
|
|
|
|
|
*mtime = (eval { require Time::HiRes } && defined &Time::HiRes::stat) |
22
|
0
|
|
|
0
|
|
0
|
? sub { (Time::HiRes::stat($_[0]))[9] } |
23
|
0
|
|
|
0
|
|
0
|
: sub { ( stat($_[0]))[9] } |
24
|
0
|
0
|
0
|
|
|
0
|
; |
25
|
0
|
|
|
|
|
0
|
goto &mtime; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=head1 NAME |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
ExtUtils::Command::MM - Commands for the MM's to use in Makefiles |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=head1 SYNOPSIS |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
perl "-MExtUtils::Command::MM" -e "function" "--" arguments... |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=head1 DESCRIPTION |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
B<FOR INTERNAL USE ONLY!> The interface is not stable. |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
ExtUtils::Command::MM encapsulates code which would otherwise have to |
42
|
|
|
|
|
|
|
be done with large "one" liners. |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Any $(FOO) used in the examples are make variables, not Perl. |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=over 4 |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=item B<test_harness> |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
test_harness($verbose, @test_libs); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
Runs the tests on @ARGV via Test::Harness passing through the $verbose |
53
|
|
|
|
|
|
|
flag. Any @test_libs will be unshifted onto the test's @INC. |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
@test_libs are run in alphabetical order. |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=cut |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub test_harness { |
60
|
0
|
|
|
0
|
1
|
0
|
require Test::Harness; |
61
|
0
|
|
|
|
|
0
|
require File::Spec; |
62
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
0
|
$Test::Harness::verbose = shift; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# Because Windows doesn't do this for us and listing all the *.t files |
66
|
|
|
|
|
|
|
# out on the command line can blow over its exec limit. |
67
|
0
|
|
|
|
|
0
|
require ExtUtils::Command; |
68
|
0
|
|
|
|
|
0
|
my @argv = ExtUtils::Command::expand_wildcards(@ARGV); |
69
|
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
0
|
local @INC = @INC; |
71
|
0
|
|
|
|
|
0
|
unshift @INC, map { File::Spec->rel2abs($_) } @_; |
|
0
|
|
|
|
|
0
|
|
72
|
0
|
|
|
|
|
0
|
Test::Harness::runtests(sort { lc $a cmp lc $b } @argv); |
|
0
|
|
|
|
|
0
|
|
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=item B<pod2man> |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
pod2man( '--option=value', |
80
|
|
|
|
|
|
|
$podfile1 => $manpage1, |
81
|
|
|
|
|
|
|
$podfile2 => $manpage2, |
82
|
|
|
|
|
|
|
... |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# or args on @ARGV |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
pod2man() is a function performing most of the duties of the pod2man |
88
|
|
|
|
|
|
|
program. Its arguments are exactly the same as pod2man as of 5.8.0 |
89
|
|
|
|
|
|
|
with the addition of: |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
--perm_rw octal permission to set the resulting manpage to |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
And the removal of: |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
--verbose/-v |
96
|
|
|
|
|
|
|
--help/-h |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
If no arguments are given to pod2man it will read from @ARGV. |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
If Pod::Man is unavailable, this function will warn and return undef. |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=cut |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
sub pod2man { |
105
|
2
|
100
|
|
2
|
1
|
838
|
local @ARGV = @_ ? @_ : @ARGV; |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
{ |
108
|
2
|
|
|
|
|
4
|
local $@; |
|
2
|
|
|
|
|
4
|
|
109
|
2
|
100
|
|
|
|
4
|
if( !eval { require Pod::Man } ) { |
|
2
|
|
|
|
|
810
|
|
110
|
1
|
|
|
|
|
21
|
warn "Pod::Man is not available: $@". |
111
|
|
|
|
|
|
|
"Man pages will not be generated during this install.\n"; |
112
|
1
|
|
|
|
|
15
|
return 0; |
113
|
|
|
|
|
|
|
} |
114
|
|
|
|
|
|
|
} |
115
|
1
|
|
|
|
|
56664
|
require Getopt::Long; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# We will cheat and just use Getopt::Long. We fool it by putting |
118
|
|
|
|
|
|
|
# our arguments into @ARGV. Should be safe. |
119
|
1
|
|
|
|
|
10714
|
my %options = (); |
120
|
1
|
|
|
|
|
4
|
Getopt::Long::config ('bundling_override'); |
121
|
1
|
|
|
|
|
33
|
Getopt::Long::GetOptions (\%options, |
122
|
|
|
|
|
|
|
'section|s=s', 'release|r=s', 'center|c=s', |
123
|
|
|
|
|
|
|
'date|d=s', 'fixed=s', 'fixedbold=s', 'fixeditalic=s', |
124
|
|
|
|
|
|
|
'fixedbolditalic=s', 'official|o', 'quotes|q=s', 'lax|l', |
125
|
|
|
|
|
|
|
'name|n=s', 'perm_rw=i', 'utf8|u' |
126
|
|
|
|
|
|
|
); |
127
|
1
|
50
|
|
|
|
1125
|
delete $options{utf8} unless $Pod::Man::VERSION >= 2.17; |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
# If there's no files, don't bother going further. |
130
|
1
|
50
|
|
|
|
6
|
return 0 unless @ARGV; |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# Official sets --center, but don't override things explicitly set. |
133
|
0
|
0
|
0
|
|
|
|
if ($options{official} && !defined $options{center}) { |
134
|
0
|
|
|
|
|
|
$options{center} = q[Perl Programmer's Reference Guide]; |
135
|
|
|
|
|
|
|
} |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
# This isn't a valid Pod::Man option and is only accepted for backwards |
138
|
|
|
|
|
|
|
# compatibility. |
139
|
0
|
|
|
|
|
|
delete $options{lax}; |
140
|
0
|
|
|
|
|
|
my $count = scalar @ARGV / 2; |
141
|
0
|
0
|
|
|
|
|
my $plural = $count == 1 ? 'document' : 'documents'; |
142
|
0
|
|
|
|
|
|
print "Manifying $count pod $plural\n"; |
143
|
|
|
|
|
|
|
|
144
|
0
|
|
|
|
|
|
do {{ # so 'next' works |
145
|
0
|
|
|
|
|
|
my ($pod, $man) = splice(@ARGV, 0, 2); |
|
0
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
|
147
|
0
|
0
|
0
|
|
|
|
next if ((-e $man) && |
|
|
|
0
|
|
|
|
|
148
|
|
|
|
|
|
|
(mtime($man) > mtime($pod)) && |
149
|
|
|
|
|
|
|
(mtime($man) > mtime("Makefile"))); |
150
|
|
|
|
|
|
|
|
151
|
0
|
|
|
|
|
|
my $parser = Pod::Man->new(%options); |
152
|
|
|
|
|
|
|
$parser->parse_from_file($pod, $man) |
153
|
0
|
0
|
|
|
|
|
or do { warn("Could not install $man\n"); next }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
0
|
0
|
|
|
|
|
if (exists $options{perm_rw}) { |
156
|
|
|
|
|
|
|
chmod(oct($options{perm_rw}), $man) |
157
|
0
|
0
|
|
|
|
|
or do { warn("chmod $options{perm_rw} $man: $!\n"); next }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
} |
159
|
|
|
|
|
|
|
}} while @ARGV; |
160
|
|
|
|
|
|
|
|
161
|
0
|
|
|
|
|
|
return 1; |
162
|
|
|
|
|
|
|
} |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item B<warn_if_old_packlist> |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
perl "-MExtUtils::Command::MM" -e warn_if_old_packlist <somefile> |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
Displays a warning that an old packlist file was found. Reads the |
170
|
|
|
|
|
|
|
filename from @ARGV. |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=cut |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
sub warn_if_old_packlist { |
175
|
0
|
|
|
0
|
1
|
|
my $packlist = $ARGV[0]; |
176
|
|
|
|
|
|
|
|
177
|
0
|
0
|
|
|
|
|
return unless -f $packlist; |
178
|
0
|
|
|
|
|
|
print <<"PACKLIST_WARNING"; |
179
|
|
|
|
|
|
|
WARNING: I have found an old package in |
180
|
|
|
|
|
|
|
$packlist. |
181
|
|
|
|
|
|
|
Please make sure the two installations are not conflicting |
182
|
|
|
|
|
|
|
PACKLIST_WARNING |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
} |
185
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=item B<perllocal_install> |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
perl "-MExtUtils::Command::MM" -e perllocal_install |
190
|
|
|
|
|
|
|
<type> <module name> <key> <value> ... |
191
|
|
|
|
|
|
|
|
192
|
|
|
|
|
|
|
# VMS only, key|value pairs come on STDIN |
193
|
|
|
|
|
|
|
perl "-MExtUtils::Command::MM" -e perllocal_install |
194
|
|
|
|
|
|
|
<type> <module name> < <key>|<value> ... |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
Prints a fragment of POD suitable for appending to perllocal.pod. |
197
|
|
|
|
|
|
|
Arguments are read from @ARGV. |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
'type' is the type of what you're installing. Usually 'Module'. |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
'module name' is simply the name of your module. (Foo::Bar) |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
Key/value pairs are extra information about the module. Fields include: |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
installed into which directory your module was out into |
206
|
|
|
|
|
|
|
LINKTYPE dynamic or static linking |
207
|
|
|
|
|
|
|
VERSION module version number |
208
|
|
|
|
|
|
|
EXE_FILES any executables installed in a space separated |
209
|
|
|
|
|
|
|
list |
210
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=cut |
212
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
sub perllocal_install { |
214
|
0
|
|
|
0
|
1
|
|
my($type, $name) = splice(@ARGV, 0, 2); |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
# VMS feeds args as a piped file on STDIN since it usually can't |
217
|
|
|
|
|
|
|
# fit all the args on a single command line. |
218
|
0
|
0
|
|
|
|
|
my @mod_info = $Is_VMS ? split /\|/, <STDIN> |
219
|
|
|
|
|
|
|
: @ARGV; |
220
|
|
|
|
|
|
|
|
221
|
0
|
|
|
|
|
|
my $pod; |
222
|
0
|
|
0
|
|
|
|
my $time = gmtime($ENV{SOURCE_DATE_EPOCH} || time); |
223
|
0
|
|
|
|
|
|
$pod = sprintf <<'POD', scalar($time), $type, $name, $name; |
224
|
|
|
|
|
|
|
=head2 %s: C<%s> L<%s|%s> |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=over 4 |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
POD |
229
|
|
|
|
|
|
|
|
230
|
0
|
|
|
|
|
|
do { |
231
|
0
|
|
|
|
|
|
my($key, $val) = splice(@mod_info, 0, 2); |
232
|
|
|
|
|
|
|
|
233
|
0
|
|
|
|
|
|
$pod .= <<POD |
234
|
|
|
|
|
|
|
=item * |
235
|
|
|
|
|
|
|
|
236
|
|
|
|
|
|
|
C<$key: $val> |
237
|
|
|
|
|
|
|
|
238
|
|
|
|
|
|
|
POD |
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
} while(@mod_info); |
241
|
|
|
|
|
|
|
|
242
|
0
|
|
|
|
|
|
$pod .= "=back\n\n"; |
243
|
0
|
|
|
|
|
|
$pod =~ s/^ //mg; |
244
|
0
|
|
|
|
|
|
print $pod; |
245
|
|
|
|
|
|
|
|
246
|
0
|
|
|
|
|
|
return 1; |
247
|
|
|
|
|
|
|
} |
248
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
=item B<uninstall> |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
perl "-MExtUtils::Command::MM" -e uninstall <packlist> |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
A wrapper around ExtUtils::Install::uninstall(). Warns that |
254
|
|
|
|
|
|
|
uninstallation is deprecated and doesn't actually perform the |
255
|
|
|
|
|
|
|
uninstallation. |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
=cut |
258
|
|
|
|
|
|
|
|
259
|
|
|
|
|
|
|
sub uninstall { |
260
|
0
|
|
|
0
|
1
|
|
my($packlist) = shift @ARGV; |
261
|
|
|
|
|
|
|
|
262
|
0
|
|
|
|
|
|
require ExtUtils::Install; |
263
|
|
|
|
|
|
|
|
264
|
0
|
|
|
|
|
|
print <<'WARNING'; |
265
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
Uninstall is unsafe and deprecated, the uninstallation was not performed. |
267
|
|
|
|
|
|
|
We will show what would have been done. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
WARNING |
270
|
|
|
|
|
|
|
|
271
|
0
|
|
|
|
|
|
ExtUtils::Install::uninstall($packlist, 1, 1); |
272
|
|
|
|
|
|
|
|
273
|
0
|
|
|
|
|
|
print <<'WARNING'; |
274
|
|
|
|
|
|
|
|
275
|
|
|
|
|
|
|
Uninstall is unsafe and deprecated, the uninstallation was not performed. |
276
|
|
|
|
|
|
|
Please check the list above carefully, there may be errors. |
277
|
|
|
|
|
|
|
Remove the appropriate files manually. |
278
|
|
|
|
|
|
|
Sorry for the inconvenience. |
279
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
WARNING |
281
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
} |
283
|
|
|
|
|
|
|
|
284
|
|
|
|
|
|
|
=item B<test_s> |
285
|
|
|
|
|
|
|
|
286
|
|
|
|
|
|
|
perl "-MExtUtils::Command::MM" -e test_s <file> |
287
|
|
|
|
|
|
|
|
288
|
|
|
|
|
|
|
Tests if a file exists and is not empty (size > 0). |
289
|
|
|
|
|
|
|
I<Exits> with 0 if it does, 1 if it does not. |
290
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=cut |
292
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
sub test_s { |
294
|
0
|
0
|
|
0
|
1
|
|
exit(-s $ARGV[0] ? 0 : 1); |
295
|
|
|
|
|
|
|
} |
296
|
|
|
|
|
|
|
|
297
|
|
|
|
|
|
|
=item B<cp_nonempty> |
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
perl "-MExtUtils::Command::MM" -e cp_nonempty <srcfile> <dstfile> <perm> |
300
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
Tests if the source file exists and is not empty (size > 0). If it is not empty |
302
|
|
|
|
|
|
|
it copies it to the given destination with the given permissions. |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
=back |
305
|
|
|
|
|
|
|
|
306
|
|
|
|
|
|
|
=cut |
307
|
|
|
|
|
|
|
|
308
|
|
|
|
|
|
|
sub cp_nonempty { |
309
|
0
|
|
|
0
|
1
|
|
my @args = @ARGV; |
310
|
0
|
0
|
|
|
|
|
return 0 unless -s $args[0]; |
311
|
0
|
|
|
|
|
|
require ExtUtils::Command; |
312
|
|
|
|
|
|
|
{ |
313
|
0
|
|
|
|
|
|
local @ARGV = @args[0,1]; |
314
|
0
|
|
|
|
|
|
ExtUtils::Command::cp(@ARGV); |
315
|
|
|
|
|
|
|
} |
316
|
|
|
|
|
|
|
{ |
317
|
0
|
|
|
|
|
|
local @ARGV = @args[2,1]; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
318
|
0
|
|
|
|
|
|
ExtUtils::Command::chmod(@ARGV); |
319
|
|
|
|
|
|
|
} |
320
|
|
|
|
|
|
|
} |
321
|
|
|
|
|
|
|
|
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
1; |