remove autogenerated file
[freeside.git] / rt / sbin / rt-test-dependencies
1 #!/usr/bin/perl
2 # BEGIN LICENSE BLOCK
3
4 # Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
5
6 # (Except where explictly superceded by other copyright notices)
7
8 # This work is made available to you under the terms of Version 2 of
9 # the GNU General Public License. A copy of that license should have
10 # been provided with this software, but in any event can be snarfed
11 # from www.gnu.org.
12
13 # This work is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 # General Public License for more details.
17
18 # Unless otherwise specified, all modifications, corrections or
19 # extensions to this work which alter its source code become the
20 # property of Best Practical Solutions, LLC when submitted for
21 # inclusion in the work.
22
23
24 # END LICENSE BLOCK
25
26 #
27 # This is just a basic script that checks to make sure that all
28 # the modules needed by RT before you can install it.
29 #
30
31 use strict;
32 no warnings qw(numeric redefine);
33 use Getopt::Long;
34 use CPAN;
35 my %args;
36 my %deps;
37 GetOptions(\%args,'install', 'with-MYSQL', 'with-POSTGRESQL|with-pg|with-pgsql', 'with-SQLITE', 'with-ORACLE', 'with-FASTCGI', 'with-SPEEDYCGI', 'with-MODPERL1', 'with-MODPERL2' ,'with-DEV');
38
39 if (!keys %args) {
40     help();
41     exit(0);
42 }
43 if ($args{'with-MODPERL2'}) {
44     warn_modperl2();
45 }
46
47 $args{'with-MASON'} = 1;
48 $args{'with-CORE'} = 1;
49 $args{'with-DEV'} =1; 
50 $args{'with-CLI'} =1; 
51 $args{'with-MAILGATE'} =1; 
52 if ($] < 5.007) {
53 $args{'with-I18N-COMPAT'} = 1;
54 }
55
56 sub warn_modperl2 {
57     print <<'.';
58         NOTE: mod_perl 2.0 isn't quite ready for prime_time just yet;
59         Best Practical Solutions strongly recommends that sites use
60         Apache 1.3 or FastCGI. If you MUST use mod_perl 2.0 (or 1.99),
61         please read the mailing list archives before asking for help.
62 .
63     sleep 5;
64 }
65
66
67 sub help {
68
69     print <<'.';
70
71 By default, testdeps determine whether you have 
72 installed all the perl modules RT needs to run.
73
74         --install               Install missing modules
75
76 The following switches will tell the tool to check for specific dependencies
77
78         --with-mysql            Database interface for MySQL
79         --with-postgresql       Database interface for PostgreSQL 
80         --with-sqlite           Database interface and driver for SQLite (unsupported)
81         --with-oracle           Database interface for oracle (unsupported)
82
83         --with-fastcgi          Libraries needed to support the fastcgi handler
84         --with-speedycgi        Libraries needed to support the speedycgi handler
85         --with-modperl1         Libraries needed to support the modperl 1 handler
86         --with-modperl2         Libraries needed to support the modperl 2 handler
87
88         --with-dev              Tools needed for RT development
89 .
90 }
91
92
93 sub _ {
94     map { /(\S+)\s*(\S*)/; $1 => ($2 ? $2 :'') } split ( /\n/, $_[0] );
95 }
96
97 $deps{'CORE'} = [ _( << '.') ];
98 Digest::MD5 2.27
99 DBI 1.37
100 Test::Inline
101 Class::ReturnValue 0.40
102 DBIx::SearchBuilder 1.01
103 Text::Template
104 File::Spec 0.8
105 HTML::Entities 
106 Net::Domain
107 Log::Dispatch 2.0
108 Locale::Maketext 1.06
109 Locale::Maketext::Lexicon 0.32
110 Locale::Maketext::Fuzzy
111 MIME::Entity 5.108
112 Mail::Mailer 1.57
113 Net::SMTP
114 Text::Wrapper 
115 Time::ParseDate
116 File::Temp
117 Term::ReadKey
118 Text::Autoformat
119 Text::Quoted 1.3
120 Scalar::Util
121 .
122
123 $deps{'MASON'} = [ _( << '.') ];
124 Params::Validate 0.02
125 Cache::Cache
126 Exception::Class
127 HTML::Mason 1.16
128 MLDBM
129 Errno
130 FreezeThaw
131 Digest::MD5 2.27
132 CGI::Cookie 1.20
133 Storable 2.08
134 Apache::Session 1.53
135 .
136
137 $deps{'MAILGATE'} = [ _( << '.') ];
138 HTML::TreeBuilder
139 HTML::FormatText
140 Getopt::Long
141 LWP::UserAgent
142 .
143
144 $deps{'CLI'} = [ _( << '.') ];
145 Getopt::Long 2.24
146 .
147
148 $deps{'DEV'} = [ _( << '.') ];
149 Regexp::Common
150 Time::HiRes 
151 Test::Inline 
152 WWW::Mechanize
153 .
154
155 $deps{'FASTCGI'} = [ _( << '.') ];
156 CGI 2.92
157 FCGI
158 CGI::Fast 
159 .
160
161 $deps{'SPEEDYCGI'} = [ _( << '.') ];
162 CGI 2.92
163 CGI::SpeedyCGI
164 .
165
166
167 $deps{'MODPERL1'} = [ _( << '.') ];
168 CGI 2.92
169 Apache::Request
170 Apache::DBI 0.92
171 .
172
173 $deps{'MODPERL2'} = [ _( << '.') ];
174 CGI 2.92
175 Apache::DBI
176 .
177
178 $deps{'I18N-COMPAT'} = [ _( << '.') ];
179 Text::Iconv
180 Encode::compat 0.04
181 .
182
183 $deps{'MYSQL'} = [ _( << '.') ];
184 DBD::mysql 2.1018
185 .
186 $deps{'ORACLE'} = [ _( << '.') ];
187 DBD::Oracle
188 .
189 $deps{'POSTGRESQL'} = [ _( << '.') ];
190 DBD::Pg
191 .
192
193 print "perl:\n";
194 print "\t5.8.3";
195 eval {require 5.008003};
196 if ($@) {
197 print "...MISSING.\n";
198         eval {require 5.008000};
199         if ($@) {
200             print "\nRT is known to be non-functional on versions of perl older than 5.8.3.\nPlease upgrade to 5.8.3 or newer\n\n";
201             die;
202         } 
203
204         eval {require 5.008003};
205         if ($@) {
206             print "\nRT is known to be non-functional on versions of perl older than 5.8.3.\nPlease upgrade to 5.8.3 or newer\n\n";
207         }
208 } else {
209         print "...found\n";
210
211 }
212
213
214 foreach my $type (keys %args)  {
215 next unless ($type =~ /^with-(.*?)$/);
216 my $type = $1;
217 print "$type dependencies:\n";
218         my @deps = (@{$deps{$type}});
219         while (@deps) {
220                 my $module = shift @deps;
221                 my $version = shift @deps;
222 my $ret;
223         $ret =test_dep($module, $version);      
224
225 if ($args{'install'} && !$ret) {
226         resolve_dep($module);           
227 }
228 }
229 }
230 sub test_dep {
231         my $module = shift;
232         my $version = shift;
233
234         print "\t$module $version";
235         eval "use $module $version" ;
236         if ($@) {
237                 my $error = $@;
238                 $error =~ s/\n(.*)$//s;
239                 print "...MISSING\n";
240                         print "\t\t$error\n" if $error =~ /this is only/;
241
242                 return undef;
243         } else {
244                 print "...found\n";
245 return 1;
246         }
247 }
248
249 sub resolve_dep {
250         my $module = shift;
251         use CPAN;
252         CPAN::Shell->install($module);          
253         
254 }
255
256
257 sub print_help {
258     print << "EOF";
259
260 $0 FLAG DBTYPE
261
262
263 $0 is a tool for RT that will tell you if you've got all
264 the modules RT depends on properly installed.
265
266 Flags: (only one flag is valid for a given run)
267
268 -quiet will check to see if we've got everything we need
269         and will exit with a return code of (1) if we don't.
270
271 -warn will tell you what isn't properly installed
272
273 -fix will use CPANPLUS.pm or CPAN.pm to magically make everything better
274
275 DBTYPE is one of:
276         oracle, pg, mysql
277
278 EOF
279
280     exit(0);
281 }