Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 1164 lines (897 sloc) 33.124 kb
a4123f87 »
2001-08-04 2.04b
1 #!/usr/bin/perl -w # -*- perl -*-
2
3 use strict;
4
5 use lib qw( ./lib );
6 use Template;
7 use ExtUtils::MakeMaker;
c8d76d48 »
2001-03-29 *** empty log message ***
8 use Cwd;
3ebfa076 »
2000-06-25 Initial revision
9
e39913fd »
2000-07-10 *** empty log message ***
10 select STDERR;
11 $| = 1;
12 select STDOUT;
13
a4123f87 »
2001-08-04 2.04b
14 use vars qw( $TT_VERSION $TT_PREFIX $TT_IMAGES $TT_RUN_DBI
ca4050f2 »
2001-04-06 prep for 2.02
15 $TT_BUILD_DOCS $TT_SPLASH_DOCS $TT_EXAMPLES
a4123f87 »
2001-08-04 2.04b
16 $TT_LATEX_ENABLE $TT_LATEX_PATH $TT_PDFLATEX_PATH $TT_DVIPS_PATH
9be7d64a »
2001-08-21 approaching 2.04d
17 $TT_XS_ENABLE $TT_XS_DEFAULT
a4123f87 »
2001-08-04 2.04b
18 $TT_SPLASH_THEME $TT_QUIET $TT_ACCEPT $TT_YES );
19
20 # check O/S to set sensible defaults
9be7d64a »
2001-08-21 approaching 2.04d
21
22 my ($WIN32, $FLAVOUR, $PREFIX, $IMAGES, $MAKE);
dd62af13 »
2001-08-21 * Applied Chris' patch to fix win => MSWin32
23 if ($^O eq 'MSWin32') { # any others also?
a4123f87 »
2001-08-04 2.04b
24 $WIN32 = 1;
25 $FLAVOUR = 'Win32';
26 $PREFIX = 'C:/Program Files/Template Toolkit 2';
9be7d64a »
2001-08-21 approaching 2.04d
27 $IMAGES = '/tt2/images';
a4123f87 »
2001-08-04 2.04b
28 $MAKE = 'nmake';
29 }
30 else {
31 $WIN32 = 0;
32 $FLAVOUR = 'Unix';
33 $PREFIX = '/usr/local/tt2';
9be7d64a »
2001-08-21 approaching 2.04d
34 $IMAGES = '/tt2/images';
a4123f87 »
2001-08-04 2.04b
35 $MAKE = 'make';
36 }
37
9be7d64a »
2001-08-21 approaching 2.04d
38
39 # read command line args putting TT_* into $ttconfig and
40 # everything else (regular Makefile.PL args, e.g. PREFIX)
41 # goes into $config
42
a4123f87 »
2001-08-04 2.04b
43 my (%config, %ttconfig);
44 while ($_ = shift) {
45 my ($k, $v) = split(/=/);
46 if ($k =~ /^TT/) {
47 $ttconfig{ $k } = $v || 0;
48 }
49 else {
50 $config{ $k } = $v || 0;
51 }
52 };
53
9be7d64a »
2001-08-21 approaching 2.04d
54
55 # print help if they asked for it
56
a4123f87 »
2001-08-04 2.04b
57 if (exists $ttconfig{ TT_HELP }) {
58 print <<EOF;
59 The following options can be specified as command line
60 arguments to 'perl Makefile.PL'. e.g.
61
9be7d64a »
2001-08-21 approaching 2.04d
62 perl Makefile.PL TT_PREFIX=/my/tt2/dir TT_ACCEPT=y
63
64 TT_PREFIX installation prefix ($PREFIX)
65 TT_IMAGES images URL (/tt2/images)
66 TT_DOCS build HTML docs (y)
67 TT_SPLASH use Splash! for docs (y)
68 TT_THEME Splash! theme (default)
69 TT_EXAMPLES build HTML examples (y)
70 TT_XS_ENABLE Enable XS Stash (y)
71 TT_XS_DEFAULT Use XS Stash by default (y)
72 TT_DBI run DBI tests (y if DBI installed)
73
74 TT_LATEX install LaTeX filter (y if LaTeX found)
75 TT_LATEX_PATH path to latex (system dependant)
76 TT_PDFLATEX_PATH path to pdflatex ( " " " )
77 TT_DVIPS_PATH path to dvips ( " " " )
a4123f87 »
2001-08-04 2.04b
78
9be7d64a »
2001-08-21 approaching 2.04d
79 TT_QUIET no messages (n)
80 TT_ACCEPT accept defaults (n)
a4123f87 »
2001-08-04 2.04b
81
82 By default, the Makefile.PL runs in interactive mode,
83 prompting for confirmation of the various configuration
84 options. Setting the TT_ACCEPT option causes the default
85 value (possibly modified by other command line options)
86 to be accepted. The TT_QUIET option can also be set to
87 suppress the prompt messages.
88
89 EOF
90 exit(0);
91 }
ca4050f2 »
2001-04-06 prep for 2.02
92
9be7d64a »
2001-08-21 approaching 2.04d
93 # these global package variables are the main flags used
94 # in this script, here defaulted to sensible values
95
a4123f87 »
2001-08-04 2.04b
96 $TT_VERSION = $Template::VERSION;
97 $TT_PREFIX = $PREFIX;
9be7d64a »
2001-08-21 approaching 2.04d
98 $TT_IMAGES = $IMAGES;
f4df3b6f »
2001-06-14 approach v2.03
99 $TT_RUN_DBI = 'y';
100 $TT_BUILD_DOCS = 'y';
101 $TT_SPLASH_DOCS = 'y';
102 $TT_EXAMPLES = 'y';
103 $TT_SPLASH_THEME = 'default';
9be7d64a »
2001-08-21 approaching 2.04d
104 $TT_XS_ENABLE = 'y';
105 $TT_XS_DEFAULT = 'y';
a4123f87 »
2001-08-04 2.04b
106 $TT_LATEX_ENABLE = 'y';
9be7d64a »
2001-08-21 approaching 2.04d
107 $TT_LATEX_PATH = '';
108 $TT_PDFLATEX_PATH = '';
109 $TT_DVIPS_PATH = '';
a4123f87 »
2001-08-04 2.04b
110 $TT_QUIET = 'n';
111 $TT_ACCEPT = 'n';
f4df3b6f »
2001-06-14 approach v2.03
112
46e4eb84 »
2001-08-21 * Added new colour theme called 'leon'
113 my $TT_SPLASH_FG = '';
114 my $TT_SPLASH_BG = '';
115 my $TT_SPLASH_FT = '';
116 my $TT_SPLASH_BT = '';
ca4050f2 »
2001-04-06 prep for 2.02
117
118 my $DEFAULTS_FILE = '.defaults.cfg';
48634a1f »
2000-10-09 *** empty log message ***
119 my $DBI_CONFIG_FILE = 't/dbi_test.cfg';
c8d76d48 »
2001-03-29 *** empty log message ***
120 my $TT_DOCS_CFG = 'docs/ttree.cfg';
121 my $TT_EXAMPLE_CFG = 'examples/ttree.cfg';
ca4050f2 »
2001-04-06 prep for 2.02
122 my $DEFAULTS = '';
911a5e37 »
2001-04-04 *** empty log message ***
123
ca4050f2 »
2001-04-06 prep for 2.02
124 if (-f $DEFAULTS_FILE) {
125 require $DEFAULTS_FILE;
126 $DEFAULTS = " read from '$DEFAULTS_FILE'";
127 }
128
9be7d64a »
2001-08-21 approaching 2.04d
129 $TT_PREFIX = $ttconfig{ TT_PREFIX } if $ttconfig{ TT_PREFIX };
130 $TT_IMAGES = $ttconfig{ TT_IMAGES } if $ttconfig{ TT_IMAGES };
131 $TT_SPLASH_THEME = $ttconfig{ TT_THEME } if $ttconfig{ TT_THEME };
132 $TT_LATEX_PATH = $ttconfig{ TT_LATEX_PATH } if $ttconfig{ TT_LATEX_PATH };
133 $TT_PDFLATEX_PATH = $ttconfig{ TT_PDFLATEX_PATH } if $ttconfig{ TT_PDFLATEX_PATH };
134 $TT_DVIPS_PATH = $ttconfig{ TT_DVIPS_PATH } if $ttconfig{ TT_DVIPS_PATH };
135 $TT_RUN_DBI = $ttconfig{ TT_DBI } if defined $ttconfig{ TT_DBI };
136 $TT_BUILD_DOCS = $ttconfig{ TT_DOCS } if defined $ttconfig{ TT_DOCS };
137 $TT_SPLASH_DOCS = $ttconfig{ TT_SPLASH } if defined $ttconfig{ TT_SPLASH };
138 $TT_EXAMPLES = $ttconfig{ TT_EXAMPLES } if defined $ttconfig{ TT_EXAMPLES };
139 $TT_LATEX_ENABLE = $ttconfig{ TT_LATEX } if defined $ttconfig{ TT_LATEX };
140 $TT_XS_ENABLE = $ttconfig{ TT_XS_ENABLE } if defined $ttconfig{ TT_XS_ENABLE };
141 $TT_XS_DEFAULT = $ttconfig{ TT_XS_DEFAULT } if defined $ttconfig{ TT_XS_DEFAULT };
142 $TT_QUIET = $ttconfig{ TT_QUIET } if defined $ttconfig{ TT_QUIET };
143 $TT_ACCEPT = $ttconfig{ TT_ACCEPT } if defined $ttconfig{ TT_ACCEPT };
144
145 foreach ($TT_RUN_DBI, $TT_BUILD_DOCS, $TT_SPLASH_DOCS, $TT_EXAMPLES,
146 $TT_LATEX_ENABLE, $TT_XS_ENABLE, $TT_XS_DEFAULT ) {
a4123f87 »
2001-08-04 2.04b
147 $_ = 'n' if ! $_;
148 }
149 $TT_ACCEPT = 0 if $TT_ACCEPT eq 'n';
150 $TT_QUIET = 0 if $TT_QUIET eq 'n';
151 $TT_QUIET = 0 unless $TT_ACCEPT;
152
ca4050f2 »
2001-04-06 prep for 2.02
153 my $SPLASH_STYLES = {
154 default => [ 'lilac', 'mauve' ],
155 aqua => [ 'aqua', 'marine' ],
156 grey => [ 'grey75', 'grey50' ],
157 blue => [ 'grey75', 'blue75' ],
158 red => [ 'grey75', 'red75' ],
159 green => [ 'grey75', 'green75' ],
46e4eb84 »
2001-08-21 * Added new colour theme called 'leon'
160 leon => [ 'red75', 'orange', 'white', 'black' ],
ca4050f2 »
2001-04-06 prep for 2.02
161 };
162
c5423016 »
2000-10-25 *** empty log message ***
163
a4123f87 »
2001-08-04 2.04b
164 #========================================================================
165
166 welcome_message();
167 version_check();
168 mandatory_modules();
169 optional_modules();
9be7d64a »
2001-08-21 approaching 2.04d
170 optional_stash_xs();
a4123f87 »
2001-08-04 2.04b
171 optional_latex();
172 optional_extras();
173 splash_images();
174 html_docs();
175 html_docstyle();
176 html_examples();
177 write_defaults();
178
179 print "\n";
180
181
182 #------------------------------------------------------------------------
183 # build options and write Makefile
184 #------------------------------------------------------------------------
185
186 package MY;
187
188 sub postamble {
189 return '' unless $main::TT_PREFIX;
190 my $amble =<<'EOF';
191 tt2_install ::
192 @$(PERL) bin/tt2inst -v "$(TT_PREFIX)"
193
194 tt2_splash ::
195 @$(PERL) -I lib bin/gifsplash -v
196
197 EOF
198 $amble .=<<EOF if $main::TT_BUILD_DOCS;
199 tt2_html_docs ::
200 \@\$(PERL) bin/ttree -v -f "\$(TT_PREFIX)/$TT_DOCS_CFG"
201
202 EOF
203 $amble .=<<EOF if $main::TT_EXAMPLES;
204 tt2_examples ::
205 \@\$(PERL) bin/ttree -v -f "\$(TT_PREFIX)/$TT_EXAMPLE_CFG"
206
207 EOF
208 return $amble;
209 }
210
211 sub install {
212 my $class = shift;
213 my $basic = $class->SUPER::install(@_);
214 my $add = 'tt2_install tt2_splash';
215 $add .= ' tt2_html_docs' if $main::TT_BUILD_DOCS;
216 $add .= ' tt2_examples' if $main::TT_EXAMPLES;
217 $basic =~ s/^(install\s+::\s+.*)$/$1 $add/m
218 if $main::TT_PREFIX;
219 $basic;
220 }
221
222 sub constants {
223 my $class = shift;
224 my $basic = $class->SUPER::constants(@_);
225 $basic = "TT_PREFIX = $main::TT_PREFIX\n$basic"
226 if $main::TT_PREFIX;
227 $basic;
228 }
229
230 package main;
231
232 my %opts = (
233 %config,
234 'NAME' => 'Template',
235 'DISTNAME' => 'Template-Toolkit',
236 'VERSION_FROM' => 'lib/Template.pm',
237 'EXE_FILES' => [ 'bin/tpage', 'bin/ttree' ],
238 'PMLIBDIRS' => [ 'lib' ],
9be7d64a »
2001-08-21 approaching 2.04d
239 'DIR' => [ ],
a4123f87 »
2001-08-04 2.04b
240 'PREREQ_PM' => { 'AppConfig' => 1.52 },
241 'dist' => {
242 'COMPRESS' => 'gzip',
243 'SUFFIX' => 'gz',
244 },
245 );
246
9be7d64a »
2001-08-21 approaching 2.04d
247 push @{ $opts{'DIR'} }, 'xs' if $TT_XS_ENABLE;
248
a4123f87 »
2001-08-04 2.04b
249 if ($ExtUtils::MakeMaker::VERSION >= 5.43) {
250 $opts{ AUTHOR } = 'Andy Wardley <abw@kfs.org>';
251 $opts{ ABSTRACT } =
252 'a fast, flexible and extensible template processing system',
253 }
254
255
256 WriteMakefile( %opts );
257
258 if ($WIN32) {
259 print <<EOF;
260
261 Configuration complete. You should now run '$MAKE', '$MAKE test' and
262 then '$MAKE install'. See the README file for further information.
263 EOF
264 }
265
266 message(<<EOF) if $TT_BUILD_DOCS;
267
9be7d64a »
2001-08-21 approaching 2.04d
268
269 Installation Notes
270 ------------------
271
a4123f87 »
2001-08-04 2.04b
272 Please note that the installation of the optional components and
273 building of the HTML documentation is performed at the "make install"
274 stage as the effective user at that time. This implies that this user
275 must have sufficient permission to install into the specified
276 directory and that all created directories and files will be owned by
277 them.
278
279 EOF
280
281 #========================================================================
282
283
284
285 #------------------------------------------------------------------------
286 # welcome_message()
287 #
288 # Print opening banner.
289 #------------------------------------------------------------------------
290
291 sub welcome_message {
292 print(<<EOF);
293
294 Template Toolkit Version $TT_VERSION
c5423016 »
2000-10-25 *** empty log message ***
295 =============================
911a5e37 »
2001-04-04 *** empty log message ***
296
ca4050f2 »
2001-04-06 prep for 2.02
297 Using $FLAVOUR defaults$DEFAULTS.
9be7d64a »
2001-08-21 approaching 2.04d
298
299 Run 'perl Makefile.PL TT_HELP' for a summary of options.
48634a1f »
2000-10-09 *** empty log message ***
300 EOF
a4123f87 »
2001-08-04 2.04b
301 print "Messages suppressed (TT_QUIET). " if $TT_QUIET;
302 print "Accepting defaults automatically (TT_ACCEPT)." if $TT_ACCEPT;
303 }
304
305
48634a1f »
2000-10-09 *** empty log message ***
306
307 #------------------------------------------------------------------------
a4123f87 »
2001-08-04 2.04b
308 # version_check()
309 #
310 # Check for pre-version 2.00 installation and issue warning
48634a1f »
2000-10-09 *** empty log message ***
311 #------------------------------------------------------------------------
312
a4123f87 »
2001-08-04 2.04b
313 sub version_check {
314 eval "use Template";
315 unless ($@ or $Template::VERSION =~ /^2/) {
316 warn(<<EOF) unless $TT_QUIET;
48634a1f »
2000-10-09 *** empty log message ***
317
c5423016 »
2000-10-25 *** empty log message ***
318 IMPORTANT NOTE:
a4123f87 »
2001-08-04 2.04b
319
48634a1f »
2000-10-09 *** empty log message ***
320 You have version $Template::VERSION of the Template Toolkit installed.
25a8d8ef »
2000-08-10 *** empty log message ***
321
82cbea87 »
2000-11-01 version 2.00
322 There are some minor incompatabilities between version 1 and 2
48634a1f »
2000-10-09 *** empty log message ***
323 of the Template Toolkit which you should be aware of. Installing
324 this version will overwrite your version $Template::VERSION files
325 unless you take measures to install one or the other version in a
82cbea87 »
2000-11-01 version 2.00
326 different location (i.e. perl Makefile.PL PREFIX=/other/path).
48634a1f »
2000-10-09 *** empty log message ***
327
328 Please consult the README and Changes file for further details.
329 Most of the changes are in the more obscure features and
330 directives so hopefully you will find the upgrade process fairly
9be7d64a »
2001-08-21 approaching 2.04d
331 painless. If you're feeling brave, then answer 'y', otherwise 'n'.
25a8d8ef »
2000-08-10 *** empty log message ***
332
333 EOF
a4123f87 »
2001-08-04 2.04b
334 exit unless ttprompt("Do you want to continue?", 'y') =~ /y/i;
335 }
48634a1f »
2000-10-09 *** empty log message ***
336 }
337
a4123f87 »
2001-08-04 2.04b
338
48634a1f »
2000-10-09 *** empty log message ***
339 #------------------------------------------------------------------------
a4123f87 »
2001-08-04 2.04b
340 # mandatory_modules()
341 #
342 # Detect mandatory module
c8d76d48 »
2001-03-29 *** empty log message ***
343 #------------------------------------------------------------------------
344
a4123f87 »
2001-08-04 2.04b
345 sub mandatory_modules {
346 eval "use AppConfig";
347 if ($@ or $AppConfig::VERSION < 1.52) {
348 die(<<EOF);
c8d76d48 »
2001-03-29 *** empty log message ***
349
350 The Template Toolkit requires that the AppConfig module (version 1.52
351 or later) first be installed. This is used by the 'ttree' program for
352 reading command line options and configuration files. It is available
353 from CPAN:
354
355 http://www.cpan.org/authors/Andy_Wardley/
356
357 EOF
a4123f87 »
2001-08-04 2.04b
358 }
c8d76d48 »
2001-03-29 *** empty log message ***
359
a4123f87 »
2001-08-04 2.04b
360 eval "use File::Spec";
361 if ($@ or $File::Spec::VERSION < 0.6) {
362 die(<<EOF);
911a5e37 »
2001-04-04 *** empty log message ***
363
f4df3b6f »
2001-06-14 approach v2.03
364 The Template Toolkit requires that the File::Spec module (version 0.6
911a5e37 »
2001-04-04 *** empty log message ***
365 or later) first be installed. This is used by the File plugin. It is
366 available from CPAN:
367
368 http://search.cpan.org/search?dist=File-Spec
369
370 EOF
a4123f87 »
2001-08-04 2.04b
371 }
911a5e37 »
2001-04-04 *** empty log message ***
372 }
373
374
a4123f87 »
2001-08-04 2.04b
375
c8d76d48 »
2001-03-29 *** empty log message ***
376 #------------------------------------------------------------------------
a4123f87 »
2001-08-04 2.04b
377 # optional_modules()
378 #
379 # Detect additional modules required by plugins (just for fun)
48634a1f »
2000-10-09 *** empty log message ***
380 #------------------------------------------------------------------------
25a8d8ef »
2000-08-10 *** empty log message ***
381
a4123f87 »
2001-08-04 2.04b
382 sub optional_modules {
383 message(<<EOF);
48634a1f »
2000-10-09 *** empty log message ***
384
9be7d64a »
2001-08-21 approaching 2.04d
385 External Modules
386 ----------------
387
82cbea87 »
2000-11-01 version 2.00
388 The Template Toolkit includes a number of plugin modules, some of
389 which interface to external Perl modules available from CPAN. All the
390 plugins will be installed regardless so that they will automatically
391 work as and when you install the relevant modules. The tests will be
392 skipped for plugins that require external modules not currently
393 available on your system.
e39913fd »
2000-07-10 *** empty log message ***
394
395 EOF
48634a1f »
2000-10-09 *** empty log message ***
396
a4123f87 »
2001-08-04 2.04b
397 foreach my $mods ( [ 'Text::Autoformat' => \&check_taf ],
398 [ 'GD' => undef ],
399 [ 'GD::Text' => undef ],
400 [ 'GD::Graph' => undef ],
401 [ 'GD::Graph3d' => undef ],
402 [ 'Date::Calc' => undef ],
87039406 »
2001-08-21 prep 2.05
403 [ 'Pod::POM' => undef ],
a4123f87 »
2001-08-04 2.04b
404 [ 'XML::DOM' => \&check_dom ],
405 [ 'XML::RSS' => \&check_rss ],
406 [ 'XML::XPath' => \&check_xpath ],
407 [ 'DBI' => \&dbi_config ] ) {
408 my ($module, $code) = ref $mods ? @$mods : ($mods, 0);
409
410 printf(" %-16s ", $module) unless $TT_QUIET;
411 eval "use $module";
412 if ($@) {
413 nope("module not installed");
414 }
415 elsif ($code) {
416 &$code;
417 }
418 else {
419 no strict qw( refs );
420 my $ver = ${"$module\::VERSION"};
421 yep("version $ver installed");
422 }
82cbea87 »
2000-11-01 version 2.00
423 }
e39913fd »
2000-07-10 *** empty log message ***
424 }
425
a4123f87 »
2001-08-04 2.04b
426
9be7d64a »
2001-08-21 approaching 2.04d
427 #------------------------------------------------------------------------
428 # optional_stash_xs()
429 #
430 # Prompt for installation and default use of XS Stash.
431 #------------------------------------------------------------------------
432
433 sub optional_stash_xs {
434 # return if $TT_ACCEPT && (! $TT_XS_ENABLE || $TT_XS_ENABLE eq 'n');
435
436 message(<<EOF);
437
438
439 XS Stash: TT2 now twice as fast!
440 --------------------------------
441
dd62af13 »
2001-08-21 * Applied Chris' patch to fix win => MSWin32
442 We have a new high speed version of the Template::Stash. It's
9be7d64a »
2001-08-21 approaching 2.04d
443 a Perl XS module which can evaluate templates about twice as fast as
dd62af13 »
2001-08-21 * Applied Chris' patch to fix win => MSWin32
444 the pure-Perl version. It is still officially "experimental" but
445 is thought to be generally stable and reliable.
9be7d64a »
2001-08-21 approaching 2.04d
446
46e4eb84 »
2001-08-21 * Added new colour theme called 'leon'
447 You can choose to build the XS stash module and enable it by default
448 so that it is used automatically for all templates. If you build it
449 but don't enable it by default then you can use it something like
450 this:
9be7d64a »
2001-08-21 approaching 2.04d
451
452 use Template;
453 use Template::Stash::XS;
454
455 my \$tt = new Template ({ STASH => new Template::Stash::XS, ... });
456
46e4eb84 »
2001-08-21 * Added new colour theme called 'leon'
457 You can also enable the XS stash by setting the \$STASH package
458 variable in the Template/Config.pm module. See 'perldoc
459 Template::Config' for further details.
9be7d64a »
2001-08-21 approaching 2.04d
460
461 EOF
462
463 $TT_XS_ENABLE = (ttprompt('Do you want to build the XS Stash module?',
464 $TT_XS_ENABLE) =~ /^y/i);
465
466 if ($TT_XS_ENABLE) {
467
468 $TT_XS_DEFAULT = (ttprompt('Do you want to use the XS Stash for all Templates?',
469 $TT_XS_DEFAULT) =~ /^y/i);
470
d9412385 »
2001-08-21 prep 2.4d
471 fix_file('lib/Template/Config.pm',
472 '$STASH',
473 $TT_XS_DEFAULT ? 'Template::Stash::XS' : 'Template::Stash');
9be7d64a »
2001-08-21 approaching 2.04d
474 }
475 }
476
a4123f87 »
2001-08-04 2.04b
477
c8d76d48 »
2001-03-29 *** empty log message ***
478 #------------------------------------------------------------------------
a4123f87 »
2001-08-04 2.04b
479 # optional_latex()
480 #
481 # Prompt for installation of latex filter
f4df3b6f »
2001-06-14 approach v2.03
482 #------------------------------------------------------------------------
483
a4123f87 »
2001-08-04 2.04b
484 sub optional_latex {
9be7d64a »
2001-08-21 approaching 2.04d
485 # return if $TT_ACCEPT && (! $TT_LATEX_ENABLE || $TT_LATEX_ENABLE eq 'n');
a4123f87 »
2001-08-04 2.04b
486
9be7d64a »
2001-08-21 approaching 2.04d
487 $TT_LATEX_PATH ||= find_program($ENV{PATH}, "latex") || '';
488 $TT_PDFLATEX_PATH ||= find_program($ENV{PATH}, "pdflatex") || '';
489 $TT_DVIPS_PATH ||= find_program($ENV{PATH}, "dvips") || '';
a4123f87 »
2001-08-04 2.04b
490
491 message(<<EOF);
f4df3b6f »
2001-06-14 approach v2.03
492
9be7d64a »
2001-08-21 approaching 2.04d
493
494 LaTeX Support
495 -------------
496
f4df3b6f »
2001-06-14 approach v2.03
497 TT2 supports PDF, DVI and PostScript output using the latex filter,
498 implemented with the programs pdflatex, latex and dvips.
499
500 Because the latex filter runs latex and pdflatex, template authors could
501 use this feature to include any arbitrary file in their latex input, or
502 also open an arbitrary output file, independent of the ABSOLUTE or
503 RELATIVE configuration settings. This might create a security concern at
504 your site. If you don't trust your template authors then don't enable
505 the latex filter.
506
507 I found the following locations for pdflatex, latex and dvips:
508 + pdflatex => $TT_PDFLATEX_PATH
509 + latex => $TT_LATEX_PATH
510 + dvips => $TT_DVIPS_PATH
511
512 EOF
513
a4123f87 »
2001-08-04 2.04b
514 if ( $TT_LATEX_PATH eq "" || $TT_PDFLATEX_PATH eq "" || $TT_DVIPS_PATH eq "" ) {
515 $TT_LATEX_ENABLE = 'n';
516 }
517 $TT_LATEX_ENABLE ||= 'y';
518 $TT_LATEX_ENABLE = (
519 ttprompt('Do you want to enable the latex filter?',
520 $TT_LATEX_ENABLE) =~ /^y/i
521 );
522 if ( $TT_LATEX_ENABLE ) {
523 if (ttprompt('Are the pdflatex, latex and dvips paths ok?', 'y') !~ /^y/i) {
524 $TT_PDFLATEX_PATH = ttprompt('pdflatex path', $TT_PDFLATEX_PATH);
525 $TT_LATEX_PATH = ttprompt('latex path', $TT_LATEX_PATH);
526 $TT_DVIPS_PATH = ttprompt('dvips path', $TT_DVIPS_PATH);
527 }
528 } else {
529 #
530 # Empty paths will cause the latex filter to throw an error
531 #
532 $TT_PDFLATEX_PATH = $TT_LATEX_PATH = $TT_DVIPS_PATH = "";
f4df3b6f »
2001-06-14 approach v2.03
533 }
d9412385 »
2001-08-21 prep 2.4d
534
a4123f87 »
2001-08-04 2.04b
535 fix_file('lib/Template/Config.pm', '$PDFLATEX_PATH', $TT_PDFLATEX_PATH);
536 fix_file('lib/Template/Config.pm', '$LATEX_PATH', $TT_LATEX_PATH);
537 fix_file('lib/Template/Config.pm', '$DVIPS_PATH', $TT_DVIPS_PATH);
f4df3b6f »
2001-06-14 approach v2.03
538 }
539
a4123f87 »
2001-08-04 2.04b
540
f4df3b6f »
2001-06-14 approach v2.03
541 #------------------------------------------------------------------------
a4123f87 »
2001-08-04 2.04b
542 # optional_extras()
543 #
544 # Prompt for installation of optional libraries and other components
c8d76d48 »
2001-03-29 *** empty log message ***
545 #------------------------------------------------------------------------
546
a4123f87 »
2001-08-04 2.04b
547 sub optional_extras {
548 message(<<EOF);
c8d76d48 »
2001-03-29 *** empty log message ***
549
9be7d64a »
2001-08-21 approaching 2.04d
550
551 Optional Extras
552 ---------------
553
c8d76d48 »
2001-03-29 *** empty log message ***
554 In additional to the Perl modules and POD documentation installed in
555 the usual way, the Template Toolkit distribution also contains a
556 number of optional components:
557
558 * Template libaries for basic HTML, Pod -> HTML, and PostScript
559
560 * Splash! - a stylish HTML user interface template library / widget set
561
562 * HTML documentation - distributed in template form for customisation
563
564 * Stylesheet templates to generate docs as vanilla HTML or using Splash!
565
566 * Examples - numerous examples of using the template libraries
567
568 If you want to install these optional components then you'll need to
569 specify a separate directory for them.
570
571 EOF
572
a4123f87 »
2001-08-04 2.04b
573 if (ttprompt('Do you want to install these components?', 'y') =~ /^y/i) {
574 message(<<EOF);
c8d76d48 »
2001-03-29 *** empty log message ***
575
576 You can chose any directory for the installation of the additional
911a5e37 »
2001-04-04 *** empty log message ***
577 Template Toolkit components. The proposed default assumes a $FLAVOUR
578 flavour to your operating system (suggestions for suitable defaults
579 for other platforms welcome).
c8d76d48 »
2001-03-29 *** empty log message ***
580
581 EOF
9be7d64a »
2001-08-21 approaching 2.04d
582 $TT_PREFIX = ttprompt('Installation directory', $TT_PREFIX || $PREFIX);
a4123f87 »
2001-08-04 2.04b
583 }
584 else {
585 $TT_PREFIX = '';
586 }
587
588 fix_file('lib/Template/Config.pm', '$INSTDIR', $TT_PREFIX);
c8d76d48 »
2001-03-29 *** empty log message ***
589 }
590
591
592
593 #------------------------------------------------------------------------
a4123f87 »
2001-08-04 2.04b
594 # splash_images()
595 #
596 # Prompt for Splash! image URL
c8d76d48 »
2001-03-29 *** empty log message ***
597 #------------------------------------------------------------------------
598
a4123f87 »
2001-08-04 2.04b
599 sub splash_images {
600 return unless $TT_PREFIX;
911a5e37 »
2001-04-04 *** empty log message ***
601
a4123f87 »
2001-08-04 2.04b
602 message(<<EOF);
c8d76d48 »
2001-03-29 *** empty log message ***
603
9be7d64a »
2001-08-21 approaching 2.04d
604
605 Splash!
606 -------
607
c8d76d48 »
2001-03-29 *** empty log message ***
608 The Splash! template library uses a number of (very) small images to
609 build user interface components. These will be installed into the
610 directory:
611
a4123f87 »
2001-08-04 2.04b
612 $TT_PREFIX/images
911a5e37 »
2001-04-04 *** empty log message ***
613 EOF
614
615 if ($WIN32) {
616 # default images value for Win32 to browse via file system
a4123f87 »
2001-08-04 2.04b
617 $TT_IMAGES = "$TT_PREFIX/images";
618
619 message(<<EOF);
620
911a5e37 »
2001-04-04 *** empty log message ***
621 If you want to use the Splash! library then you'll need to make sure
622 you can access these images via your browser. If you want to deliver
623 pages via a web server then you'll need to specify the URL that can be
624 use to access these images. In the general case you can accept the
625 default and access the images via the filesystem.
626
627 EOF
628 }
629 else {
a4123f87 »
2001-08-04 2.04b
630 message(<<EOF);
c8d76d48 »
2001-03-29 *** empty log message ***
631
632 If you want to use the Splash! library then you'll need to copy these
633 images, define an alias (e.g. in the httpd.conf) or create a symbolic
634 link to them so that your web server can find them. Then you'll need
635 to specify the resulting URL which can be used to retrieve them from
636 the web server.
637
638 Typical values might be '/tt2/images', '/images/tt2', '/~user/tt2/images'
639 or even something like 'http://www.yourhost.org/images/tt2'.
640
641 (NOTE: If this is too much for you to think about right now, then
642 accept the default below and read the Template::Library::Splash
643 manpage at your leisure to find out more).
644
645 EOF
911a5e37 »
2001-04-04 *** empty log message ***
646 }
c8d76d48 »
2001-03-29 *** empty log message ***
647
9be7d64a »
2001-08-21 approaching 2.04d
648 $TT_IMAGES = ttprompt('URL base for TT2 images?', $TT_IMAGES || $IMAGES);
c8d76d48 »
2001-03-29 *** empty log message ***
649 $TT_IMAGES =~ s[/$][]g; # just in case
d9412385 »
2001-08-21 prep 2.4d
650
c8d76d48 »
2001-03-29 *** empty log message ***
651 fix_file('templates/splash/config', 'images', "$TT_IMAGES/splash");
652 }
653
654
655
a4123f87 »
2001-08-04 2.04b
656 #------------------------------------------------------------------------
657 # html_docs()
658 #
659 # Prompt for HTML documentation build
660 #--------------------------------------------------------------------
661
662 sub html_docs {
663 return unless $TT_PREFIX;
664
c8d76d48 »
2001-03-29 *** empty log message ***
665 my $style = 'plain';
666 my $style_cfg = '';
667
a4123f87 »
2001-08-04 2.04b
668 message(<<EOF);
c8d76d48 »
2001-03-29 *** empty log message ***
669
9be7d64a »
2001-08-21 approaching 2.04d
670
671 HTML Documentation
672 ------------------
673
c8d76d48 »
2001-03-29 *** empty log message ***
674 The modules comprising the Template Toolkit contain comprehensive POD
675 documentation which can be browsed using 'perldoc' or 'man' (if your
676 system supports it). In additional, the distribution also includes a
677 set of source templates and style elements for generating the same
678 documentation in HTML format. These will be installed in the
679 directory:
680
a4123f87 »
2001-08-04 2.04b
681 $TT_PREFIX/docs
c8d76d48 »
2001-03-29 *** empty log message ***
682
683 The HTML documentation can be built for you at "make install" time in
684 a plain and simple HTML format or using the Splash! library. You can
685 see examples of these different styles and browse the documentation
686 online at:
687
688 http://www.template-toolkit.org/docs/
689
690 EOF
691
692 $TT_BUILD_DOCS = (
a4123f87 »
2001-08-04 2.04b
693 ttprompt('Do you want to build the HTML documentation?',
c8d76d48 »
2001-03-29 *** empty log message ***
694 $TT_BUILD_DOCS) =~ /^y/i
695 );
696
a4123f87 »
2001-08-04 2.04b
697 }
698
699
700 #--------------------------------------------------------------------
701 # html_docstyle()
702 #
703 # prompt for docs style: plain or splash
704 #--------------------------------------------------------------------
705
706 sub html_docstyle {
707 return unless $TT_PREFIX && $TT_BUILD_DOCS;
708
709 my $style = 'plain';
710 my $style_cfg = '';
c8d76d48 »
2001-03-29 *** empty log message ***
711
a4123f87 »
2001-08-04 2.04b
712 message(<<EOF);
c8d76d48 »
2001-03-29 *** empty log message ***
713
ca4050f2 »
2001-04-06 prep for 2.02
714 If you want to build the HTML documentation using the Splash! library
715 then you'll need to make sure you correctly defined the URL for the
716 Splash! images above. Otherwise, answer 'n' to the next question to
717 use plain HTML.
c8d76d48 »
2001-03-29 *** empty log message ***
718
719 EOF
a4123f87 »
2001-08-04 2.04b
720 $TT_SPLASH_DOCS = (
721 ttprompt('Do you want to use the Splash! library?', $TT_SPLASH_DOCS) =~ /^y/i
722 );
c8d76d48 »
2001-03-29 *** empty log message ***
723
a4123f87 »
2001-08-04 2.04b
724 if ($TT_SPLASH_DOCS) {
725 my $splash_style = '';
726 message(<<EOF);
ca4050f2 »
2001-04-06 prep for 2.02
727
728 Which Splash! colour scheme would you like to use to build the
729 documentation? Acceptable values are:
730
731 EOF
a4123f87 »
2001-08-04 2.04b
732 unless ($TT_QUIET) {
ca4050f2 »
2001-04-06 prep for 2.02
733 print " Name Colours\n -------------------------\n";
734 foreach my $t ('default',
735 grep { ! /^default$/ } sort keys %$SPLASH_STYLES) {
736 my $v = $SPLASH_STYLES->{ $t };
737 local $" = '/';
738 printf(" %-8s @$v\n", $t);
739 }
740 print "\n";
741
742 while (! $splash_style) {
a4123f87 »
2001-08-04 2.04b
743 $TT_SPLASH_THEME = ttprompt("Enter name of colour scheme: ", $TT_SPLASH_THEME);
744 message("! No such scheme\n"), $TT_SPLASH_THEME = 'default'
ca4050f2 »
2001-04-06 prep for 2.02
745 unless ($splash_style = $SPLASH_STYLES->{ $TT_SPLASH_THEME });
746 }
46e4eb84 »
2001-08-21 * Added new colour theme called 'leon'
747
748 ( $TT_SPLASH_BG, $TT_SPLASH_FG, $TT_SPLASH_BT, $TT_SPLASH_FT )
749 = @$splash_style;
750
751 # default background (unselected) text is black, fore is white
752 $TT_SPLASH_BT ||= 'black';
753 $TT_SPLASH_FT ||= 'white';
ca4050f2 »
2001-04-06 prep for 2.02
754
c8d76d48 »
2001-03-29 *** empty log message ***
755 $style = 'splash';
ca4050f2 »
2001-04-06 prep for 2.02
756 $style_cfg = <<EOF;
757
758 pre_process = splash/config
759 define splash_fg = '$TT_SPLASH_FG'
760 define splash_bg = '$TT_SPLASH_BG'
46e4eb84 »
2001-08-21 * Added new colour theme called 'leon'
761 define splash_ft = '$TT_SPLASH_FT'
762 define splash_bt = '$TT_SPLASH_BT'
ca4050f2 »
2001-04-06 prep for 2.02
763 EOF
c8d76d48 »
2001-03-29 *** empty log message ***
764 }
765 }
766
767 #--------------------------------------------------------------------
768 # write ttree config file for building docs
769 #--------------------------------------------------------------------
770
771 open(FP, "> $TT_DOCS_CFG") || die "$TT_DOCS_CFG: $!\n";
772 print FP <<EOF;
773 # This ttree configuration file is automatically generated by
774 # the Makefile.PL installation script. Feel free to edit it
775 # but be warned that re-installing the Template Toolkit will
776 # overwrite your changes.
a4123f87 »
2001-08-04 2.04b
777 src = $TT_PREFIX/docs/src
778 dest = $TT_PREFIX/docs/html
779 lib = $TT_PREFIX/docs/style/$style
780 lib = $TT_PREFIX/docs/lib
781 lib = $TT_PREFIX/templates
c8d76d48 »
2001-03-29 *** empty log message ***
782 $style_cfg
783 pre_process = config
784 pre_process = header
785 post_process = footer
911a5e37 »
2001-04-04 *** empty log message ***
786 recurse
787 verbose
c8d76d48 »
2001-03-29 *** empty log message ***
788 EOF
789 close(FP);
a4123f87 »
2001-08-04 2.04b
790 }
c8d76d48 »
2001-03-29 *** empty log message ***
791
792
a4123f87 »
2001-08-04 2.04b
793
794
795 #--------------------------------------------------------------------
796 # html_examples()
797 #
798 # Prompt for building examples
799 #--------------------------------------------------------------------
800
801 sub html_examples {
802 return unless $TT_PREFIX;
803
804 message(<<EOF);
c8d76d48 »
2001-03-29 *** empty log message ***
805
9be7d64a »
2001-08-21 approaching 2.04d
806
807 HTML Examples
808 -------------
809
c8d76d48 »
2001-03-29 *** empty log message ***
810 A number of examples showing use of the HTML, Splash! and PostScript
811 libraries will be installed into:
812
a4123f87 »
2001-08-04 2.04b
813 $TT_PREFIX/examples
c8d76d48 »
2001-03-29 *** empty log message ***
814
815 As with the documentation, the examples are provided in template form
816 and can be automatically built into HTML pages during the "make
817 install". These pages rely on the Splash! library and expect the
818 images URL to be correctly defined for correct viewing.
819
820 EOF
821
822 $TT_EXAMPLES = (
a4123f87 »
2001-08-04 2.04b
823 ttprompt('Do you want to build the HTML example pages?',
c8d76d48 »
2001-03-29 *** empty log message ***
824 $TT_EXAMPLES) =~ /^y/i
825 );
826
827 #--------------------------------------------------------------------
828 # write ttree config file for building examples
829 #--------------------------------------------------------------------
830
831 open(FP, "> $TT_EXAMPLE_CFG") || die "$TT_EXAMPLE_CFG: $!\n";
832 print FP <<EOF;
833 # This ttree configuration file is automatically generated by
834 # the Makefile.PL installation script. Feel free to edit it
835 # but be warned that re-installing the Template Toolkit will
836 # overwrite your changes.
837
a4123f87 »
2001-08-04 2.04b
838 src = $TT_PREFIX/examples/src
839 dest = $TT_PREFIX/examples/html
840 lib = $TT_PREFIX/examples/lib
841 lib = $TT_PREFIX/templates
ca4050f2 »
2001-04-06 prep for 2.02
842 define splash_fg = '$TT_SPLASH_FG'
843 define splash_bg = '$TT_SPLASH_BG'
c8d76d48 »
2001-03-29 *** empty log message ***
844 pre_process = config
911a5e37 »
2001-04-04 *** empty log message ***
845 recurse
846 verbose
c8d76d48 »
2001-03-29 *** empty log message ***
847 EOF
848
849 close(FP);
850 }
a4123f87 »
2001-08-04 2.04b
851
852
853 #--------------------------------------------------------------------
854 # write_defaults()
855 #
856 # write configuration defaults to file
857 #--------------------------------------------------------------------
858
859 sub write_defaults {
ca4050f2 »
2001-04-06 prep for 2.02
860 open(FP, "> $DEFAULTS_FILE") || die "$DEFAULTS_FILE: $!\n";
9be7d64a »
2001-08-21 approaching 2.04d
861 my ( $ttdbi, $ttdocs, $ttsplash, $ttex,
862 $ttlatex, $ttxs_enable, $ttxs_default )
863 = map { $_ ? 'y' : 'n' }
864 ( $TT_RUN_DBI, $TT_BUILD_DOCS, $TT_SPLASH_DOCS, $TT_EXAMPLES,
865 $TT_LATEX_ENABLE, $TT_XS_ENABLE, $TT_XS_DEFAULT );
ca4050f2 »
2001-04-06 prep for 2.02
866 print FP <<EOF;
a4123f87 »
2001-08-04 2.04b
867 \$TT_PREFIX = '$TT_PREFIX';
f4df3b6f »
2001-06-14 approach v2.03
868 \$TT_IMAGES = '$TT_IMAGES';
869 \$TT_RUN_DBI = '$ttdbi';
870 \$TT_BUILD_DOCS = '$ttdocs';
871 \$TT_SPLASH_DOCS = '$ttsplash';
872 \$TT_EXAMPLES = '$ttex';
873 \$TT_SPLASH_THEME = '$TT_SPLASH_THEME';
874 \$TT_LATEX_ENABLE = '$ttlatex';
875 \$TT_LATEX_PATH = '$TT_LATEX_PATH';
876 \$TT_PDFLATEX_PATH = '$TT_PDFLATEX_PATH';
877 \$TT_DVIPS_PATH = '$TT_DVIPS_PATH';
9be7d64a »
2001-08-21 approaching 2.04d
878 \$TT_XS_ENABLE = '$ttxs_enable';
879 \$TT_XS_DEFAULT = '$ttxs_default';
a4123f87 »
2001-08-04 2.04b
880 \$TT_ACCEPT = '$TT_ACCEPT';
881 \$TT_QUIET = '$TT_QUIET';
9acc7961 »
2001-06-23 post 2.03a
882 1;
ca4050f2 »
2001-04-06 prep for 2.02
883 EOF
884 close(FP);
c8d76d48 »
2001-03-29 *** empty log message ***
885 }
886
48634a1f »
2000-10-09 *** empty log message ***
887
888 #------------------------------------------------------------------------
889 # build_docs()
890 #
891 # Echo the relevant incantation so that 'make dist' regenerates the
892 # documentation from the template sources.
25a8d8ef »
2000-08-10 *** empty log message ***
893 #------------------------------------------------------------------------
eabb19e8 »
2000-08-06 *** empty log message ***
894
3ebfa076 »
2000-06-25 Initial revision
895 sub build_docs {
896 return <<EOF;
897 echo "Building documentation for version \$(VERSION)" ; \\
0b63aaec »
2000-09-08 *** empty log message ***
898 \$(PERL) bin/ttree -f ./docs/ttdist.cfg --define version=\$(VERSION) -a; \\
3ebfa076 »
2000-06-25 Initial revision
899 EOF
900 }
901
48634a1f »
2000-10-09 *** empty log message ***
902
82cbea87 »
2000-11-01 version 2.00
903
904 #------------------------------------------------------------------------
867f44f2 »
2000-11-14 rc2
905 # check_taf()
906 #
907 # There are some problems with Text::Autoformat with version of Perl
908 # prior to 5.6.0 not working properly with locales that use a numerical
909 # separator other than '.' (e.g. Swedish)
910 #------------------------------------------------------------------------
911
912 sub check_taf {
913 use POSIX qw( localeconv );
914 my $loc = localeconv;
915 my $dec = $loc->{ decimal_point };
916
917 yep("version $Text::Autoformat::VERSION installed");
918
919 if ($] <= 5.006 && $dec ne '.') {
920 print ' ' x 6,
921 "NOTE: tests 23 and 25 may fail under your locale, see TODO file.\n";
922 }
923 }
924
925
926 #------------------------------------------------------------------------
acff2124 »
2000-10-09 *** empty log message ***
927 # check_dom()
928 #
867f44f2 »
2000-11-14 rc2
929 # XML::DOM changed from HASH to ARRAY objects somewhere between versions
930 # 1.25 and 1.27, so the latter version is an absolute necessity.
60dfe443 »
2000-10-09 *** empty log message ***
931 #------------------------------------------------------------------------
932
933 sub check_dom {
867f44f2 »
2000-11-14 rc2
934 if ($XML::DOM::VERSION < 1.27) {
935 nope("requires version 1.27 or later ($XML::DOM::VERSION installed)");
60dfe443 »
2000-10-09 *** empty log message ***
936 }
937 else {
82cbea87 »
2000-11-01 version 2.00
938 yep("version $XML::DOM::VERSION installed");
60dfe443 »
2000-10-09 *** empty log message ***
939 }
940 }
941
942
acff2124 »
2000-10-09 *** empty log message ***
943 #------------------------------------------------------------------------
944 # check_rss()
945 #
946 # Version 0.8 of XML::RSS gave warnings under Perl 5.6.0 so issue an
947 # upgrade recommendation
948 #------------------------------------------------------------------------
949
60dfe443 »
2000-10-09 *** empty log message ***
950 sub check_rss {
82cbea87 »
2000-11-01 version 2.00
951 if ($] >= 5.006 && $XML::RSS::VERSION < 0.9) {
952 nope("requires version 0.9 or later ($XML::RSS::VERSION installed)");
60dfe443 »
2000-10-09 *** empty log message ***
953 }
954 else {
82cbea87 »
2000-11-01 version 2.00
955 yep("version $XML::RSS::VERSION installed");
60dfe443 »
2000-10-09 *** empty log message ***
956 }
957 }
958
a4123f87 »
2001-08-04 2.04b
959
acff2124 »
2000-10-09 *** empty log message ***
960 #------------------------------------------------------------------------
961 # check_xpath()
962 #
963 # Tests fail under some of the earlier versions (e.g. 0.55) so we issue
964 # an upgrade recommendation.
965 #------------------------------------------------------------------------
60dfe443 »
2000-10-09 *** empty log message ***
966
967 sub check_xpath {
968 if ($XML::XPath::VERSION < 1.00) {
82cbea87 »
2000-11-01 version 2.00
969 nope("requires version 1.00 or later ($XML::XPath::VERSION installed)");
60dfe443 »
2000-10-09 *** empty log message ***
970 }
971 else {
82cbea87 »
2000-11-01 version 2.00
972 yep("version $XML::XPath::VERSION installed");
60dfe443 »
2000-10-09 *** empty log message ***
973 }
974 }
975
976
977 #------------------------------------------------------------------------
48634a1f »
2000-10-09 *** empty log message ***
978 # dbi_config()
979 #
980 # Quiz the user for options related to running the DBI tests.
981 #------------------------------------------------------------------------
982
983 sub dbi_config {
a4123f87 »
2001-08-04 2.04b
984 my ($dsn, $user, $pass) = ('') x 3;
48634a1f »
2000-10-09 *** empty log message ***
985
a4123f87 »
2001-08-04 2.04b
986 message("[X] version $DBI::VERSION installed, configuring tests\n\n");
48634a1f »
2000-10-09 *** empty log message ***
987
a4123f87 »
2001-08-04 2.04b
988 if (ttprompt("Do you want to run the DBI tests?\n" .
c8d76d48 »
2001-03-29 *** empty log message ***
989 "It requires access to an existing test database.",
ca4050f2 »
2001-04-06 prep for 2.02
990 $TT_RUN_DBI) =~ /y/i) {
48634a1f »
2000-10-09 *** empty log message ***
991
ca4050f2 »
2001-04-06 prep for 2.02
992 $TT_RUN_DBI = 1;
48634a1f »
2000-10-09 *** empty log message ***
993 my ($driver, $dbname);
994 my @drivers = DBI->available_drivers();
995 local $" = ', ';
996
30480bd9 »
2001-08-21 * Fixed bug which looked for msql or mysql DBD driver and didn't set an
997 my $default = (grep(/m.?sql/i, @drivers))[0]
998 || $drivers[0] || '';
867f44f2 »
2000-11-14 rc2
999
a4123f87 »
2001-08-04 2.04b
1000 message(<<EOF);
48634a1f »
2000-10-09 *** empty log message ***
1001
9be7d64a »
2001-08-21 approaching 2.04d
1002 DBI Test Configuration
1003 ----------------------
1004
c8d76d48 »
2001-03-29 *** empty log message ***
1005 Please enter the driver name for the test database.
1006 The DBD drivers installed on your system are
1007
1008 @drivers
867f44f2 »
2000-11-14 rc2
1009
1010 EOF
48634a1f »
2000-10-09 *** empty log message ***
1011
1012 while (! $driver) {
a4123f87 »
2001-08-04 2.04b
1013 $driver = ttprompt("Enter driver name: ", $default);
1014 message("! No such DBD driver\n"), undef $driver
48634a1f »
2000-10-09 *** empty log message ***
1015 unless grep(/^$driver$/, @drivers);
1016 }
1017
a4123f87 »
2001-08-04 2.04b
1018 message(<<EOF);
c8d76d48 »
2001-03-29 *** empty log message ***
1019
1020 Now enter the data source (DSN) for the test database.
1021 Many DBD drivers require only a database name (e.g. 'test') while
1022 others may require an alternate format or additional parameters
1023 (e.g. 'dbname=test'). Please consult your DBD documentation for
1024 further details.
1025
867f44f2 »
2000-11-14 rc2
1026 EOF
1027
1028 my $dbname_eg = $driver eq 'Pg' ? 'dbname=test' : 'test';
48634a1f »
2000-10-09 *** empty log message ***
1029 while (! $dbname) {
a4123f87 »
2001-08-04 2.04b
1030 $dbname = ttprompt('Database name: ', $dbname_eg);
48634a1f »
2000-10-09 *** empty log message ***
1031 }
1032
1033 $dsn = "dbi:$driver:$dbname";
1034
a4123f87 »
2001-08-04 2.04b
1035 $user = ttprompt('Enter user name : ', '');
1036 $pass = ttprompt('Enter password : ', '');
48634a1f »
2000-10-09 *** empty log message ***
1037
1038 $user = '' unless defined $user;
1039 $pass = '' unless defined $pass;
1040 }
1041 else {
ca4050f2 »
2001-04-06 prep for 2.02
1042 $TT_RUN_DBI = 0;
48634a1f »
2000-10-09 *** empty log message ***
1043 }
1044
a4123f87 »
2001-08-04 2.04b
1045 message("\nwriting $DBI_CONFIG_FILE\n");
48634a1f »
2000-10-09 *** empty log message ***
1046 open(CFGFILE, ">$DBI_CONFIG_FILE") || die "$DBI_CONFIG_FILE: $!\n";
1047 print CFGFILE <<EOF;
ca4050f2 »
2001-04-06 prep for 2.02
1048 \$run = $TT_RUN_DBI;
48634a1f »
2000-10-09 *** empty log message ***
1049 \$dsn = '$dsn';
1050 \$user = '$user';
1051 \$pass = '$pass';
1052 1;
1053 EOF
1054 close(CFGFILE);
1055 }
1056
c8d76d48 »
2001-03-29 *** empty log message ***
1057
1058
1059 #------------------------------------------------------------------------
1060 # fix_file($file, $find, $fix)
1061 #
1062 # Fixes a variable definition in a file. e.g.
d9412385 »
2001-08-21 prep 2.4d
1063 # fix_file('templates/splash/config', 'images', '/tt2/splash')
c8d76d48 »
2001-03-29 *** empty log message ***
1064 #------------------------------------------------------------------------
1065
1066 sub fix_file {
1067 my ($file, $find, $fix) = @_;
1068 local *FP;
1069 local $/ = undef;
1070
1071 $find = quotemeta($find);
1072
1073 open(FP, "< $file") || die "$file: $!\n";
1074 my $text = <FP>;
1075 close(FP);
1076
1077 ($text =~ s/^(\s*${find}\s*=\s*)'.*?'/$1'$fix'/m)
1078 || die "$find not found in $file\n";
1079
1080 open(FP, "> $file") || die "$file: $!\n";
1081 print FP $text;
1082 close(FP);
1083 }
1084
a4123f87 »
2001-08-04 2.04b
1085
1086 #------------------------------------------------------------------------
9be7d64a »
2001-08-21 approaching 2.04d
1087 # find_program($path, $prog)
f4df3b6f »
2001-06-14 approach v2.03
1088 #
1089 # Find a program, $prog, by traversing the given directory path, $path.
1090 # Returns full path if the program is found.
1091 #
1092 # Written by Craig Barratt, Richard Tietjen add fixes for Win32.
9be7d64a »
2001-08-21 approaching 2.04d
1093 #
1094 # abw changed name from studly caps findProgram() to find_program() :-)
a4123f87 »
2001-08-04 2.04b
1095 #------------------------------------------------------------------------
1096
9be7d64a »
2001-08-21 approaching 2.04d
1097 sub find_program {
f4df3b6f »
2001-06-14 approach v2.03
1098 my($path, $prog) = @_;
1099 my $sep = $WIN32 ? qr/;/ : qr/:/;
1100 foreach my $dir ( split($sep, $path) ) {
1101 my $file = File::Spec->catfile($dir, $prog);
1102 if ( !$WIN32 ) {
1103 return $file if ( -x $file );
1104 } else {
1105 # Windows executables end in .xxx, exe precedes .bat and .cmd
1106 foreach my $dx ( qw/exe bat cmd/ ) {
1107 return "$file.$dx" if ( -x "$file.$dx" );
1108 }
1109 }
1110 }
1111 }
a4123f87 »
2001-08-04 2.04b
1112
1113
1114 #------------------------------------------------------------------------
1115 # message($text)
1116 #
1117 # Print message unless quiet mode.
1118 #------------------------------------------------------------------------
1119
1120 sub message {
1121 return if $TT_QUIET;
1122 print @_;
1123 }
1124
1125
1126 #------------------------------------------------------------------------
1127 # ttprompt($message, $default)
1128 #------------------------------------------------------------------------
1129
1130 sub ttprompt {
1131 my ($msg, $def)=@_;
1132 my $ISA_TTY = -t STDIN && (-t STDOUT || !(-f STDOUT || -c STDOUT)) ; # Pipe?
1133 my $dispdef = defined $def ? "[$def] " : " ";
1134 $def = defined $def ? $def : "";
1135 my $ans = '';
1136 local $|=1;
1137 print "$msg $dispdef" unless $TT_QUIET;
1138 if ($TT_ACCEPT || ! $ISA_TTY) {
1139 print "$def\n" unless $TT_QUIET;
1140 }
1141 else {
1142 chomp($ans = <STDIN>);
1143 }
1144 return ($ans ne '') ? $ans : $def;
1145 }
1146
1147
1148 #------------------------------------------------------------------------
1149 # yep($text)
1150 #------------------------------------------------------------------------
1151
1152 sub yep {
1153 return if $TT_QUIET;
1154 print '[X] ', shift, "\n";
1155 }
1156
1157
1158 #------------------------------------------------------------------------
1159 # nope($text)
1160 #------------------------------------------------------------------------
1161 sub nope {
1162 return if $TT_QUIET;
1163 print '[ ] ', shift, "\n";
1164 }
Something went wrong with that request. Please try again.