2 # BEGIN BPS TAGGED BLOCK {{{
6 # This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC
7 # <jesse@bestpractical.com>
9 # (Except where explicitly superseded by other copyright notices)
14 # This work is made available to you under the terms of Version 2 of
15 # the GNU General Public License. A copy of that license should have
16 # been provided with this software, but in any event can be snarfed
19 # This work is distributed in the hope that it will be useful, but
20 # WITHOUT ANY WARRANTY; without even the implied warranty of
21 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 # General Public License for more details.
24 # You should have received a copy of the GNU General Public License
25 # along with this program; if not, write to the Free Software
26 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
27 # 02110-1301 or visit their web page on the internet at
28 # http://www.gnu.org/copyleft/gpl.html.
31 # CONTRIBUTION SUBMISSION POLICY:
33 # (The following paragraph is not intended to limit the rights granted
34 # to you to modify and distribute this software under the terms of
35 # the GNU General Public License and is only of importance to you if
36 # you choose to contribute your changes and enhancements to the
37 # community by submitting them to Best Practical Solutions, LLC.)
39 # By intentionally submitting any modifications, corrections or
40 # derivatives to this work, or any other work intended for use with
41 # Request Tracker, to Best Practical Solutions, LLC, you confirm that
42 # you are the copyright holder for those contributions and you grant
43 # Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
44 # royalty-free, perpetual, license to use, copy, create derivative
45 # works based on those contributions, and sublicense and distribute
46 # those contributions and any derivatives thereof.
48 # END BPS TAGGED BLOCK }}}
50 # This is just a basic script that checks to make sure that all
51 # the modules needed by RT before you can install it.
55 no warnings qw(numeric redefine);
61 'install', 'with-MYSQL',
62 'with-POSTGRESQL|with-pg|with-pgsql', 'with-SQLITE',
63 'with-ORACLE', 'with-FASTCGI',
64 'with-SPEEDYCGI', 'with-MODPERL1',
65 'with-MODPERL2', 'with-DEV',
81 'with-DEV' => @RT_DEVEL_MODE@,
82 'with-STANDALONE' => @RT_STANDALONE@,
84 $args{$_} = $default{$_} foreach grep !exists $args{$_}, keys %default;
89 my %always_show_sections = (
106 $any_missing = 1 unless $test;
107 if ($args{'v'} or not $test or $always_show_sections{$section}) {
109 print $test ? "found" : "MISSING";
113 print "\t\t$extra\n" if defined $extra;
118 print "\nSOMETHING WAS MISSING!\n";
120 print "\nEverything was found.\n";
129 By default, testdeps determine whether you have
130 installed all the perl modules RT needs to run.
132 --install Install missing modules
134 The following switches will tell the tool to check for specific dependencies
136 --with-mysql Database interface for MySQL
137 --with-postgresql Database interface for PostgreSQL
138 --with-sqlite Database interface and driver for SQLite (unsupported)
139 --with-oracle Database interface for oracle (unsupported)
141 --with-standalone Libraries needed to support the standalone simple pure perl server
142 --with-fastcgi Libraries needed to support the fastcgi handler
143 --with-speedycgi Libraries needed to support the speedycgi handler
144 --with-modperl1 Libraries needed to support the modperl 1 handler
145 --with-modperl2 Libraries needed to support the modperl 2 handler
147 --with-dev Tools needed for RT development
149 You can also specify -v or --verbose to list the status of all dependencies,
150 rather than just the missing ones.
152 The "RT_FIX_DEPS_CMD" environment variable, if set, will be used
153 instead of the standard CPAN shell by --install to install any
154 required modules. It will be called with the module name, or, if
155 "RT_FIX_DEPS_CMD" contains a "%s", will replace the "%s" with the
156 module name before calling the program.
163 for my $line ( split /\n/, $_[0] ) {
164 my($key, $value) = $line =~ /(\S+)\s*(\S*)/;
166 $hash{$key} = $value;
172 $deps{'CORE'} = [ text_to_hash( << '.') ];
176 Class::ReturnValue 0.40
178 DBIx::SearchBuilder 1.50
184 Locale::Maketext 1.06
185 Locale::Maketext::Lexicon 0.32
186 Locale::Maketext::Fuzzy
199 Module::Versions::Report 1.03
200 Cache::Simple::TimedExpiry
206 $deps{'MASON'} = [ text_to_hash( << '.') ];
217 Text::WikiFormat 0.76
221 $deps{'STANDALONE'} = [ text_to_hash( << '.') ];
222 HTTP::Server::Simple 0.07
223 HTTP::Server::Simple::Mason 0.09
226 $deps{'MAILGATE'} = [ text_to_hash( << '.') ];
234 $deps{'CLI'} = [ text_to_hash( << '.') ];
237 HTTP::Request::Common
243 $deps{'DEV'} = [ text_to_hash( << '.') ];
249 Test::WWW::Mechanize 1.04
256 $deps{'FASTCGI'} = [ text_to_hash( << '.') ];
262 $deps{'SPEEDYCGI'} = [ text_to_hash( << '.') ];
268 $deps{'MODPERL1'} = [ text_to_hash( << '.') ];
274 $deps{'MODPERL2'} = [ text_to_hash( << '.') ];
280 $deps{'MYSQL'} = [ text_to_hash( << '.') ];
283 $deps{'ORACLE'} = [ text_to_hash( << '.') ];
286 $deps{'POSTGRESQL'} = [ text_to_hash( << '.') ];
290 $deps{'SQLITE'} = [ text_to_hash( << '.') ];
294 if ($args{'download'}) {
300 check_perl_version();
305 foreach my $type (sort grep $args{$_}, keys %args) {
306 next unless ($type =~ /^with-(.*?)$/);
309 section("$type dependencies");
312 my @deps = @{ $deps{$type} };
314 my $module = shift @deps;
315 my $version = shift @deps;
316 my $ret = test_dep($module, $version);
318 push @missing, $module, $version unless $ret;
320 if ( $args{'install'} ) {
322 resolve_dep(shift @missing, shift @missing);
333 eval "use $module $version ()";
336 $error =~ s/\n(.*)$//s;
337 undef $error unless $error =~ /this is only/;
338 found("$module $version", 0, $error);
343 $msg .= " >=$version" if $version;
353 print "\nInstall module $module\n";
355 my $ext = $ENV{'RT_FIX_DEPS_CMD'};
360 if ( $ENV{'HOME'} ) {
361 unshift @INC, "$ENV{'HOME'}/.cpan";
363 $configured = eval { require CPAN::MyConfig } || eval { require CPAN::Config };
365 unless ( $configured ) {
367 You didn't configure CPAN shell yet.
368 Please run `@PERL@ -MCPAN -e shell` tool and configure it.
372 my $rv = eval { require CPAN; CPAN::Shell->install($module) };
373 return $rv unless $@;
376 Failed to load module CPAN.
378 -------- Error ---------
380 ------------------------
382 When we tried to start installing RT's perl dependencies,
383 we were unable to load the CPAN client. This module is usually distributed
384 with Perl. This usually indicates that your vendor has shipped an unconfigured
385 or incorrectly configured CPAN client.
386 The error above may (or may not) give you a hint about what went wrong
388 You have several choices about how to install dependencies in
391 1) use a different tool to install dependencies by running setting the following
392 shell environment variable and rerunning this tool:
393 RT_FIX_DEPS_CMD='@PERL@ -MCPAN -e"install %s"'
394 2) Attempt to configure CPAN by running:
395 `@PERL@ -MCPAN -e shell` program from shell.
396 If this fails, you may have to manually upgrade CPAN (see below)
397 3) Try to update the CPAN client. Download it from:
398 http://search.cpan.org/dist/CPAN and try again
399 4) Install each dependency manually by downloading them one by one from
400 http://search.cpan.org
407 $ext =~ s/\%s/$module/g; # sprintf( $ext, $module );
411 print "\t\tcommand: '$ext'\n";
412 return scalar `$ext 1>&2`;
419 foreach my $key (keys %deps) {
420 my @deps = (@{$deps{$key}});
422 my $mod = shift @deps;
423 my $ver = shift @deps;
424 next if ($mod =~ /^(DBD-|Apache-Request)/);
425 $modules{$mod} = $ver;
428 my @mods = keys %modules;
430 my $moddir = $args{'download'};
431 foreach my $mod (@mods) {
432 $CPAN::Config->{'build_dir'} = $moddir;
436 opendir(DIR, $moddir);
437 while ( my $dir = readdir(DIR)) {
438 print "Dir is $dir\n";
439 next if ( $dir =~ /^\.\.?$/);
441 # Skip things we've previously tagged
442 my $out = `svn ls $args{'repository'}/tags/$dir`;
445 if ($dir =~ /^(.*)-(.*?)$/) {
446 `svn_load_dirs -no_user_input -t tags/$dir -v $args{'repository'} dists/$1 $moddir/$dir`;
447 `rm -rf $moddir/$dir`;
456 sub check_perl_version {
458 eval {require 5.008003};
460 found("5.8.3", 0,"RT is known to be non-functional on versions of perl older than 5.8.3. Please upgrade to 5.8.3 or newer.");
463 found( ">=5.8.3($])", 1);
469 found("rt group (@RTGROUP@)", defined getgrnam("@RTGROUP@"));
470 found("bin owner (@BIN_OWNER@)", defined getpwnam("@BIN_OWNER@"));
471 found("libs owner (@LIBS_OWNER@)", defined getpwnam("@LIBS_OWNER@"));
472 found("libs group (@LIBS_GROUP@)", defined getgrnam("@LIBS_GROUP@"));
473 found("web owner (@WEB_USER@)", defined getpwnam("@WEB_USER@"));
474 found("web group (@WEB_GROUP@)", defined getgrnam("@WEB_GROUP@"));