Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 655 lines (497 sloc) 18.46 kb
49d1e32 @abw *** empty log message ***
authored
1 use ExtUtils::MakeMaker; # -*-perl-*-
c8d76d4 @abw *** empty log message ***
authored
2 use Cwd;
3ebfa07 @abw Initial revision
authored
3
e39913f @abw *** empty log message ***
authored
4 select STDERR;
5 $| = 1;
6 select STDOUT;
7
48634a1 @abw *** empty log message ***
authored
8 my $DBI_CONFIG_FILE = 't/dbi_test.cfg';
c8d76d4 @abw *** empty log message ***
authored
9 my $TT_INST_ROOT = '/usr/local/tt2'; # should be more platform general
10 my $TT_IMAGES = '/tt2/images'; # and honour existing installation
11 my $TT_BUILD_DOCS = 'y';
12 my $TT_SPLASH_DOCS = 'y';
13 my $TT_EXAMPLES = 'y';
14 my $TT_DOCS_CFG = 'docs/ttree.cfg';
15 my $TT_EXAMPLE_CFG = 'examples/ttree.cfg';
d52480d @abw *** empty log message ***
authored
16
911a5e3 @abw *** empty log message ***
authored
17 my $WIN32 = ($^O =~ /win/i);
18 my $FLAVOUR = $WIN32 ? 'Win32' : 'Unix';
19
20 if ($WIN32) {
21 $TT_INST_ROOT = 'C:/Program Files/Template Toolkit 2';
22 }
23
48634a1 @abw *** empty log message ***
authored
24 print <<EOF;
c542301 @abw *** empty log message ***
authored
25
c8d76d4 @abw *** empty log message ***
authored
26 Template Toolkit Version 2.01
c542301 @abw *** empty log message ***
authored
27 =============================
911a5e3 @abw *** empty log message ***
authored
28
29 Using $FLAVOUR defaults.
48634a1 @abw *** empty log message ***
authored
30 EOF
31
32 #------------------------------------------------------------------------
33 # check for pre-version 2.00 installation and issue warning
34 #------------------------------------------------------------------------
35
36 eval "use Template";
37 unless ($@ or $Template::VERSION =~ /^2/) {
38 warn(<<EOF);
39
c542301 @abw *** empty log message ***
authored
40 IMPORTANT NOTE:
41 ---------------
48634a1 @abw *** empty log message ***
authored
42 You have version $Template::VERSION of the Template Toolkit installed.
25a8d8e @abw *** empty log message ***
authored
43
82cbea8 @abw version 2.00
authored
44 There are some minor incompatabilities between version 1 and 2
48634a1 @abw *** empty log message ***
authored
45 of the Template Toolkit which you should be aware of. Installing
46 this version will overwrite your version $Template::VERSION files
47 unless you take measures to install one or the other version in a
82cbea8 @abw version 2.00
authored
48 different location (i.e. perl Makefile.PL PREFIX=/other/path).
48634a1 @abw *** empty log message ***
authored
49
50 Please consult the README and Changes file for further details.
51 Most of the changes are in the more obscure features and
52 directives so hopefully you will find the upgrade process fairly
53 painless.
25a8d8e @abw *** empty log message ***
authored
54
55 EOF
48634a1 @abw *** empty log message ***
authored
56 exit unless prompt("Do you want to continue?", 'y') =~ /y/i;
57 }
58
59 #------------------------------------------------------------------------
c8d76d4 @abw *** empty log message ***
authored
60 # detect mandatory module
61 #------------------------------------------------------------------------
62
63 eval "use AppConfig";
64 if ($@ or $AppConfig::VERSION < 1.52) {
65 die(<<EOF);
66
67 The Template Toolkit requires that the AppConfig module (version 1.52
68 or later) first be installed. This is used by the 'ttree' program for
69 reading command line options and configuration files. It is available
70 from CPAN:
71
72 http://www.cpan.org/authors/Andy_Wardley/
73
74 EOF
75 }
76
911a5e3 @abw *** empty log message ***
authored
77 eval "use File::Spec";
78 if ($@ or $File::Spec::VERSION < 0.82) {
79 die(<<EOF);
80
81 The Template Toolkit requires that the File::Spec module (version 0.82
82 or later) first be installed. This is used by the File plugin. It is
83 available from CPAN:
84
85 http://search.cpan.org/search?dist=File-Spec
86
87 EOF
88 }
89
90
c8d76d4 @abw *** empty log message ***
authored
91 #------------------------------------------------------------------------
48634a1 @abw *** empty log message ***
authored
92 # detect additional modules required by plugins (just for fun)
93 #------------------------------------------------------------------------
25a8d8e @abw *** empty log message ***
authored
94
48634a1 @abw *** empty log message ***
authored
95 print <<EOF;
96
82cbea8 @abw version 2.00
authored
97 The Template Toolkit includes a number of plugin modules, some of
98 which interface to external Perl modules available from CPAN. All the
99 plugins will be installed regardless so that they will automatically
100 work as and when you install the relevant modules. The tests will be
101 skipped for plugins that require external modules not currently
102 available on your system.
e39913f @abw *** empty log message ***
authored
103
104 EOF
48634a1 @abw *** empty log message ***
authored
105
867f44f @abw rc2
authored
106 foreach my $mods ( [ Text::Autoformat => \&check_taf ],
82cbea8 @abw version 2.00
authored
107 [ XML::DOM => \&check_dom ],
60dfe44 @abw *** empty log message ***
authored
108 [ XML::RSS => \&check_rss ],
109 [ XML::XPath => \&check_xpath ],
110 [ DBI => \&dbi_config ] ) {
82cbea8 @abw version 2.00
authored
111 my ($module, $code) = ref $mods ? @$mods : ($mods, 0);
60dfe44 @abw *** empty log message ***
authored
112
82cbea8 @abw version 2.00
authored
113 printf(" %-16s ", $module);
48634a1 @abw *** empty log message ***
authored
114 eval "use $module";
115 if ($@) {
82cbea8 @abw version 2.00
authored
116 nope("module not installed");
48634a1 @abw *** empty log message ***
authored
117 }
82cbea8 @abw version 2.00
authored
118 elsif ($code) {
60dfe44 @abw *** empty log message ***
authored
119 &$code;
48634a1 @abw *** empty log message ***
authored
120 }
82cbea8 @abw version 2.00
authored
121 else {
122 no strict qw( refs );
123 my $ver = ${"$module\::VERSION"};
124 yep("version $ver installed");
125 }
e39913f @abw *** empty log message ***
authored
126 }
127
c8d76d4 @abw *** empty log message ***
authored
128 #------------------------------------------------------------------------
129 # prompt for installation of optional libraries and other components
130 #------------------------------------------------------------------------
131
132 print <<EOF;
133
134 In additional to the Perl modules and POD documentation installed in
135 the usual way, the Template Toolkit distribution also contains a
136 number of optional components:
137
138 * Template libaries for basic HTML, Pod -> HTML, and PostScript
139
140 * Splash! - a stylish HTML user interface template library / widget set
141
142 * HTML documentation - distributed in template form for customisation
143
144 * Stylesheet templates to generate docs as vanilla HTML or using Splash!
145
146 * Examples - numerous examples of using the template libraries
147
148 If you want to install these optional components then you'll need to
149 specify a separate directory for them.
150
151 EOF
152
153 if (prompt('Do you want to install these components?', 'y') =~ /^y/i) {
154 print <<EOF;
155
156 You can chose any directory for the installation of the additional
911a5e3 @abw *** empty log message ***
authored
157 Template Toolkit components. The proposed default assumes a $FLAVOUR
158 flavour to your operating system (suggestions for suitable defaults
159 for other platforms welcome).
c8d76d4 @abw *** empty log message ***
authored
160
161 EOF
911a5e3 @abw *** empty log message ***
authored
162 $TT_INST_ROOT = prompt('Installation directory',
c8d76d4 @abw *** empty log message ***
authored
163 $TT_INST_ROOT);
164 }
165 else {
166 $TT_INST_ROOT = '';
167 }
168
169 fix_file('lib/Template/Config.pm', '$INSTDIR', $TT_INST_ROOT);
170
171
172 #------------------------------------------------------------------------
173 # prompt for Splash! image URL
174 #------------------------------------------------------------------------
175
176 if ($TT_INST_ROOT) {
911a5e3 @abw *** empty log message ***
authored
177
c8d76d4 @abw *** empty log message ***
authored
178 print <<EOF;
179
180 The Splash! template library uses a number of (very) small images to
181 build user interface components. These will be installed into the
182 directory:
183
184 $TT_INST_ROOT/images
911a5e3 @abw *** empty log message ***
authored
185 EOF
186
187 if ($WIN32) {
188 # default images value for Win32 to browse via file system
189 $TT_IMAGES = "$TT_INST_ROOT/images";
190
191 print <<EOF;
192
193 If you want to use the Splash! library then you'll need to make sure
194 you can access these images via your browser. If you want to deliver
195 pages via a web server then you'll need to specify the URL that can be
196 use to access these images. In the general case you can accept the
197 default and access the images via the filesystem.
198
199 EOF
200 }
201 else {
202 print <<EOF;
c8d76d4 @abw *** empty log message ***
authored
203
204 If you want to use the Splash! library then you'll need to copy these
205 images, define an alias (e.g. in the httpd.conf) or create a symbolic
206 link to them so that your web server can find them. Then you'll need
207 to specify the resulting URL which can be used to retrieve them from
208 the web server.
209
210 Typical values might be '/tt2/images', '/images/tt2', '/~user/tt2/images'
211 or even something like 'http://www.yourhost.org/images/tt2'.
212
213 (NOTE: If this is too much for you to think about right now, then
214 accept the default below and read the Template::Library::Splash
215 manpage at your leisure to find out more).
216
217 EOF
911a5e3 @abw *** empty log message ***
authored
218 }
c8d76d4 @abw *** empty log message ***
authored
219
220 $TT_IMAGES = prompt('URL base for TT2 images?', $TT_IMAGES);
221 $TT_IMAGES =~ s[/$][]g; # just in case
222 fix_file('templates/splash/config', 'images', "$TT_IMAGES/splash");
223 }
224
225
226
227 if ($TT_INST_ROOT) {
228 my $style = 'plain';
229 my $style_cfg = '';
230
231 #--------------------------------------------------------------------
232 # prompt for HTML documentation build
233 #--------------------------------------------------------------------
234 print <<EOF;
235
236 The modules comprising the Template Toolkit contain comprehensive POD
237 documentation which can be browsed using 'perldoc' or 'man' (if your
238 system supports it). In additional, the distribution also includes a
239 set of source templates and style elements for generating the same
240 documentation in HTML format. These will be installed in the
241 directory:
242
243 $TT_INST_ROOT/docs
244
245 The HTML documentation can be built for you at "make install" time in
246 a plain and simple HTML format or using the Splash! library. You can
247 see examples of these different styles and browse the documentation
248 online at:
249
250 http://www.template-toolkit.org/docs/
251
252 EOF
253
254 $TT_BUILD_DOCS = (
255 prompt('Do you want to build the HTML documentation?',
256 $TT_BUILD_DOCS) =~ /^y/i
257 );
258
259 #--------------------------------------------------------------------
260 # prompt for docs style: plain or splash
261 #--------------------------------------------------------------------
262
263 if ($TT_BUILD_DOCS) {
264 print <<EOF;
265
266 If you want to build the HTML documentation using then the Splash!
267 library then you'll need to make sure you correctly defined the URL
268 for the Splash! images above. Otherwise, answer 'n' to the next
269 question to use plain HTML.
270
271 EOF
272 $TT_SPLASH_DOCS = (
273 prompt('Do you want to use the Splash! library?',
274 $TT_SPLASH_DOCS) =~ /^y/i
275 );
276
277 if ($TT_SPLASH_DOCS) {
278 $style = 'splash';
279 $style_cfg = "\npre_process = splash/config";
280 }
281 }
282
283 #--------------------------------------------------------------------
284 # write ttree config file for building docs
285 #--------------------------------------------------------------------
286
287 open(FP, "> $TT_DOCS_CFG") || die "$TT_DOCS_CFG: $!\n";
288 print FP <<EOF;
289 # This ttree configuration file is automatically generated by
290 # the Makefile.PL installation script. Feel free to edit it
291 # but be warned that re-installing the Template Toolkit will
292 # overwrite your changes.
293 src = $TT_INST_ROOT/docs/src
294 dest = $TT_INST_ROOT/docs/html
295 lib = $TT_INST_ROOT/docs/style/$style
296 lib = $TT_INST_ROOT/docs/lib
297 lib = $TT_INST_ROOT/templates
298 $style_cfg
299 pre_process = config
300 pre_process = header
301 post_process = footer
911a5e3 @abw *** empty log message ***
authored
302 recurse
303 verbose
c8d76d4 @abw *** empty log message ***
authored
304 EOF
305 close(FP);
306
307 #--------------------------------------------------------------------
308 # prompt for building examples
309 #--------------------------------------------------------------------
310
311 print <<EOF;
312
313 A number of examples showing use of the HTML, Splash! and PostScript
314 libraries will be installed into:
315
316 $TT_INST_ROOT/examples
317
318 As with the documentation, the examples are provided in template form
319 and can be automatically built into HTML pages during the "make
320 install". These pages rely on the Splash! library and expect the
321 images URL to be correctly defined for correct viewing.
322
323 EOF
324
325 $TT_EXAMPLES = (
326 prompt('Do you want to build the HTML example pages?',
327 $TT_EXAMPLES) =~ /^y/i
328 );
329
330 #--------------------------------------------------------------------
331 # write ttree config file for building examples
332 #--------------------------------------------------------------------
333
334 open(FP, "> $TT_EXAMPLE_CFG") || die "$TT_EXAMPLE_CFG: $!\n";
335 print FP <<EOF;
336 # This ttree configuration file is automatically generated by
337 # the Makefile.PL installation script. Feel free to edit it
338 # but be warned that re-installing the Template Toolkit will
339 # overwrite your changes.
340
341 src = $TT_INST_ROOT/examples/src
342 dest = $TT_INST_ROOT/examples/html
343 lib = $TT_INST_ROOT/examples/lib
344 lib = $TT_INST_ROOT/templates
345 pre_process = config
911a5e3 @abw *** empty log message ***
authored
346 recurse
347 verbose
c8d76d4 @abw *** empty log message ***
authored
348 EOF
349
350 close(FP);
351 }
352
82cbea8 @abw version 2.00
authored
353 print "\n";
e39913f @abw *** empty log message ***
authored
354
48634a1 @abw *** empty log message ***
authored
355 #------------------------------------------------------------------------
356 # build options and write Makefile
357 #------------------------------------------------------------------------
3ebfa07 @abw Initial revision
authored
358
c8d76d4 @abw *** empty log message ***
authored
359 package MY;
360
361 sub postamble {
362 return '' unless $TT_INST_ROOT;
363 my $amble =<<'EOF';
364 tt2_install ::
365 @$(PERL) bin/tt2inst -v $(TT_INST_ROOT)
366
911a5e3 @abw *** empty log message ***
authored
367 tt2_splash ::
368 @$(PERL) -I lib bin/gifsplash -v
369
c8d76d4 @abw *** empty log message ***
authored
370 EOF
371 $amble .=<<EOF if $TT_BUILD_DOCS;
372 tt2_html_docs ::
373 \@\$(PERL) bin/ttree -v -f \$(TT_INST_ROOT)/$TT_DOCS_CFG
911a5e3 @abw *** empty log message ***
authored
374
c8d76d4 @abw *** empty log message ***
authored
375 EOF
376 $amble .=<<EOF if $TT_EXAMPLES;
377 tt2_examples ::
378 \@\$(PERL) bin/ttree -v -f \$(TT_INST_ROOT)/$TT_EXAMPLE_CFG
911a5e3 @abw *** empty log message ***
authored
379
c8d76d4 @abw *** empty log message ***
authored
380 EOF
381 return $amble;
382 }
383
384 sub install {
385 my $class = shift;
386 my $basic = $class->SUPER::install(@_);
911a5e3 @abw *** empty log message ***
authored
387 my $add = 'tt2_install tt2_splash';
c8d76d4 @abw *** empty log message ***
authored
388 $add .= ' tt2_html_docs' if $TT_BUILD_DOCS;
389 $add .= ' tt2_examples' if $TT_EXAMPLES;
390 $basic =~ s/^(install\s+::\s+.*)$/$1 $add/m
391 if $TT_INST_ROOT;
392 $basic;
393 }
394
395 sub constants {
396 my $class = shift;
397 my $basic = $class->SUPER::constants(@_);
398 $basic = "TT_INST_ROOT = $TT_INST_ROOT\n$basic"
399 if $TT_INST_ROOT;
400 $basic;
401 }
402
403 package main;
404
25a8d8e @abw *** empty log message ***
authored
405 my %opts = (
3ebfa07 @abw Initial revision
authored
406 'NAME' => 'Template',
407 'DISTNAME' => 'Template-Toolkit',
408 'VERSION_FROM' => 'lib/Template.pm',
409 'EXE_FILES' => [ 'bin/tpage', 'bin/ttree' ],
410 'PMLIBDIRS' => [ 'lib' ],
411 'PREREQ_PM' => { 'AppConfig' => 1.52 },
412 'dist' => {
413 'COMPRESS' => 'gzip',
414 'SUFFIX' => 'gz',
c8d76d4 @abw *** empty log message ***
authored
415 # 'PREOP' => build_docs(),
3ebfa07 @abw Initial revision
authored
416 },
417 );
418
25a8d8e @abw *** empty log message ***
authored
419 if ($ExtUtils::MakeMaker::VERSION >= 5.43) {
420 $opts{ AUTHOR } = 'Andy Wardley <abw@kfs.org>';
421 $opts{ ABSTRACT } =
422 'a fast, flexible and extensible template processing system',
423 }
424
c8d76d4 @abw *** empty log message ***
authored
425
25a8d8e @abw *** empty log message ***
authored
426 WriteMakefile( %opts );
427
82cbea8 @abw version 2.00
authored
428 print <<EOF;
429
430 Configuration complete. You should now run 'make', 'make test' and then
c8d76d4 @abw *** empty log message ***
authored
431 'make install'. See the README file for further information.
432 EOF
433
434 print <<EOF if $TT_BUILD_DOCS;
435
436 Please note that the installation of the optional components and
437 building of the HTML documentation is performed at the "make install"
438 stage as the effective user at that time. This implies that this user
439 must have sufficient permission to install into the specified
440 directory and that all created directories and files will be owned by
441 them.
82cbea8 @abw version 2.00
authored
442
443 EOF
25a8d8e @abw *** empty log message ***
authored
444
48634a1 @abw *** empty log message ***
authored
445 #========================================================================
446
447
448 #------------------------------------------------------------------------
449 # build_docs()
450 #
451 # Echo the relevant incantation so that 'make dist' regenerates the
452 # documentation from the template sources.
25a8d8e @abw *** empty log message ***
authored
453 #------------------------------------------------------------------------
eabb19e @abw *** empty log message ***
authored
454
3ebfa07 @abw Initial revision
authored
455 sub build_docs {
456 return <<EOF;
457 echo "Building documentation for version \$(VERSION)" ; \\
0b63aae @abw *** empty log message ***
authored
458 \$(PERL) bin/ttree -f ./docs/ttdist.cfg --define version=\$(VERSION) -a; \\
3ebfa07 @abw Initial revision
authored
459 EOF
460 }
461
48634a1 @abw *** empty log message ***
authored
462
463 #------------------------------------------------------------------------
82cbea8 @abw version 2.00
authored
464 # yep($text)
465 # nope($text)
466 #------------------------------------------------------------------------
467
468 sub yep {
469 print '[X] ', shift, "\n";
470 }
471
472 sub nope {
473 print '[ ] ', shift, "\n";
474 }
475
476
477 #------------------------------------------------------------------------
867f44f @abw rc2
authored
478 # check_taf()
479 #
480 # There are some problems with Text::Autoformat with version of Perl
481 # prior to 5.6.0 not working properly with locales that use a numerical
482 # separator other than '.' (e.g. Swedish)
483 #------------------------------------------------------------------------
484
485 sub check_taf {
486 use POSIX qw( localeconv );
487 my $loc = localeconv;
488 my $dec = $loc->{ decimal_point };
489
490 yep("version $Text::Autoformat::VERSION installed");
491
492 if ($] <= 5.006 && $dec ne '.') {
493 print ' ' x 6,
494 "NOTE: tests 23 and 25 may fail under your locale, see TODO file.\n";
495 }
496 }
497
498
499 #------------------------------------------------------------------------
acff212 @abw *** empty log message ***
authored
500 # check_dom()
501 #
867f44f @abw rc2
authored
502 # XML::DOM changed from HASH to ARRAY objects somewhere between versions
503 # 1.25 and 1.27, so the latter version is an absolute necessity.
60dfe44 @abw *** empty log message ***
authored
504 #------------------------------------------------------------------------
505
506 sub check_dom {
867f44f @abw rc2
authored
507 if ($XML::DOM::VERSION < 1.27) {
508 nope("requires version 1.27 or later ($XML::DOM::VERSION installed)");
60dfe44 @abw *** empty log message ***
authored
509 }
510 else {
82cbea8 @abw version 2.00
authored
511 yep("version $XML::DOM::VERSION installed");
60dfe44 @abw *** empty log message ***
authored
512 }
513 }
514
515
acff212 @abw *** empty log message ***
authored
516 #------------------------------------------------------------------------
517 # check_rss()
518 #
519 # Version 0.8 of XML::RSS gave warnings under Perl 5.6.0 so issue an
520 # upgrade recommendation
521 #------------------------------------------------------------------------
522
60dfe44 @abw *** empty log message ***
authored
523 sub check_rss {
82cbea8 @abw version 2.00
authored
524 if ($] >= 5.006 && $XML::RSS::VERSION < 0.9) {
525 nope("requires version 0.9 or later ($XML::RSS::VERSION installed)");
60dfe44 @abw *** empty log message ***
authored
526 }
527 else {
82cbea8 @abw version 2.00
authored
528 yep("version $XML::RSS::VERSION installed");
60dfe44 @abw *** empty log message ***
authored
529 }
530 }
531
acff212 @abw *** empty log message ***
authored
532 #------------------------------------------------------------------------
533 # check_xpath()
534 #
535 # Tests fail under some of the earlier versions (e.g. 0.55) so we issue
536 # an upgrade recommendation.
537 #------------------------------------------------------------------------
60dfe44 @abw *** empty log message ***
authored
538
539 sub check_xpath {
540 if ($XML::XPath::VERSION < 1.00) {
82cbea8 @abw version 2.00
authored
541 nope("requires version 1.00 or later ($XML::XPath::VERSION installed)");
60dfe44 @abw *** empty log message ***
authored
542 }
543 else {
82cbea8 @abw version 2.00
authored
544 yep("version $XML::XPath::VERSION installed");
60dfe44 @abw *** empty log message ***
authored
545 }
546 }
547
548
549 #------------------------------------------------------------------------
48634a1 @abw *** empty log message ***
authored
550 # dbi_config()
551 #
552 # Quiz the user for options related to running the DBI tests.
553 #------------------------------------------------------------------------
554
555 sub dbi_config {
556 my ($dsn, $user, $pass, $run);
557 $run = 1;
558
c8d76d4 @abw *** empty log message ***
authored
559 print "[X] version $DBI::VERSION installed, configuring tests\n\n";
48634a1 @abw *** empty log message ***
authored
560
c8d76d4 @abw *** empty log message ***
authored
561 if (prompt("Do you want to run the DBI tests?\n" .
562 "It requires access to an existing test database.",
48634a1 @abw *** empty log message ***
authored
563 "y") =~ /y/i) {
564
565 my ($driver, $dbname);
566 my @drivers = DBI->available_drivers();
567 local $" = ', ';
568
569 my $default = (grep(/m.?sql/i, @drivers))[0];
867f44f @abw rc2
authored
570
571 print <<EOF;
48634a1 @abw *** empty log message ***
authored
572
c8d76d4 @abw *** empty log message ***
authored
573 Please enter the driver name for the test database.
574 The DBD drivers installed on your system are
575
576 @drivers
867f44f @abw rc2
authored
577
578 EOF
48634a1 @abw *** empty log message ***
authored
579
580 while (! $driver) {
c8d76d4 @abw *** empty log message ***
authored
581 $driver = prompt("Enter driver name: ", $default);
582 print("! No such DBD driver\n"), undef $driver
48634a1 @abw *** empty log message ***
authored
583 unless grep(/^$driver$/, @drivers);
584 }
585
867f44f @abw rc2
authored
586 print <<EOF;
c8d76d4 @abw *** empty log message ***
authored
587
588 Now enter the data source (DSN) for the test database.
589 Many DBD drivers require only a database name (e.g. 'test') while
590 others may require an alternate format or additional parameters
591 (e.g. 'dbname=test'). Please consult your DBD documentation for
592 further details.
593
867f44f @abw rc2
authored
594 EOF
595
596 my $dbname_eg = $driver eq 'Pg' ? 'dbname=test' : 'test';
48634a1 @abw *** empty log message ***
authored
597 while (! $dbname) {
c8d76d4 @abw *** empty log message ***
authored
598 $dbname = prompt('Database name: ', $dbname_eg);
48634a1 @abw *** empty log message ***
authored
599 }
600
601 $dsn = "dbi:$driver:$dbname";
602
c8d76d4 @abw *** empty log message ***
authored
603 $user = prompt('Enter user name : ', '');
604 $pass = prompt('Enter password : ', '');
48634a1 @abw *** empty log message ***
authored
605
606 $user = '' unless defined $user;
607 $pass = '' unless defined $pass;
608 }
609 else {
610 $run = 0;
611 }
612
c8d76d4 @abw *** empty log message ***
authored
613 print "\nwriting $DBI_CONFIG_FILE\n";
48634a1 @abw *** empty log message ***
authored
614 open(CFGFILE, ">$DBI_CONFIG_FILE") || die "$DBI_CONFIG_FILE: $!\n";
615 print CFGFILE <<EOF;
616 \$run = $run;
617 \$dsn = '$dsn';
618 \$user = '$user';
619 \$pass = '$pass';
620 1;
621 EOF
622 close(CFGFILE);
623 }
624
c8d76d4 @abw *** empty log message ***
authored
625
626
627 #------------------------------------------------------------------------
628 # fix_file($file, $find, $fix)
629 #
630 # Fixes a variable definition in a file. e.g.
631 # fix_file('lib/Template/Config.pm', '$INSTDIR', '/usr/local/tt2')
632 #------------------------------------------------------------------------
633
634 sub fix_file {
635 my ($file, $find, $fix) = @_;
636 local *FP;
637 local $/ = undef;
638
639 # print "\nSetting $find in $file to '$fix'\n\n";
640 $find = quotemeta($find);
641
642 open(FP, "< $file") || die "$file: $!\n";
643 my $text = <FP>;
644 close(FP);
645
646 ($text =~ s/^(\s*${find}\s*=\s*)'.*?'/$1'$fix'/m)
647 || die "$find not found in $file\n";
648
649 open(FP, "> $file") || die "$file: $!\n";
650 print FP $text;
651 close(FP);
652 }
653
654
Something went wrong with that request. Please try again.