This commit was generated by cvs2svn to compensate for changes in r2526,
[freeside.git] / rt / tools / testdeps
1 #!/usr/bin/perl -w
2
3 # $Header: /home/cvs/cvsroot/freeside/rt/tools/Attic/testdeps,v 1.1 2002-08-12 06:17:08 ivan Exp $
4
5 # Copyright 2000 Jesse Vincent <jesse@fsck.com>
6 # Distributed under the GNU General Public License
7
8
9 #
10 # This is just a basic script that checks to make sure that all
11 # the modules needed by RT before you can install it.
12 #
13
14 use strict;
15
16 use vars qw($mode $dbd $module @modules);
17
18 $mode = shift || print_help();
19 $dbd = shift || print_help();
20
21 @modules = qw(
22 Digest::MD5
23 Storable
24 DBI 1.18
25 DBIx::DataSource 0.02
26 DBIx::SearchBuilder 0.48
27 HTML::Entities 
28 MLDBM
29 Net::Domain
30 Net::SMTP
31 Params::Validate 0.02
32 HTML::Mason 1.02
33 CGI::Cookie 1.20
34 Apache::Cookie
35 Apache::Session 1.53
36 Date::Parse
37 Date::Format 
38 MIME::Entity 5.108
39 Mail::Mailer 1.20
40 Getopt::Long 2.24
41 Tie::IxHash 
42 Text::Wrapper 
43 Text::Template
44 File::Spec 0.8
45 Errno
46 FreezeThaw
47 File::Temp 
48 Log::Dispatch 1.6
49 );
50
51
52 if ($dbd =~ /mysql/i) {
53         push @modules, ('DBD::mysql','2.0416'); 
54 }
55 elsif ($dbd =~ /oracle/i) {
56         push @modules, ('DBD::Oracle','');
57 }
58 elsif ($dbd =~ /pg/i) {
59         push @modules, ('DBD::Pg','');
60 }
61 use CPAN;
62
63 while ($module= shift @modules) {
64         my $version = "";
65         $version = " ". shift (@modules) . " " if ($modules[0] =~ /^([\d\.]*)$/);
66         print "Checking for $module$version";
67         eval "use $module$version" ;
68         if ($@) {
69         &resolve_dependency($module, $version) 
70         }
71         else {
72         print "...found\n";
73         }
74 }
75
76 sub print_help {
77 print <<EOF;
78
79 $0 FLAG DBTYPE
80
81
82 $0 is a tool for RT that will tell you if you've got all
83 the modules RT depends on properly installed.
84
85 Flags: (only one flag is valid for a given run)
86
87 -quiet will check to see if we've got everything we need
88         and will exit with a return code of (1) if we don't.
89
90 -warn will tell you what isn't properly installed
91
92 -fix will use CPAN to magically make everything better
93
94 DBTYPE is one of:
95         oracle, pg, mysql
96
97 EOF
98
99 exit(0);
100 }
101
102 sub resolve_dependency {
103         my $module = shift;
104         my $version = shift;
105         print "....$module$version not installed.";
106     if ($mode =~ /-f/) {
107         $module = "DBD::mysql::Install" if ($module =~ /DBD::mysql/);
108         
109         print "Installing with CPAN...";
110         CPAN::install($module);
111      }
112      print "\n";
113         exit(1) if ($mode =~ /-q/);
114 }       
115