Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 256 lines (200 sloc) 7.062 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
82cbea8 @abw version 2.00
authored
57 foreach my $mods ( Text::Wrap,
58 Text::Autoformat,
59 [ XML::DOM => \&check_dom ],
60dfe44 @abw *** empty log message ***
authored
60 [ XML::RSS => \&check_rss ],
61 [ XML::XPath => \&check_xpath ],
62 [ DBI => \&dbi_config ] ) {
82cbea8 @abw version 2.00
authored
63 my ($module, $code) = ref $mods ? @$mods : ($mods, 0);
60dfe44 @abw *** empty log message ***
authored
64
82cbea8 @abw version 2.00
authored
65 printf(" %-16s ", $module);
48634a1 @abw *** empty log message ***
authored
66 eval "use $module";
67 if ($@) {
82cbea8 @abw version 2.00
authored
68 nope("module not installed");
48634a1 @abw *** empty log message ***
authored
69 }
82cbea8 @abw version 2.00
authored
70 elsif ($code) {
60dfe44 @abw *** empty log message ***
authored
71 &$code;
48634a1 @abw *** empty log message ***
authored
72 }
82cbea8 @abw version 2.00
authored
73 else {
74 no strict qw( refs );
75 my $ver = ${"$module\::VERSION"};
76 yep("version $ver installed");
77 }
e39913f @abw *** empty log message ***
authored
78 }
79
82cbea8 @abw version 2.00
authored
80 print "\n";
e39913f @abw *** empty log message ***
authored
81
48634a1 @abw *** empty log message ***
authored
82 #------------------------------------------------------------------------
83 # build options and write Makefile
84 #------------------------------------------------------------------------
3ebfa07 @abw Initial revision
authored
85
25a8d8e @abw *** empty log message ***
authored
86 my %opts = (
3ebfa07 @abw Initial revision
authored
87 'NAME' => 'Template',
88 'DISTNAME' => 'Template-Toolkit',
89 'VERSION_FROM' => 'lib/Template.pm',
90 'EXE_FILES' => [ 'bin/tpage', 'bin/ttree' ],
91 'PMLIBDIRS' => [ 'lib' ],
92 'PREREQ_PM' => { 'AppConfig' => 1.52 },
93 'dist' => {
94 'COMPRESS' => 'gzip',
95 'SUFFIX' => 'gz',
96 'PREOP' => build_docs(),
97 },
98 );
99
25a8d8e @abw *** empty log message ***
authored
100 if ($ExtUtils::MakeMaker::VERSION >= 5.43) {
101 $opts{ AUTHOR } = 'Andy Wardley <abw@kfs.org>';
102 $opts{ ABSTRACT } =
103 'a fast, flexible and extensible template processing system',
104 }
105
106 WriteMakefile( %opts );
107
82cbea8 @abw version 2.00
authored
108 print <<EOF;
109
110 Configuration complete. You should now run 'make', 'make test' and then
111 'make install'. Please don't forget to read the README file.
112
113 EOF
25a8d8e @abw *** empty log message ***
authored
114
48634a1 @abw *** empty log message ***
authored
115 #========================================================================
116
117
118 #------------------------------------------------------------------------
119 # build_docs()
120 #
121 # Echo the relevant incantation so that 'make dist' regenerates the
122 # documentation from the template sources.
25a8d8e @abw *** empty log message ***
authored
123 #------------------------------------------------------------------------
eabb19e @abw *** empty log message ***
authored
124
3ebfa07 @abw Initial revision
authored
125 sub build_docs {
126 return <<EOF;
127 echo "Building documentation for version \$(VERSION)" ; \\
0b63aae @abw *** empty log message ***
authored
128 \$(PERL) bin/ttree -f ./docs/ttdist.cfg --define version=\$(VERSION) -a; \\
3ebfa07 @abw Initial revision
authored
129 EOF
130 }
131
48634a1 @abw *** empty log message ***
authored
132
133 #------------------------------------------------------------------------
82cbea8 @abw version 2.00
authored
134 # yep($text)
135 # nope($text)
136 #------------------------------------------------------------------------
137
138 sub yep {
139 print '[X] ', shift, "\n";
140 }
141
142 sub nope {
143 print '[ ] ', shift, "\n";
144 }
145
146
147 #------------------------------------------------------------------------
acff212 @abw *** empty log message ***
authored
148 # check_dom()
149 #
150 # XML::DOM version 1.25 (and earlier?) dump core with Perl 5.6.0
60dfe44 @abw *** empty log message ***
authored
151 #------------------------------------------------------------------------
152
153 sub check_dom {
82cbea8 @abw version 2.00
authored
154 if ($] >= 5.006 && $XML::DOM::VERSION <= 1.25) {
155 nope("version $XML::DOM::VERSION may not work with Perl $]");
60dfe44 @abw *** empty log message ***
authored
156 }
157 else {
82cbea8 @abw version 2.00
authored
158 yep("version $XML::DOM::VERSION installed");
60dfe44 @abw *** empty log message ***
authored
159 }
160 }
161
162
acff212 @abw *** empty log message ***
authored
163 #------------------------------------------------------------------------
164 # check_rss()
165 #
166 # Version 0.8 of XML::RSS gave warnings under Perl 5.6.0 so issue an
167 # upgrade recommendation
168 #------------------------------------------------------------------------
169
60dfe44 @abw *** empty log message ***
authored
170 sub check_rss {
82cbea8 @abw version 2.00
authored
171 if ($] >= 5.006 && $XML::RSS::VERSION < 0.9) {
172 nope("requires version 0.9 or later ($XML::RSS::VERSION installed)");
60dfe44 @abw *** empty log message ***
authored
173 }
174 else {
82cbea8 @abw version 2.00
authored
175 yep("version $XML::RSS::VERSION installed");
60dfe44 @abw *** empty log message ***
authored
176 }
177 }
178
acff212 @abw *** empty log message ***
authored
179 #------------------------------------------------------------------------
180 # check_xpath()
181 #
182 # Tests fail under some of the earlier versions (e.g. 0.55) so we issue
183 # an upgrade recommendation.
184 #------------------------------------------------------------------------
60dfe44 @abw *** empty log message ***
authored
185
186 sub check_xpath {
187 if ($XML::XPath::VERSION < 1.00) {
82cbea8 @abw version 2.00
authored
188 nope("requires version 1.00 or later ($XML::XPath::VERSION installed)");
60dfe44 @abw *** empty log message ***
authored
189 }
190 else {
82cbea8 @abw version 2.00
authored
191 yep("version $XML::XPath::VERSION installed");
60dfe44 @abw *** empty log message ***
authored
192 }
193 }
194
195
196 #------------------------------------------------------------------------
48634a1 @abw *** empty log message ***
authored
197 # dbi_config()
198 #
199 # Quiz the user for options related to running the DBI tests.
200 #------------------------------------------------------------------------
201
202 sub dbi_config {
203 my ($dsn, $user, $pass, $run);
204 $run = 1;
205
82cbea8 @abw version 2.00
authored
206 print "[X] version $DBI::VERSION installed, configuring tests\n";
48634a1 @abw *** empty log message ***
authored
207
82cbea8 @abw version 2.00
authored
208 if (prompt(" - Do you want to run the DBI tests?\n" .
209 " It requires access to an existing test database.",
48634a1 @abw *** empty log message ***
authored
210 "y") =~ /y/i) {
211
212 my ($driver, $dbname);
213 my @drivers = DBI->available_drivers();
214 local $" = ', ';
215
216 my $default = (grep(/m.?sql/i, @drivers))[0];
217
82cbea8 @abw version 2.00
authored
218 print " - Please enter the driver name for the test database.\n";
219 print " The DBD drivers installed on your system are\n\n";
48634a1 @abw *** empty log message ***
authored
220 print " @drivers\n\n";
221
222 while (! $driver) {
82cbea8 @abw version 2.00
authored
223 $driver = prompt(" - Enter driver name: ", $default);
224 print(" No such DBD driver\n"), undef $driver
48634a1 @abw *** empty log message ***
authored
225 unless grep(/^$driver$/, @drivers);
226 }
227
228 while (! $dbname) {
82cbea8 @abw version 2.00
authored
229 $dbname = prompt(' - Enter database name: ', 'test');
48634a1 @abw *** empty log message ***
authored
230 }
231
232 $dsn = "dbi:$driver:$dbname";
233
82cbea8 @abw version 2.00
authored
234 $user = prompt(' - Enter user name : ', '');
235 $pass = prompt(' - Enter password : ', '');
48634a1 @abw *** empty log message ***
authored
236
237 $user = '' unless defined $user;
238 $pass = '' unless defined $pass;
239 }
240 else {
241 $run = 0;
242 }
243
82cbea8 @abw version 2.00
authored
244 print " - writing $DBI_CONFIG_FILE\n";
48634a1 @abw *** empty log message ***
authored
245 open(CFGFILE, ">$DBI_CONFIG_FILE") || die "$DBI_CONFIG_FILE: $!\n";
246 print CFGFILE <<EOF;
247 \$run = $run;
248 \$dsn = '$dsn';
249 \$user = '$user';
250 \$pass = '$pass';
251 1;
252 EOF
253 close(CFGFILE);
254 }
255
Something went wrong with that request. Please try again.