line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/perl -w |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package HPUX::SDUX; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
23241
|
use Carp; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
99
|
|
6
|
1
|
|
|
1
|
|
5
|
use Config; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
40
|
|
7
|
1
|
|
|
1
|
|
5
|
use Cwd qw( cwd ); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
45
|
|
8
|
1
|
|
|
1
|
|
821
|
use DirHandle; |
|
1
|
|
|
|
|
2534
|
|
|
1
|
|
|
|
|
25
|
|
9
|
1
|
|
|
1
|
|
6
|
use Exporter(); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
15
|
|
10
|
1
|
|
|
1
|
|
4654
|
use ExtUtils::MakeMaker; |
|
1
|
|
|
|
|
142124
|
|
|
1
|
|
|
|
|
164
|
|
11
|
1
|
|
|
1
|
|
825
|
use File::Copy; |
|
1
|
|
|
|
|
5239
|
|
|
1
|
|
|
|
|
88
|
|
12
|
1
|
|
|
1
|
|
8
|
use strict qw( vars ); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
46
|
|
13
|
1
|
|
|
|
|
141
|
use vars qw( |
14
|
|
|
|
|
|
|
$VERSION @EXPORT |
15
|
1
|
|
|
1
|
|
6
|
); |
|
1
|
|
|
|
|
2
|
|
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
$VERSION='0.03'; |
18
|
|
|
|
|
|
|
@HPUX::SDUX::ISA = qw( Exporter ); |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# We will export &wmf so that |
21
|
|
|
|
|
|
|
# perl -MHPUX::SDUX -e wmf |
22
|
|
|
|
|
|
|
# makes sense. |
23
|
|
|
|
|
|
|
@EXPORT= qw( |
24
|
|
|
|
|
|
|
&wmf |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
BEGIN { |
28
|
1
|
|
|
1
|
|
6553
|
my $cwd = cwd; |
29
|
1
|
50
|
|
|
|
332
|
die "This module is useful only on an HP-UX system" unless $^O eq 'hpux'; |
30
|
0
|
0
|
|
|
|
|
unless (-f 'Makefile.PL') { die "Makefile.PL does not exist in $cwd: $!" }; |
|
0
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
END { |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
###################################################################### |
37
|
|
|
|
|
|
|
# The basic strategy is to create a new file Makefile.SDUX, which is a copy of |
38
|
|
|
|
|
|
|
# Makefile.PL plus a few routines overriding MakeMaker routines, |
39
|
|
|
|
|
|
|
# execute Makefile.SDUX to write Makefile, and then add a new target 'depot.' |
40
|
|
|
|
|
|
|
# |
41
|
|
|
|
|
|
|
# The target 'depot' will: |
42
|
|
|
|
|
|
|
# 1. install module into a temporary directory (./sdux by default) |
43
|
|
|
|
|
|
|
# and determine the content of this module distribution |
44
|
|
|
|
|
|
|
# 2. write module.psf file with &HPUX::SDUX::write_psf |
45
|
|
|
|
|
|
|
# 3. call 'swpackage -s module.psf' |
46
|
|
|
|
|
|
|
# |
47
|
|
|
|
|
|
|
# Notice that you have to have certain privileges to make 'depot'. |
48
|
|
|
|
|
|
|
###################################################################### |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
###################################################################### |
51
|
|
|
|
|
|
|
# variables needed in multiple subroutines |
52
|
|
|
|
|
|
|
###################################################################### |
53
|
|
|
|
|
|
|
my $cwd = cwd; |
54
|
|
|
|
|
|
|
my $sdux_install_dir = "$cwd/sdux"; # the temporary directory to install module |
55
|
|
|
|
|
|
|
my ( $module_version, $module_name, $module_author, $module_prefix ); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
###################################################################### |
58
|
|
|
|
|
|
|
# Anonymous subroutines inaccessible from other packages |
59
|
|
|
|
|
|
|
###################################################################### |
60
|
|
|
|
|
|
|
my $__parse_version = sub { |
61
|
|
|
|
|
|
|
# Copied from &ExtUtils::MM_Unix::parse_version (v1.3.3), sans OO-interface |
62
|
|
|
|
|
|
|
# Also reformatted |
63
|
|
|
|
|
|
|
my $parsefile = shift; |
64
|
|
|
|
|
|
|
my $result; |
65
|
|
|
|
|
|
|
local *FH; |
66
|
|
|
|
|
|
|
local $/ = "\n"; |
67
|
|
|
|
|
|
|
open(FH,$parsefile) or die "Could not open '$parsefile': $!"; |
68
|
|
|
|
|
|
|
my $inpod = 0; |
69
|
|
|
|
|
|
|
while () { |
70
|
|
|
|
|
|
|
$inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod; |
71
|
|
|
|
|
|
|
next if $inpod || /^\s*#/; |
72
|
|
|
|
|
|
|
chop; |
73
|
|
|
|
|
|
|
# next unless /\$(([\w\:\']*)\bVERSION)\b.*\=/; |
74
|
|
|
|
|
|
|
next unless /([\$*])(([\w\:\']*)\bVERSION)\b.*\=/; |
75
|
|
|
|
|
|
|
my $eval = qq{ |
76
|
|
|
|
|
|
|
package ExtUtils::MakeMaker::_version; |
77
|
|
|
|
|
|
|
no strict; |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
local $1$2; |
80
|
|
|
|
|
|
|
\$$2=undef; do { |
81
|
|
|
|
|
|
|
$_ |
82
|
|
|
|
|
|
|
}; \$$2 |
83
|
|
|
|
|
|
|
}; |
84
|
|
|
|
|
|
|
local $^W = 0; |
85
|
|
|
|
|
|
|
$result = eval($eval); |
86
|
|
|
|
|
|
|
warn "Could not eval '$eval' in $parsefile: $@" if $@; |
87
|
|
|
|
|
|
|
last; |
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
close FH; |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
$result = "undef" unless defined $result; |
92
|
|
|
|
|
|
|
return $result; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
}; |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $__get_module_info = sub { |
97
|
|
|
|
|
|
|
# Get basic information about the module |
98
|
|
|
|
|
|
|
my ($version, $version_from); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
open MAKEFILEPL, "< Makefile.PL" or die "Cannot open Makefile.PL: $!"; |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
do { $_ = } until ( $_ =~ m/WriteMakefile/ ); # skip until the call to WriteMakefile |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
while () { |
105
|
|
|
|
|
|
|
if ( m/(['"]?)(?:DIST)?NAME(\1?)\s*=>\s*['"]?([-A-Za-z0-9:]+)/ ) { |
106
|
|
|
|
|
|
|
$module_name = $3; |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
if ( m/(['"]?)AUTHOR(\1?)\s*=>\s*['"]?([\w ]+)/ ) { |
109
|
|
|
|
|
|
|
$module_author = $3; |
110
|
|
|
|
|
|
|
$module_author =~ s/\s*$//; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
if ( m/(['"]?)VERSION_FROM(\1?)\s*=>\s*(['"])(\S*)(\3)/ ) { |
113
|
|
|
|
|
|
|
$version_from = $4; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
close MAKEFILEPL; |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
$version = &$__parse_version($version_from); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
return ( $version, $module_name, $module_author, $Config{prefix} ); |
121
|
|
|
|
|
|
|
}; |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
my $__top_subdirs = sub { |
124
|
|
|
|
|
|
|
# Given a directory name, return an array of top-level subdirectory names |
125
|
|
|
|
|
|
|
# in that directory. Based on "Perl Cookbook", recipe 9.5. |
126
|
|
|
|
|
|
|
my $dir = shift(); |
127
|
|
|
|
|
|
|
my $dh = DirHandle->new($dir) or die "Cannot open $dir: $!"; |
128
|
|
|
|
|
|
|
return sort |
129
|
|
|
|
|
|
|
grep { s[$dir/][] } # remove "$dir/" |
130
|
|
|
|
|
|
|
grep { -d } # only directories |
131
|
|
|
|
|
|
|
map { "$dir/$_" } |
132
|
|
|
|
|
|
|
grep { !/^\./ } |
133
|
|
|
|
|
|
|
$dh->read(); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
}; |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
( $module_version, $module_name, $module_author, $module_prefix ) = &$__get_module_info(); |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
my $__write_filesets_section = sub { |
140
|
|
|
|
|
|
|
# filehandle PSFFILE should be open when this routine is called. |
141
|
|
|
|
|
|
|
# required in PSF layout version 1.0 |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
my $current_dir = cwd; |
144
|
|
|
|
|
|
|
my $dir = shift(); |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
print STDERR "Writing $dir fileset section\n"; |
147
|
|
|
|
|
|
|
print PSFFILE <<"FILESET_SECTION"; |
148
|
|
|
|
|
|
|
fileset |
149
|
|
|
|
|
|
|
tag $dir |
150
|
|
|
|
|
|
|
directory $sdux_install_dir/$dir = $module_prefix/$dir |
151
|
|
|
|
|
|
|
file * |
152
|
|
|
|
|
|
|
end |
153
|
|
|
|
|
|
|
FILESET_SECTION |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
}; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
my $__write_subproducts_section = sub { |
158
|
|
|
|
|
|
|
# optional in PSF layout version 1.0 |
159
|
|
|
|
|
|
|
print STDERR "Writing subproducts section\n"; |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# for now, we don't use this section |
162
|
|
|
|
|
|
|
}; |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
my $__write_products_section = sub { |
165
|
|
|
|
|
|
|
# filehandle PSFFILE should be open when this routine is called. |
166
|
|
|
|
|
|
|
# required in PSF layout version 1.0 |
167
|
|
|
|
|
|
|
print STDERR "Writing products section\n"; |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
my $current_dir = cwd; |
170
|
|
|
|
|
|
|
$module_name =~ s/::/-/g; |
171
|
|
|
|
|
|
|
$module_name = 'CPAN-'.$module_name; |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
print PSFFILE <<"PRODUCT_SECTION_PREAMBLE"; |
174
|
|
|
|
|
|
|
product |
175
|
|
|
|
|
|
|
tag $module_name |
176
|
|
|
|
|
|
|
revision $module_version |
177
|
|
|
|
|
|
|
directory $module_prefix |
178
|
|
|
|
|
|
|
readme < $current_dir/README |
179
|
|
|
|
|
|
|
is_locatable false |
180
|
|
|
|
|
|
|
is_patch false |
181
|
|
|
|
|
|
|
os_name HP-UX |
182
|
|
|
|
|
|
|
os_release ?.11.* |
183
|
|
|
|
|
|
|
os_version ? |
184
|
|
|
|
|
|
|
category_tag language_perl |
185
|
|
|
|
|
|
|
PRODUCT_SECTION_PREAMBLE |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
my @dirs = &$__top_subdirs($sdux_install_dir); |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
foreach my $dir (@dirs) { |
190
|
|
|
|
|
|
|
&$__write_filesets_section($dir); |
191
|
|
|
|
|
|
|
} |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
print PSFFILE <<"PRODUCT_SECTION_POSTAMBLE"; # close 'product' |
194
|
|
|
|
|
|
|
end |
195
|
|
|
|
|
|
|
PRODUCT_SECTION_POSTAMBLE |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
}; |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
###################################################################### |
200
|
|
|
|
|
|
|
# |
201
|
|
|
|
|
|
|
# &HPUX::SDUX::wmf |
202
|
|
|
|
|
|
|
# |
203
|
|
|
|
|
|
|
###################################################################### |
204
|
|
|
|
|
|
|
sub wmf() { |
205
|
|
|
|
|
|
|
my $package_name = __PACKAGE__; |
206
|
|
|
|
|
|
|
my $sdux_makefile = 'Makefile.SDUX'; |
207
|
|
|
|
|
|
|
my $makefile = 'Makefile.PL'; # read Makefile.PL by default |
208
|
|
|
|
|
|
|
die "$makefile does not exist: $?" unless (-f $makefile); |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
{ |
211
|
|
|
|
|
|
|
# run Makefile.PL with appropriate arguments |
212
|
|
|
|
|
|
|
# save off @ARGV, just in case we need it later |
213
|
|
|
|
|
|
|
my @makefile_argv = @ARGV; |
214
|
|
|
|
|
|
|
local @ARGV; |
215
|
|
|
|
|
|
|
if (@makefile_argv) { |
216
|
|
|
|
|
|
|
# override any 'SITEPREFIX=' run-time option |
217
|
|
|
|
|
|
|
push @makefile_argv, ( "SITEPREFIX=$sdux_install_dir" ); |
218
|
|
|
|
|
|
|
} else { |
219
|
|
|
|
|
|
|
@makefile_argv = ( "SITEPREFIX=$sdux_install_dir" ) |
220
|
|
|
|
|
|
|
} |
221
|
|
|
|
|
|
|
@ARGV = @makefile_argv; |
222
|
|
|
|
|
|
|
open MYMAKEFILE, ">> $sdux_makefile" || die "Cannot write to $sdux_makefile: $?"; |
223
|
|
|
|
|
|
|
File::Copy::copy ($makefile,$sdux_makefile); |
224
|
|
|
|
|
|
|
print MYMAKEFILE <<"END_MAKEFILE_PL"; |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
# ExtUtils::MakeMaker methods overridden by $package_name |
227
|
|
|
|
|
|
|
sub MY::clean { |
228
|
|
|
|
|
|
|
my \$clean = &ExtUtils::MM_Unix::clean; |
229
|
|
|
|
|
|
|
\$clean .= "\\t\\\$(RM_RF) HPUX sdux \\\$(DEV_NULL)\\n"; |
230
|
|
|
|
|
|
|
\$clean .= "\\t-\\\$(MV) module.psf module.psf.old \\\$(DEV_NULL)\\n"; |
231
|
|
|
|
|
|
|
\$clean .= "\\t-\\\$(MV) Makefile.SDUX Makefile.SDUX.old \\\$(DEV_NULL)"; |
232
|
|
|
|
|
|
|
\$clean; |
233
|
|
|
|
|
|
|
} |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
sub MY::realclean { |
236
|
|
|
|
|
|
|
my \$realclean = &ExtUtils::MM_Unix::realclean; |
237
|
|
|
|
|
|
|
\$realclean .= "\\t\\\$(RM_RF) module.psf module.psf.old \\\$(DEV_NULL)\\n"; |
238
|
|
|
|
|
|
|
\$realclean .= "\\t\\\$(RM_RF) Makefile.SDUX Makefile.SDUX.old \\\$(DEV_NULL)"; |
239
|
|
|
|
|
|
|
\$realclean; |
240
|
|
|
|
|
|
|
} |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
sub MY::postamble { |
243
|
|
|
|
|
|
|
my \$postamble = <<'END_DEPOT'; |
244
|
|
|
|
|
|
|
depot: install |
245
|
|
|
|
|
|
|
\$(PERL) -M$package_name -e ${package_name}::write_psf |
246
|
|
|
|
|
|
|
swpackage -s module.psf -x write_remote_files=true \@$sdux_install_dir |
247
|
|
|
|
|
|
|
END_DEPOT |
248
|
|
|
|
|
|
|
} |
249
|
|
|
|
|
|
|
END_MAKEFILE_PL |
250
|
|
|
|
|
|
|
close MYMAKEFILE; |
251
|
|
|
|
|
|
|
do $sdux_makefile or die "Cannot create Makefile: $!"; |
252
|
|
|
|
|
|
|
} |
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
} |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
###################################################################### |
257
|
|
|
|
|
|
|
# |
258
|
|
|
|
|
|
|
# &HPUX::SDUX::write_psf |
259
|
|
|
|
|
|
|
# This is called in the 'depot' target of our Makefile |
260
|
|
|
|
|
|
|
# |
261
|
|
|
|
|
|
|
###################################################################### |
262
|
|
|
|
|
|
|
sub write_psf() { |
263
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
# This routine should be called only from the "depot" target. |
265
|
|
|
|
|
|
|
# When we get here, 'make' should have made the target "install". |
266
|
|
|
|
|
|
|
# There should be a directory './sdux' whose content is what |
267
|
|
|
|
|
|
|
# the module needs. |
268
|
|
|
|
|
|
|
|
269
|
|
|
|
|
|
|
print STDERR "Writing PSF\n"; |
270
|
|
|
|
|
|
|
|
271
|
|
|
|
|
|
|
# information about the module |
272
|
|
|
|
|
|
|
my $current_dir = cwd; |
273
|
|
|
|
|
|
|
my $psf_file = 'module.psf'; |
274
|
|
|
|
|
|
|
my $psf_version = '1.0'; # just in case |
275
|
|
|
|
|
|
|
my $author_tag = $module_author; |
276
|
|
|
|
|
|
|
map { s/[^A-Z]//g } $author_tag; |
277
|
|
|
|
|
|
|
if ($author_tag) { |
278
|
|
|
|
|
|
|
$author_tag = 'CPAN'.$author_tag |
279
|
|
|
|
|
|
|
} else { |
280
|
|
|
|
|
|
|
$author_tag = 'UNDEF' |
281
|
|
|
|
|
|
|
} |
282
|
|
|
|
|
|
|
|
283
|
|
|
|
|
|
|
open PSFFILE, "> $psf_file" or die "Cannot write to $psf_file: $?"; |
284
|
|
|
|
|
|
|
|
285
|
|
|
|
|
|
|
print PSFFILE <<"PSF_PREAMBLE"; |
286
|
|
|
|
|
|
|
depot |
287
|
|
|
|
|
|
|
layout_version $psf_version |
288
|
|
|
|
|
|
|
vendor |
289
|
|
|
|
|
|
|
tag $author_tag |
290
|
|
|
|
|
|
|
title $module_author |
291
|
|
|
|
|
|
|
end |
292
|
|
|
|
|
|
|
category |
293
|
|
|
|
|
|
|
tag language_perl |
294
|
|
|
|
|
|
|
description A perl module |
295
|
|
|
|
|
|
|
end |
296
|
|
|
|
|
|
|
PSF_PREAMBLE |
297
|
|
|
|
|
|
|
|
298
|
|
|
|
|
|
|
&$__write_products_section(); |
299
|
|
|
|
|
|
|
|
300
|
|
|
|
|
|
|
print PSFFILE <<"PSF_POSTAMBLE"; # close 'depot' |
301
|
|
|
|
|
|
|
end |
302
|
|
|
|
|
|
|
PSF_POSTAMBLE |
303
|
|
|
|
|
|
|
|
304
|
|
|
|
|
|
|
close PSFFILE or die "Cannot close $psf_file: $?"; |
305
|
|
|
|
|
|
|
} |
306
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
1; # end of HPUX::SDUX |
308
|
|
|
|
|
|
|
|
309
|
|
|
|
|
|
|
__END__ |