Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 489 lines (375 sloc) 13.783 kB
a4123f8 @abw 2.04b
authored
1 #!/usr/bin/perl -w # -*- perl -*-
2
3 use strict;
c942c1b @abw Version 2.15
authored
4 use warnings;
a4123f8 @abw 2.04b
authored
5
2d0a850 @abw Added "use 5.006" constraint in Makefile.PL
authored
6 use 5.006;
a4123f8 @abw 2.04b
authored
7 use lib qw( ./lib );
714a8cd @abw * prep for release 2.07a
authored
8 use Config;
9 use File::Spec::Functions qw( catfile );
a4123f8 @abw 2.04b
authored
10 use Template;
11 use ExtUtils::MakeMaker;
c8d76d4 @abw *** empty log message ***
authored
12 use Cwd;
3ebfa07 @abw Initial revision
authored
13
e39913f @abw *** empty log message ***
authored
14 select STDERR;
15 $| = 1;
16 select STDOUT;
17
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
18 use vars qw( $TT_VERSION $TT_PREFIX
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
19 $TT_XS_ENABLE $TT_XS_DEFAULT
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
20 $TT_QUIET $TT_ACCEPT $TT_YES );
a4123f8 @abw 2.04b
authored
21
22 # check O/S to set sensible defaults
9be7d64 @abw approaching 2.04d
authored
23
24 my ($WIN32, $FLAVOUR, $PREFIX, $IMAGES, $MAKE);
dd62af1 @abw * Applied Chris' patch to fix win => MSWin32
authored
25 if ($^O eq 'MSWin32') { # any others also?
a4123f8 @abw 2.04b
authored
26 $WIN32 = 1;
27 $FLAVOUR = 'Win32';
8b5c5f7 @abw Couple more fixes/unfixes for Makefile.PL
authored
28 $PREFIX = 'C:/Program Files/Template Toolkit 2';
29 $IMAGES = '/tt2/images';
a4123f8 @abw 2.04b
authored
30 }
31 else {
32 $WIN32 = 0;
33 $FLAVOUR = 'Unix';
8b5c5f7 @abw Couple more fixes/unfixes for Makefile.PL
authored
34 $PREFIX = '/usr/local/tt2';
35 $IMAGES = '/tt2/images';
a4123f8 @abw 2.04b
authored
36 }
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
37 $MAKE=$Config{'make'};
a4123f8 @abw 2.04b
authored
38
9be7d64 @abw approaching 2.04d
authored
39
40 # read command line args putting TT_* into $ttconfig and
41 # everything else (regular Makefile.PL args, e.g. PREFIX)
42 # goes into $config
43
a4123f8 @abw 2.04b
authored
44 my (%config, %ttconfig);
28ffe70 @toddr Fixed bug RT#67918 - Bug in Makefile.PL command line parsing when 2 e…
toddr authored
45 while (shift @ARGV) {
46 my ($k, $v) = split(/=/, $_, 2);
a4123f8 @abw 2.04b
authored
47 if ($k =~ /^TT/) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
48 $ttconfig{ $k } = $v || 0;
a4123f8 @abw 2.04b
authored
49 }
50 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
51 $config{ $k } = $v || 0;
a4123f8 @abw 2.04b
authored
52 }
53 };
54
9be7d64 @abw approaching 2.04d
authored
55
56 # print help if they asked for it
57
a4123f8 @abw 2.04b
authored
58 if (exists $ttconfig{ TT_HELP }) {
59 print <<EOF;
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
60 The following options can be specified as command line
a4123f8 @abw 2.04b
authored
61 arguments to 'perl Makefile.PL'. e.g.
62
8b5c5f7 @abw Couple more fixes/unfixes for Makefile.PL
authored
63 perl Makefile.PL TT_XS_DEFAULT=y TT_ACCEPT=y
9be7d64 @abw approaching 2.04d
authored
64
65 TT_XS_ENABLE Enable XS Stash (y)
66 TT_XS_DEFAULT Use XS Stash by default (y)
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
67 TT_QUIET no messages (n)
9be7d64 @abw approaching 2.04d
authored
68 TT_ACCEPT accept defaults (n)
a4123f8 @abw 2.04b
authored
69
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
70 By default, the Makefile.PL runs in interactive mode,
a4123f8 @abw 2.04b
authored
71 prompting for confirmation of the various configuration
72 options. Setting the TT_ACCEPT option causes the default
73 value (possibly modified by other command line options)
74 to be accepted. The TT_QUIET option can also be set to
75 suppress the prompt messages.
76
77 EOF
78 exit(0);
79 }
ca4050f @abw prep for 2.02
authored
80
9be7d64 @abw approaching 2.04d
authored
81 # these global package variables are the main flags used
82 # in this script, here defaulted to sensible values
83
a4123f8 @abw 2.04b
authored
84 $TT_VERSION = $Template::VERSION;
9be7d64 @abw approaching 2.04d
authored
85 $TT_XS_ENABLE = 'y';
86 $TT_XS_DEFAULT = 'y';
a4123f8 @abw 2.04b
authored
87 $TT_QUIET = 'n';
88 $TT_ACCEPT = 'n';
f4df3b6 @abw approach v2.03
authored
89
ca4050f @abw prep for 2.02
authored
90 my $DEFAULTS_FILE = '.defaults.cfg';
91 my $DEFAULTS = '';
911a5e3 @abw *** empty log message ***
authored
92
ca4050f @abw prep for 2.02
authored
93 if (-f $DEFAULTS_FILE) {
94 require $DEFAULTS_FILE;
95 $DEFAULTS = " read from '$DEFAULTS_FILE'";
96 }
97
9be7d64 @abw approaching 2.04d
authored
98 $TT_XS_ENABLE = $ttconfig{ TT_XS_ENABLE } if defined $ttconfig{ TT_XS_ENABLE };
99 $TT_XS_DEFAULT = $ttconfig{ TT_XS_DEFAULT } if defined $ttconfig{ TT_XS_DEFAULT };
100 $TT_QUIET = $ttconfig{ TT_QUIET } if defined $ttconfig{ TT_QUIET };
101
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
102 if (defined $ttconfig{ TT_ACCEPT }) {
103 $TT_ACCEPT = $ttconfig{ TT_ACCEPT };
104 }
105 else {
106 # standard behaviour for MakeMaker to indicate accept all defaults
107 $TT_ACCEPT = $ENV{PERL_MM_USE_DEFAULT} ? 'y' : 'n';
108 }
109
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
110 foreach ($TT_XS_ENABLE, $TT_XS_DEFAULT ) {
a4123f8 @abw 2.04b
authored
111 $_ = 'n' if ! $_;
112 }
113 $TT_ACCEPT = 0 if $TT_ACCEPT eq 'n';
114 $TT_QUIET = 0 if $TT_QUIET eq 'n';
115 $TT_QUIET = 0 unless $TT_ACCEPT;
116
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
117 # define version numbers of required modules
d56b9a8 @abw commit for 2.14a
authored
118 my $TT_APPCONFIG_VERSION = '1.56';
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
119 my $TT_FILE_SPEC_VERSION = '0.8';
120 my $TT_FILE_TEMP_VERSION = '0.12';
121
122
a4123f8 @abw 2.04b
authored
123 #========================================================================
124
125 welcome_message();
126 version_check();
28cc36e @abw prep for 2.06d
authored
127 mandatory_modules();
9be7d64 @abw approaching 2.04d
authored
128 optional_stash_xs();
a4123f8 @abw 2.04b
authored
129 write_defaults();
130
131 print "\n";
132
133
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
134 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
135 # build options and write Makefile
136 #------------------------------------------------------------------------
137
138 package main;
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
139
a4123f8 @abw 2.04b
authored
140 my %opts = (
141 %config,
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
142 'NAME' => 'Template',
a4123f8 @abw 2.04b
authored
143 'DISTNAME' => 'Template-Toolkit',
144 'VERSION_FROM' => 'lib/Template.pm',
145 'EXE_FILES' => [ 'bin/tpage', 'bin/ttree' ],
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
146 'PMLIBDIRS' => [ 'lib' ],
9be7d64 @abw approaching 2.04d
authored
147 'DIR' => [ ],
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
148 'PREREQ_PM' => {
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
149 'AppConfig' => $TT_APPCONFIG_VERSION,
150 'File::Spec' => $TT_FILE_SPEC_VERSION,
151 'File::Temp' => $TT_FILE_TEMP_VERSION,
cdc0072 @abw Added Scalar::Util as a pre-requisite in Makefile.PL
authored
152 'Scalar::Util' => 0,
c7d3d41 @abw * removed mandatory modules check from Makefile.PL to keep CPAN module
authored
153 },
a4123f8 @abw 2.04b
authored
154 'dist' => {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
155 'COMPRESS' => 'gzip',
156 'SUFFIX' => 'gz',
a4123f8 @abw 2.04b
authored
157 },
50fc1a2 @abw * changed TESTS to reflect the fact that vmethod tests have moved int…
authored
158 'test' => {
86cfaef @abw Updated Changes, TODO, Makefile.PL, MANIFEST and MANIFEST.SKIP
authored
159 'TESTS' => join(' ', map { glob } qw( t/*.t t/vmethods/*.t )),
50fc1a2 @abw * changed TESTS to reflect the fact that vmethod tests have moved int…
authored
160 },
28cc36e @abw prep for 2.06d
authored
161 'clean' => {
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
162 'FILES' => join(' ', qw( docs/ttree.cfg
163 examples/ttree.cfg
164 t/dbi_test.cfg
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
165 t/test/src/baz.ttc
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
166 t/test/src/complex.org
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
167 t/test/src/complex.ttc
168 t/test/src/evalperl.ttc
169 t/test/src/foo.ttc )),
28cc36e @abw prep for 2.06d
authored
170 },
a4123f8 @abw 2.04b
authored
171 );
172
9be7d64 @abw approaching 2.04d
authored
173 push @{ $opts{'DIR'} }, 'xs' if $TT_XS_ENABLE;
174
7cd902d @abw applied Adam Kennedy's patches from v2.16 and v2.17
authored
175 # Handle dev versions in our check
176 my $mmv = $ExtUtils::MakeMaker::VERSION;
177 $mmv =~ s/\_.+//;
178
179 if ($mmv >= 5.43) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
180 $opts{ AUTHOR } = 'Andy Wardley <abw@wardley.org>';
181 $opts{ ABSTRACT } = 'comprehensive template processing system',
a4123f8 @abw 2.04b
authored
182 }
183
86cfaef @abw Updated Changes, TODO, Makefile.PL, MANIFEST and MANIFEST.SKIP
authored
184 if ($ExtUtils::MakeMaker::VERSION ge '6.30_00') {
185 $opts{'LICENSE' } = 'perl';
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
186 }
a4123f8 @abw 2.04b
authored
187
188 WriteMakefile( %opts );
189
190 print <<EOF;
191
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
192 Configuration complete. You should now run '$MAKE', '$MAKE test' and
a4123f8 @abw 2.04b
authored
193 then '$MAKE install'. See the README file for further information.
194 EOF
195
196
197 #========================================================================
198
199
200
201 #------------------------------------------------------------------------
202 # welcome_message()
203 #
204 # Print opening banner.
205 #------------------------------------------------------------------------
206
207 sub welcome_message {
208 print(<<EOF);
209
210 Template Toolkit Version $TT_VERSION
c542301 @abw *** empty log message ***
authored
211 =============================
911a5e3 @abw *** empty log message ***
authored
212
ca4050f @abw prep for 2.02
authored
213 Using $FLAVOUR defaults$DEFAULTS.
9be7d64 @abw approaching 2.04d
authored
214 Run 'perl Makefile.PL TT_HELP' for a summary of options.
48634a1 @abw *** empty log message ***
authored
215 EOF
a4123f8 @abw 2.04b
authored
216 print "Messages suppressed (TT_QUIET). " if $TT_QUIET;
217 print "Accepting defaults automatically (TT_ACCEPT)." if $TT_ACCEPT;
218 }
219
220
48634a1 @abw *** empty log message ***
authored
221
222 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
223 # version_check()
224 #
225 # Check for pre-version 2.00 installation and issue warning
48634a1 @abw *** empty log message ***
authored
226 #------------------------------------------------------------------------
227
a4123f8 @abw 2.04b
authored
228 sub version_check {
229 eval "use Template";
230 unless ($@ or $Template::VERSION =~ /^2/) {
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
231 warn(<<EOF) unless $TT_QUIET;
48634a1 @abw *** empty log message ***
authored
232
c542301 @abw *** empty log message ***
authored
233 IMPORTANT NOTE:
a4123f8 @abw 2.04b
authored
234
48634a1 @abw *** empty log message ***
authored
235 You have version $Template::VERSION of the Template Toolkit installed.
25a8d8e @abw *** empty log message ***
authored
236
82cbea8 @abw version 2.00
authored
237 There are some minor incompatabilities between version 1 and 2
48634a1 @abw *** empty log message ***
authored
238 of the Template Toolkit which you should be aware of. Installing
239 this version will overwrite your version $Template::VERSION files
240 unless you take measures to install one or the other version in a
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
241 different location (i.e. perl Makefile.PL PREFIX=/other/path).
48634a1 @abw *** empty log message ***
authored
242
243 Please consult the README and Changes file for further details.
244 Most of the changes are in the more obscure features and
245 directives so hopefully you will find the upgrade process fairly
9be7d64 @abw approaching 2.04d
authored
246 painless. If you're feeling brave, then answer 'y', otherwise 'n'.
25a8d8e @abw *** empty log message ***
authored
247
248 EOF
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
249 exit unless ttprompt("Do you want to continue?", 'y') =~ /y/i;
a4123f8 @abw 2.04b
authored
250 }
48634a1 @abw *** empty log message ***
authored
251 }
252
a4123f8 @abw 2.04b
authored
253
48634a1 @abw *** empty log message ***
authored
254 #------------------------------------------------------------------------
a4123f8 @abw 2.04b
authored
255 # mandatory_modules()
256 #
257 # Detect mandatory module
c8d76d4 @abw *** empty log message ***
authored
258 #------------------------------------------------------------------------
259
a4123f8 @abw 2.04b
authored
260 sub mandatory_modules {
261 eval "use AppConfig";
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
262 if ($@ or $AppConfig::VERSION < $TT_APPCONFIG_VERSION) {
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
263 warn(<<EOF);
c8d76d4 @abw *** empty log message ***
authored
264
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
265 The Template Toolkit requires that the AppConfig module (version $TT_APPCONFIG_VERSION
266 or later) first be installed. This is used by
267 the 'ttree' program for reading command line options and configuration
268 files. It is available from CPAN:
c8d76d4 @abw *** empty log message ***
authored
269
270 http://www.cpan.org/authors/Andy_Wardley/
271
272 EOF
a4123f8 @abw 2.04b
authored
273 }
c8d76d4 @abw *** empty log message ***
authored
274
a4123f8 @abw 2.04b
authored
275 eval "use File::Spec";
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
276 if ($@ or $File::Spec::VERSION < $TT_FILE_SPEC_VERSION) {
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
277 warn(<<EOF);
911a5e3 @abw *** empty log message ***
authored
278
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
279 The Template Toolkit requires that the File::Spec module (version $TT_FILE_SPEC_VERSION
911a5e3 @abw *** empty log message ***
authored
280 or later) first be installed. This is used by the File plugin. It is
281 available from CPAN:
282
283 http://search.cpan.org/search?dist=File-Spec
284
285 EOF
a4123f8 @abw 2.04b
authored
286 }
911a5e3 @abw *** empty log message ***
authored
287
5d8ad91 @abw * applied patch from Axel Gerstmair to fix File::Spec and File::Temp
authored
288 eval "use File::Temp";
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
289 if ($@ or $File::Temp::VERSION < $TT_FILE_TEMP_VERSION) {
5d8ad91 @abw * applied patch from Axel Gerstmair to fix File::Spec and File::Temp
authored
290 warn(<<EOF);
291
8d30d52 @abw * applied patch from Axel to use variables for dependent module versi…
authored
292 The Template Toolkit requires that the File::Temp module (version $TT_FILE_TEMP_VERSION
5d8ad91 @abw * applied patch from Axel Gerstmair to fix File::Spec and File::Temp
authored
293 or later) first be installed. This is used by the Template::Document
294 class for storing compiled templates. It is available from CPAN:
295
296 http://search.cpan.org/search?dist=File-Temp
297
298 EOF
299 }
300 }
911a5e3 @abw *** empty log message ***
authored
301
a4123f8 @abw 2.04b
authored
302
c8d76d4 @abw *** empty log message ***
authored
303 #------------------------------------------------------------------------
9be7d64 @abw approaching 2.04d
authored
304 # optional_stash_xs()
305 #
306 # Prompt for installation and default use of XS Stash.
307 #------------------------------------------------------------------------
308
309 sub optional_stash_xs {
310 # return if $TT_ACCEPT && (! $TT_XS_ENABLE || $TT_XS_ENABLE eq 'n');
311
312 message(<<EOF);
313
314
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
315 Template::Stash::XS
316 -------------------
317
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
318 The Template::Stash module is a core part of the Template Toolkit,
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
319 implementing the magic for accessing data using the dot notation.
9be7d64 @abw approaching 2.04d
authored
320
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
321 There is a high speed version, Template::Stash::XS, written in C.
322 This makes the Template Toolkit run about twice as fast as when using
323 the regular Template::Stash written in Perl. If you've got a C
324 compiler on your system then you can elect to have the XS Stash built.
325 You can also specify that you want to use the XS Stash by default.
9be7d64 @abw approaching 2.04d
authored
326
d56b9a8 @abw commit for 2.14a
authored
327 Note that as of version 2.15 the XS Stash now supports access to tied
328 hashes and arrays.
f897871 @abw * added code to detect $ENV{PERL_MM_USE_DEFAULT}
authored
329
330 See 'perldoc Template::Config' for further details.
9be7d64 @abw approaching 2.04d
authored
331
332 EOF
333
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
334 $TT_XS_ENABLE = (ttprompt('Do you want to build the XS Stash module?',
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
335 $TT_XS_ENABLE) =~ /^y/i);
9be7d64 @abw approaching 2.04d
authored
336
337 if ($TT_XS_ENABLE) {
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
338 $TT_XS_DEFAULT =
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
339 (ttprompt('Do you want to use the XS Stash by default?',
340 $TT_XS_DEFAULT) =~ /^y/i);
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
341 }
342 else {
343 # If the XS stash is disabled, we cannot use it as the default stash.
344 $TT_XS_DEFAULT = 0;
345 }
9be7d64 @abw approaching 2.04d
authored
346
193ba4e @abw * applied another patch from Axel to fix Makefile.PL
authored
347 # Actually, we would have to fix 'Config.pm' only if the XS stash is
348 # disabled. But this way, we are sure the correct module is used.
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
349 fix_file(catfile('lib','Template','Config.pm'),
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
350 '$STASH',
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
351 $TT_XS_DEFAULT ? 'Template::Stash::XS' : 'Template::Stash');
c8d76d4 @abw *** empty log message ***
authored
352 }
353
354
355
a4123f8 @abw 2.04b
authored
356
357
358 #--------------------------------------------------------------------
359 # write_defaults()
360 #
361 # write configuration defaults to file
362 #--------------------------------------------------------------------
363
364 sub write_defaults {
ca4050f @abw prep for 2.02
authored
365 open(FP, "> $DEFAULTS_FILE") || die "$DEFAULTS_FILE: $!\n";
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
366 my ( $ttxs_enable, $ttxs_default )
367 = map { $_ ? 'y' : 'n' }
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
368 ( $TT_XS_ENABLE, $TT_XS_DEFAULT );
ca4050f @abw prep for 2.02
authored
369 print FP <<EOF;
9be7d64 @abw approaching 2.04d
authored
370 \$TT_XS_ENABLE = '$ttxs_enable';
371 \$TT_XS_DEFAULT = '$ttxs_default';
a4123f8 @abw 2.04b
authored
372 \$TT_ACCEPT = '$TT_ACCEPT';
373 \$TT_QUIET = '$TT_QUIET';
9acc796 @abw post 2.03a
authored
374 1;
ca4050f @abw prep for 2.02
authored
375 EOF
376 close(FP);
c8d76d4 @abw *** empty log message ***
authored
377 }
378
48634a1 @abw *** empty log message ***
authored
379
380
82cbea8 @abw version 2.00
authored
381
382 #------------------------------------------------------------------------
c8d76d4 @abw *** empty log message ***
authored
383 # fix_file($file, $find, $fix)
384 #
3b0b197 @abw Zapped trailing whitespace (thanks Sublime Text)
authored
385 # Fixes a variable definition in a file. e.g.
d941238 @abw prep 2.4d
authored
386 # fix_file('templates/splash/config', 'images', '/tt2/splash')
c8d76d4 @abw *** empty log message ***
authored
387 #------------------------------------------------------------------------
388
389 sub fix_file {
390 my ($file, $find, $fix) = @_;
391 local *FP;
392 local $/ = undef;
393
394 $find = quotemeta($find);
395
396 open(FP, "< $file") || die "$file: $!\n";
397 my $text = <FP>;
398 close(FP);
399
400 ($text =~ s/^(\s*${find}\s*=\s*)'.*?'/$1'$fix'/m)
3dd76fc @abw Cleaned out some of the old installation cruft from Makefile.PL
authored
401 || die "$find not found in $file\n";
c8d76d4 @abw *** empty log message ***
authored
402
403 open(FP, "> $file") || die "$file: $!\n";
404 print FP $text;
405 close(FP);
406 }
407
a4123f8 @abw 2.04b
authored
408
409 #------------------------------------------------------------------------
9be7d64 @abw approaching 2.04d
authored
410 # find_program($path, $prog)
f4df3b6 @abw approach v2.03
authored
411 #
412 # Find a program, $prog, by traversing the given directory path, $path.
413 # Returns full path if the program is found.
414 #
415 # Written by Craig Barratt, Richard Tietjen add fixes for Win32.
9be7d64 @abw approaching 2.04d
authored
416 #
417 # abw changed name from studly caps findProgram() to find_program() :-)
a4123f8 @abw 2.04b
authored
418 #------------------------------------------------------------------------
419
9be7d64 @abw approaching 2.04d
authored
420 sub find_program {
f4df3b6 @abw approach v2.03
authored
421 my($path, $prog) = @_;
714a8cd @abw * prep for release 2.07a
authored
422 # my $sep = $WIN32 ? qr/;/ : qr/:/;
423 # foreach my $dir ( split($sep, $path) ) {
424 foreach my $dir ( split($Config{path_sep}, $path) ) {
f4df3b6 @abw approach v2.03
authored
425 my $file = File::Spec->catfile($dir, $prog);
426 if ( !$WIN32 ) {
427 return $file if ( -x $file );
428 } else {
429 # Windows executables end in .xxx, exe precedes .bat and .cmd
430 foreach my $dx ( qw/exe bat cmd/ ) {
431 return "$file.$dx" if ( -x "$file.$dx" );
432 }
433 }
434 }
435 }
a4123f8 @abw 2.04b
authored
436
437
438 #------------------------------------------------------------------------
439 # message($text)
440 #
441 # Print message unless quiet mode.
442 #------------------------------------------------------------------------
443
444 sub message {
445 return if $TT_QUIET;
446 print @_;
447 }
448
449
450 #------------------------------------------------------------------------
451 # ttprompt($message, $default)
452 #------------------------------------------------------------------------
453
454 sub ttprompt {
455 my ($msg, $def)=@_;
456 my $ISA_TTY = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe?
457 my $dispdef = defined $def ? "[$def] " : " ";
458 $def = defined $def ? $def : "";
459 my $ans = '';
460 local $|=1;
461 print "$msg $dispdef" unless $TT_QUIET;
462 if ($TT_ACCEPT || ! $ISA_TTY) {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
463 print "$def\n" unless $TT_QUIET;
a4123f8 @abw 2.04b
authored
464 }
465 else {
80509c2 @abw * bumped pre-requisite for AppConfig to 1.55
authored
466 chomp($ans = <STDIN>);
a4123f8 @abw 2.04b
authored
467 }
468 return ($ans ne '') ? $ans : $def;
469 }
470
471
472 #------------------------------------------------------------------------
473 # yep($text)
474 #------------------------------------------------------------------------
475
476 sub yep {
477 return if $TT_QUIET;
478 print '[X] ', shift, "\n";
479 }
480
481
482 #------------------------------------------------------------------------
483 # nope($text)
484 #------------------------------------------------------------------------
485 sub nope {
486 return if $TT_QUIET;
487 print '[ ] ', shift, "\n";
488 }
Something went wrong with that request. Please try again.