Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 227 lines (177 sloc) 6.536 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
48634a1 @abw *** empty log message ***
authored
27 There are some minor incompatabilities between version 1.* and 2.*
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
31 different location (i.e. perl Makefile.PL LIB=/other/path).
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
48 The Template Toolkit includes a number of plugin modules, some of which
49 interface to external Perl modules available from CPAN. All the plugins
50 will be installed regardless (so that they will work automatically if and
51 when you install the relevant modules) but the tests will be skipped for
52 plugins that require external modules not available on your system.
e39913f @abw *** empty log message ***
authored
53
54 EOF
48634a1 @abw *** empty log message ***
authored
55
60dfe44 @abw *** empty log message ***
authored
56 foreach my $mods ( [ XML::DOM => \&check_dom ],
57 [ XML::RSS => \&check_rss ],
58 [ XML::XPath => \&check_xpath ],
59 [ DBI => \&dbi_config ] ) {
60 my ($module, $code) = @$mods;
61
acff212 @abw *** empty log message ***
authored
62 printf(" %-12s - ", $module);
48634a1 @abw *** empty log message ***
authored
63 eval "use $module";
64 if ($@) {
acff212 @abw *** empty log message ***
authored
65 print "skipping test (module not installed)\n";
48634a1 @abw *** empty log message ***
authored
66 }
67 else {
60dfe44 @abw *** empty log message ***
authored
68 &$code;
48634a1 @abw *** empty log message ***
authored
69 }
e39913f @abw *** empty log message ***
authored
70 }
71
72
48634a1 @abw *** empty log message ***
authored
73 #------------------------------------------------------------------------
74 # build options and write Makefile
75 #------------------------------------------------------------------------
3ebfa07 @abw Initial revision
authored
76
25a8d8e @abw *** empty log message ***
authored
77 my %opts = (
3ebfa07 @abw Initial revision
authored
78 'NAME' => 'Template',
79 'DISTNAME' => 'Template-Toolkit',
80 'VERSION_FROM' => 'lib/Template.pm',
81 'EXE_FILES' => [ 'bin/tpage', 'bin/ttree' ],
82 'PMLIBDIRS' => [ 'lib' ],
83 'PREREQ_PM' => { 'AppConfig' => 1.52 },
84 'dist' => {
85 'COMPRESS' => 'gzip',
86 'SUFFIX' => 'gz',
87 'PREOP' => build_docs(),
88 },
89 );
90
25a8d8e @abw *** empty log message ***
authored
91 if ($ExtUtils::MakeMaker::VERSION >= 5.43) {
92 $opts{ AUTHOR } = 'Andy Wardley <abw@kfs.org>';
93 $opts{ ABSTRACT } =
94 'a fast, flexible and extensible template processing system',
95 }
96
97 WriteMakefile( %opts );
98
99
48634a1 @abw *** empty log message ***
authored
100 #========================================================================
101
102
103 #------------------------------------------------------------------------
104 # build_docs()
105 #
106 # Echo the relevant incantation so that 'make dist' regenerates the
107 # documentation from the template sources.
25a8d8e @abw *** empty log message ***
authored
108 #------------------------------------------------------------------------
eabb19e @abw *** empty log message ***
authored
109
3ebfa07 @abw Initial revision
authored
110 sub build_docs {
111 return <<EOF;
112 echo "Building documentation for version \$(VERSION)" ; \\
0b63aae @abw *** empty log message ***
authored
113 \$(PERL) bin/ttree -f ./docs/ttdist.cfg --define version=\$(VERSION) -a; \\
3ebfa07 @abw Initial revision
authored
114 EOF
115 }
116
48634a1 @abw *** empty log message ***
authored
117
118 #------------------------------------------------------------------------
acff212 @abw *** empty log message ***
authored
119 # check_dom()
120 #
121 # XML::DOM version 1.25 (and earlier?) dump core with Perl 5.6.0
60dfe44 @abw *** empty log message ***
authored
122 #------------------------------------------------------------------------
123
124 sub check_dom {
125 if ($] == 5.006 && $XML::DOM::VERSION <= 1.25) {
acff212 @abw *** empty log message ***
authored
126 print "version $XML::DOM::VERSION may not work with Perl $], skipping\n";
60dfe44 @abw *** empty log message ***
authored
127 }
128 else {
acff212 @abw *** empty log message ***
authored
129 print "version $XML::DOM::VERSION installed, including tests\n";
60dfe44 @abw *** empty log message ***
authored
130 }
131 }
132
133
acff212 @abw *** empty log message ***
authored
134 #------------------------------------------------------------------------
135 # check_rss()
136 #
137 # Version 0.8 of XML::RSS gave warnings under Perl 5.6.0 so issue an
138 # upgrade recommendation
139 #------------------------------------------------------------------------
140
60dfe44 @abw *** empty log message ***
authored
141 sub check_rss {
acff212 @abw *** empty log message ***
authored
142 if ($] == 5.006 && $XML::RSS::VERSION < 0.9) {
143 print "please upgrade to version 0.9 or later ($XML::RSS::VERSION installed)\n";
60dfe44 @abw *** empty log message ***
authored
144 }
145 else {
acff212 @abw *** empty log message ***
authored
146 print "version $XML::RSS::VERSION installed, including tests\n";
60dfe44 @abw *** empty log message ***
authored
147 }
148 }
149
acff212 @abw *** empty log message ***
authored
150 #------------------------------------------------------------------------
151 # check_xpath()
152 #
153 # Tests fail under some of the earlier versions (e.g. 0.55) so we issue
154 # an upgrade recommendation.
155 #------------------------------------------------------------------------
60dfe44 @abw *** empty log message ***
authored
156
157 sub check_xpath {
158 if ($XML::XPath::VERSION < 1.00) {
acff212 @abw *** empty log message ***
authored
159 print "please upgrade to version 1.00 or later ($XML::XPath::VERSION installed)\n";
60dfe44 @abw *** empty log message ***
authored
160 }
161 else {
acff212 @abw *** empty log message ***
authored
162 print "version $XML::XPath::VERSION installed, including tests\n";
60dfe44 @abw *** empty log message ***
authored
163 }
164 }
165
166
167 #------------------------------------------------------------------------
48634a1 @abw *** empty log message ***
authored
168 # dbi_config()
169 #
170 # Quiz the user for options related to running the DBI tests.
171 #------------------------------------------------------------------------
172
173 sub dbi_config {
174 my ($dsn, $user, $pass, $run);
175 $run = 1;
176
acff212 @abw *** empty log message ***
authored
177 print "version $DBI::VERSION installed, configuring tests\n";
48634a1 @abw *** empty log message ***
authored
178
179 if (prompt("- Do you want to run the DBI tests?\n" .
180 " It requires access to an existing test database.",
181 "y") =~ /y/i) {
182
183 my ($driver, $dbname);
184 my @drivers = DBI->available_drivers();
185 local $" = ', ';
186
187 my $default = (grep(/m.?sql/i, @drivers))[0];
188
189 print "- Please enter the driver name for the test database.\n";
190 print " The DBD drivers installed on your system are\n\n";
191 print " @drivers\n\n";
192
193 while (! $driver) {
194 $driver = prompt("- Enter driver name: ", $default);
195 print("! No such DBD driver\n"), undef $driver
196 unless grep(/^$driver$/, @drivers);
197 }
198
199 while (! $dbname) {
200 $dbname = prompt('- Enter database name: ', 'test');
201 }
202
203 $dsn = "dbi:$driver:$dbname";
204
205 $user = prompt('- Enter user name : ', '');
206 $pass = prompt('- Enter password : ', '');
207
208 $user = '' unless defined $user;
209 $pass = '' unless defined $pass;
210 }
211 else {
212 $run = 0;
213 }
214
215 print "- writing $DBI_CONFIG_FILE\n";
216 open(CFGFILE, ">$DBI_CONFIG_FILE") || die "$DBI_CONFIG_FILE: $!\n";
217 print CFGFILE <<EOF;
218 \$run = $run;
219 \$dsn = '$dsn';
220 \$user = '$user';
221 \$pass = '$pass';
222 1;
223 EOF
224 close(CFGFILE);
225 }
226
Something went wrong with that request. Please try again.