Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 291 lines (227 sloc) 8.134 kb
49d1e32 @abw *** empty log message ***
authored
1 use ExtUtils::MakeMaker; # -*-perl-*-
3ebfa07 @abw Initial revision
authored
2
e39913f @abw *** empty log message ***
authored
3 select STDERR;
4 $| = 1;
5 select STDOUT;
6
48634a1 @abw *** empty log message ***
authored
7 my $DBI_CONFIG_FILE = 't/dbi_test.cfg';
d52480d @abw *** empty log message ***
authored
8
48634a1 @abw *** empty log message ***
authored
9 print <<EOF;
c542301 @abw *** empty log message ***
authored
10
11 Template Toolkit Version 2.00
12 =============================
48634a1 @abw *** empty log message ***
authored
13 EOF
14
15 #------------------------------------------------------------------------
16 # check for pre-version 2.00 installation and issue warning
17 #------------------------------------------------------------------------
18
19 eval "use Template";
20 unless ($@ or $Template::VERSION =~ /^2/) {
21 warn(<<EOF);
22
c542301 @abw *** empty log message ***
authored
23 IMPORTANT NOTE:
24 ---------------
48634a1 @abw *** empty log message ***
authored
25 You have version $Template::VERSION of the Template Toolkit installed.
25a8d8e @abw *** empty log message ***
authored
26
82cbea8 @abw version 2.00
authored
27 There are some minor incompatabilities between version 1 and 2
48634a1 @abw *** empty log message ***
authored
28 of the Template Toolkit which you should be aware of. Installing
29 this version will overwrite your version $Template::VERSION files
30 unless you take measures to install one or the other version in a
82cbea8 @abw version 2.00
authored
31 different location (i.e. perl Makefile.PL PREFIX=/other/path).
48634a1 @abw *** empty log message ***
authored
32
33 Please consult the README and Changes file for further details.
34 Most of the changes are in the more obscure features and
35 directives so hopefully you will find the upgrade process fairly
36 painless.
25a8d8e @abw *** empty log message ***
authored
37
38 EOF
48634a1 @abw *** empty log message ***
authored
39 exit unless prompt("Do you want to continue?", 'y') =~ /y/i;
40 }
41
42 #------------------------------------------------------------------------
43 # detect additional modules required by plugins (just for fun)
44 #------------------------------------------------------------------------
25a8d8e @abw *** empty log message ***
authored
45
48634a1 @abw *** empty log message ***
authored
46 print <<EOF;
47
82cbea8 @abw version 2.00
authored
48 The Template Toolkit includes a number of plugin modules, some of
49 which interface to external Perl modules available from CPAN. All the
50 plugins will be installed regardless so that they will automatically
51 work as and when you install the relevant modules. The tests will be
52 skipped for plugins that require external modules not currently
53 available on your system.
e39913f @abw *** empty log message ***
authored
54
55 EOF
48634a1 @abw *** empty log message ***
authored
56
867f44f @abw rc2
authored
57 foreach my $mods ( [ Text::Autoformat => \&check_taf ],
82cbea8 @abw version 2.00
authored
58 [ XML::DOM => \&check_dom ],
60dfe44 @abw *** empty log message ***
authored
59 [ XML::RSS => \&check_rss ],
60 [ XML::XPath => \&check_xpath ],
61 [ DBI => \&dbi_config ] ) {
82cbea8 @abw version 2.00
authored
62 my ($module, $code) = ref $mods ? @$mods : ($mods, 0);
60dfe44 @abw *** empty log message ***
authored
63
82cbea8 @abw version 2.00
authored
64 printf(" %-16s ", $module);
48634a1 @abw *** empty log message ***
authored
65 eval "use $module";
66 if ($@) {
82cbea8 @abw version 2.00
authored
67 nope("module not installed");
48634a1 @abw *** empty log message ***
authored
68 }
82cbea8 @abw version 2.00
authored
69 elsif ($code) {
60dfe44 @abw *** empty log message ***
authored
70 &$code;
48634a1 @abw *** empty log message ***
authored
71 }
82cbea8 @abw version 2.00
authored
72 else {
73 no strict qw( refs );
74 my $ver = ${"$module\::VERSION"};
75 yep("version $ver installed");
76 }
e39913f @abw *** empty log message ***
authored
77 }
78
82cbea8 @abw version 2.00
authored
79 print "\n";
e39913f @abw *** empty log message ***
authored
80
48634a1 @abw *** empty log message ***
authored
81 #------------------------------------------------------------------------
82 # build options and write Makefile
83 #------------------------------------------------------------------------
3ebfa07 @abw Initial revision
authored
84
25a8d8e @abw *** empty log message ***
authored
85 my %opts = (
3ebfa07 @abw Initial revision
authored
86 'NAME' => 'Template',
87 'DISTNAME' => 'Template-Toolkit',
88 'VERSION_FROM' => 'lib/Template.pm',
89 'EXE_FILES' => [ 'bin/tpage', 'bin/ttree' ],
90 'PMLIBDIRS' => [ 'lib' ],
91 'PREREQ_PM' => { 'AppConfig' => 1.52 },
92 'dist' => {
93 'COMPRESS' => 'gzip',
94 'SUFFIX' => 'gz',
95 'PREOP' => build_docs(),
96 },
97 );
98
25a8d8e @abw *** empty log message ***
authored
99 if ($ExtUtils::MakeMaker::VERSION >= 5.43) {
100 $opts{ AUTHOR } = 'Andy Wardley <abw@kfs.org>';
101 $opts{ ABSTRACT } =
102 'a fast, flexible and extensible template processing system',
103 }
104
105 WriteMakefile( %opts );
106
82cbea8 @abw version 2.00
authored
107 print <<EOF;
108
109 Configuration complete. You should now run 'make', 'make test' and then
110 'make install'. Please don't forget to read the README file.
111
112 EOF
25a8d8e @abw *** empty log message ***
authored
113
48634a1 @abw *** empty log message ***
authored
114 #========================================================================
115
116
117 #------------------------------------------------------------------------
118 # build_docs()
119 #
120 # Echo the relevant incantation so that 'make dist' regenerates the
121 # documentation from the template sources.
25a8d8e @abw *** empty log message ***
authored
122 #------------------------------------------------------------------------
eabb19e @abw *** empty log message ***
authored
123
3ebfa07 @abw Initial revision
authored
124 sub build_docs {
125 return <<EOF;
126 echo "Building documentation for version \$(VERSION)" ; \\
0b63aae @abw *** empty log message ***
authored
127 \$(PERL) bin/ttree -f ./docs/ttdist.cfg --define version=\$(VERSION) -a; \\
3ebfa07 @abw Initial revision
authored
128 EOF
129 }
130
48634a1 @abw *** empty log message ***
authored
131
132 #------------------------------------------------------------------------
82cbea8 @abw version 2.00
authored
133 # yep($text)
134 # nope($text)
135 #------------------------------------------------------------------------
136
137 sub yep {
138 print '[X] ', shift, "\n";
139 }
140
141 sub nope {
142 print '[ ] ', shift, "\n";
143 }
144
145
146 #------------------------------------------------------------------------
867f44f @abw rc2
authored
147 # check_taf()
148 #
149 # There are some problems with Text::Autoformat with version of Perl
150 # prior to 5.6.0 not working properly with locales that use a numerical
151 # separator other than '.' (e.g. Swedish)
152 #------------------------------------------------------------------------
153
154 sub check_taf {
155 use POSIX qw( localeconv );
156 my $loc = localeconv;
157 my $dec = $loc->{ decimal_point };
158
159 yep("version $Text::Autoformat::VERSION installed");
160
161 if ($] <= 5.006 && $dec ne '.') {
162 print ' ' x 6,
163 "NOTE: tests 23 and 25 may fail under your locale, see TODO file.\n";
164 }
165 }
166
167
168 #------------------------------------------------------------------------
acff212 @abw *** empty log message ***
authored
169 # check_dom()
170 #
867f44f @abw rc2
authored
171 # XML::DOM changed from HASH to ARRAY objects somewhere between versions
172 # 1.25 and 1.27, so the latter version is an absolute necessity.
60dfe44 @abw *** empty log message ***
authored
173 #------------------------------------------------------------------------
174
175 sub check_dom {
867f44f @abw rc2
authored
176 if ($XML::DOM::VERSION < 1.27) {
177 nope("requires version 1.27 or later ($XML::DOM::VERSION installed)");
60dfe44 @abw *** empty log message ***
authored
178 }
179 else {
82cbea8 @abw version 2.00
authored
180 yep("version $XML::DOM::VERSION installed");
60dfe44 @abw *** empty log message ***
authored
181 }
182 }
183
184
acff212 @abw *** empty log message ***
authored
185 #------------------------------------------------------------------------
186 # check_rss()
187 #
188 # Version 0.8 of XML::RSS gave warnings under Perl 5.6.0 so issue an
189 # upgrade recommendation
190 #------------------------------------------------------------------------
191
60dfe44 @abw *** empty log message ***
authored
192 sub check_rss {
82cbea8 @abw version 2.00
authored
193 if ($] >= 5.006 && $XML::RSS::VERSION < 0.9) {
194 nope("requires version 0.9 or later ($XML::RSS::VERSION installed)");
60dfe44 @abw *** empty log message ***
authored
195 }
196 else {
82cbea8 @abw version 2.00
authored
197 yep("version $XML::RSS::VERSION installed");
60dfe44 @abw *** empty log message ***
authored
198 }
199 }
200
acff212 @abw *** empty log message ***
authored
201 #------------------------------------------------------------------------
202 # check_xpath()
203 #
204 # Tests fail under some of the earlier versions (e.g. 0.55) so we issue
205 # an upgrade recommendation.
206 #------------------------------------------------------------------------
60dfe44 @abw *** empty log message ***
authored
207
208 sub check_xpath {
209 if ($XML::XPath::VERSION < 1.00) {
82cbea8 @abw version 2.00
authored
210 nope("requires version 1.00 or later ($XML::XPath::VERSION installed)");
60dfe44 @abw *** empty log message ***
authored
211 }
212 else {
82cbea8 @abw version 2.00
authored
213 yep("version $XML::XPath::VERSION installed");
60dfe44 @abw *** empty log message ***
authored
214 }
215 }
216
217
218 #------------------------------------------------------------------------
48634a1 @abw *** empty log message ***
authored
219 # dbi_config()
220 #
221 # Quiz the user for options related to running the DBI tests.
222 #------------------------------------------------------------------------
223
224 sub dbi_config {
225 my ($dsn, $user, $pass, $run);
226 $run = 1;
227
82cbea8 @abw version 2.00
authored
228 print "[X] version $DBI::VERSION installed, configuring tests\n";
48634a1 @abw *** empty log message ***
authored
229
82cbea8 @abw version 2.00
authored
230 if (prompt(" - Do you want to run the DBI tests?\n" .
231 " It requires access to an existing test database.",
48634a1 @abw *** empty log message ***
authored
232 "y") =~ /y/i) {
233
234 my ($driver, $dbname);
235 my @drivers = DBI->available_drivers();
236 local $" = ', ';
237
238 my $default = (grep(/m.?sql/i, @drivers))[0];
867f44f @abw rc2
authored
239
240 print <<EOF;
241 - Please enter the driver name for the test database.
242 The DBD drivers installed on your system are
48634a1 @abw *** empty log message ***
authored
243
867f44f @abw rc2
authored
244 @drivers
245
246 EOF
48634a1 @abw *** empty log message ***
authored
247
248 while (! $driver) {
82cbea8 @abw version 2.00
authored
249 $driver = prompt(" - Enter driver name: ", $default);
250 print(" No such DBD driver\n"), undef $driver
48634a1 @abw *** empty log message ***
authored
251 unless grep(/^$driver$/, @drivers);
252 }
253
867f44f @abw rc2
authored
254 print <<EOF;
255 - Please enter the data source (DSN) of the test database.
256 Many DBD drivers require only a database name (e.g. 'test') while
257 others may require an alternate format or additional parameters
258 (e.g. 'dbname=test'). Please consult your DBD documentation for
259 further details.
260 EOF
261
262 my $dbname_eg = $driver eq 'Pg' ? 'dbname=test' : 'test';
48634a1 @abw *** empty log message ***
authored
263 while (! $dbname) {
867f44f @abw rc2
authored
264 $dbname = prompt(' - Database name: ', $dbname_eg);
48634a1 @abw *** empty log message ***
authored
265 }
266
267 $dsn = "dbi:$driver:$dbname";
268
82cbea8 @abw version 2.00
authored
269 $user = prompt(' - Enter user name : ', '');
270 $pass = prompt(' - Enter password : ', '');
48634a1 @abw *** empty log message ***
authored
271
272 $user = '' unless defined $user;
273 $pass = '' unless defined $pass;
274 }
275 else {
276 $run = 0;
277 }
278
82cbea8 @abw version 2.00
authored
279 print " - writing $DBI_CONFIG_FILE\n";
48634a1 @abw *** empty log message ***
authored
280 open(CFGFILE, ">$DBI_CONFIG_FILE") || die "$DBI_CONFIG_FILE: $!\n";
281 print CFGFILE <<EOF;
282 \$run = $run;
283 \$dsn = '$dsn';
284 \$user = '$user';
285 \$pass = '$pass';
286 1;
287 EOF
288 close(CFGFILE);
289 }
290
Something went wrong with that request. Please try again.