Skip to content

HTTPS clone URL

Subversion checkout URL

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