Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

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