2 # BEGIN BPS TAGGED BLOCK {{{
6 # This software is Copyright (c) 1996-2009 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/licenses/old-licenses/gpl-2.0.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";
121 print "\nEverything was found.\n";
130 By default, testdeps determine whether you have
131 installed all the perl modules RT needs to run.
133 --install Install missing modules
135 The following switches will tell the tool to check for specific dependencies
137 --with-mysql Database interface for MySQL
138 --with-postgresql Database interface for PostgreSQL
139 --with-sqlite Database interface and driver for SQLite (unsupported)
140 --with-oracle Database interface for oracle (unsupported)
142 --with-standalone Libraries needed to support the standalone simple pure perl server
143 --with-fastcgi Libraries needed to support the fastcgi handler
144 --with-speedycgi Libraries needed to support the speedycgi handler
145 --with-modperl1 Libraries needed to support the modperl 1 handler
146 --with-modperl2 Libraries needed to support the modperl 2 handler
148 --with-dev Tools needed for RT development
150 You can also specify -v or --verbose to list the status of all dependencies,
151 rather than just the missing ones.
153 The "RT_FIX_DEPS_CMD" environment variable, if set, will be used
154 instead of the standard CPAN shell by --install to install any
155 required modules. It will be called with the module name, or, if
156 "RT_FIX_DEPS_CMD" contains a "%s", will replace the "%s" with the
157 module name before calling the program.
164 for my $line ( split /\n/, $_[0] ) {
165 my($key, $value) = $line =~ /(\S+)\s*(\S*)/;
167 $hash{$key} = $value;
173 $deps{'CORE'} = [ text_to_hash( << '.') ];
177 Class::ReturnValue 0.40
179 DBIx::SearchBuilder 1.53
185 Locale::Maketext 1.06
186 Locale::Maketext::Lexicon 0.32
187 Locale::Maketext::Fuzzy
200 Module::Versions::Report 1.03
201 Cache::Simple::TimedExpiry
205 Devel::StackTrace 1.19
208 $deps{'MASON'} = [ text_to_hash( << '.') ];
219 Text::WikiFormat 0.76
223 $deps{'STANDALONE'} = [ text_to_hash( << '.') ];
224 HTTP::Server::Simple 0.07
225 HTTP::Server::Simple::Mason 0.09
228 $deps{'MAILGATE'} = [ text_to_hash( << '.') ];
236 $deps{'CLI'} = [ text_to_hash( << '.') ];
239 HTTP::Request::Common
245 $deps{'DEV'} = [ text_to_hash( << '.') ];
251 Test::WWW::Mechanize 1.04
258 $deps{'FASTCGI'} = [ text_to_hash( << '.') ];
264 $deps{'SPEEDYCGI'} = [ text_to_hash( << '.') ];
270 $deps{'MODPERL1'} = [ text_to_hash( << '.') ];
276 $deps{'MODPERL2'} = [ text_to_hash( << '.') ];
282 $deps{'MYSQL'} = [ text_to_hash( << '.') ];
285 $deps{'ORACLE'} = [ text_to_hash( << '.') ];
288 $deps{'POSTGRESQL'} = [ text_to_hash( << '.') ];
292 $deps{'SQLITE'} = [ text_to_hash( << '.') ];
296 if ($args{'download'}) {
302 check_perl_version();
307 foreach my $type (sort grep $args{$_}, keys %args) {
308 next unless ($type =~ /^with-(.*?)$/);
311 section("$type dependencies");
314 my @deps = @{ $deps{$type} };
316 my $module = shift @deps;
317 my $version = shift @deps;
318 my $ret = test_dep($module, $version);
320 push @missing, $module, $version unless $ret;
322 if ( $args{'install'} ) {
324 resolve_dep(shift @missing, shift @missing);
335 eval "use $module $version ()";
338 $error =~ s/\n(.*)$//s;
339 undef $error unless $error =~ /this is only/;
340 found("$module $version", 0, $error);
345 $msg .= " >=$version" if $version;
355 print "\nInstall module $module\n";
357 my $ext = $ENV{'RT_FIX_DEPS_CMD'};
362 if ( $ENV{'HOME'} ) {
363 unshift @INC, "$ENV{'HOME'}/.cpan";
365 $configured = eval { require CPAN::MyConfig } || eval { require CPAN::Config };
367 unless ( $configured ) {
369 You didn't configure CPAN shell yet.
370 Please run `@PERL@ -MCPAN -e shell` tool and configure it.
374 my $rv = eval { require CPAN; CPAN::Shell->install($module) };
375 return $rv unless $@;
378 Failed to load module CPAN.
380 -------- Error ---------
382 ------------------------
384 When we tried to start installing RT's perl dependencies,
385 we were unable to load the CPAN client. This module is usually distributed
386 with Perl. This usually indicates that your vendor has shipped an unconfigured
387 or incorrectly configured CPAN client.
388 The error above may (or may not) give you a hint about what went wrong
390 You have several choices about how to install dependencies in
393 1) use a different tool to install dependencies by running setting the following
394 shell environment variable and rerunning this tool:
395 RT_FIX_DEPS_CMD='@PERL@ -MCPAN -e"install %s"'
396 2) Attempt to configure CPAN by running:
397 `@PERL@ -MCPAN -e shell` program from shell.
398 If this fails, you may have to manually upgrade CPAN (see below)
399 3) Try to update the CPAN client. Download it from:
400 http://search.cpan.org/dist/CPAN and try again
401 4) Install each dependency manually by downloading them one by one from
402 http://search.cpan.org
409 $ext =~ s/\%s/$module/g; # sprintf( $ext, $module );
413 print "\t\tcommand: '$ext'\n";
414 return scalar `$ext 1>&2`;
421 foreach my $key (keys %deps) {
422 my @deps = (@{$deps{$key}});
424 my $mod = shift @deps;
425 my $ver = shift @deps;
426 next if ($mod =~ /^(DBD-|Apache-Request)/);
427 $modules{$mod} = $ver;
430 my @mods = keys %modules;
432 my $moddir = $args{'download'};
433 foreach my $mod (@mods) {
434 $CPAN::Config->{'build_dir'} = $moddir;
438 opendir(DIR, $moddir);
439 while ( my $dir = readdir(DIR)) {
440 print "Dir is $dir\n";
441 next if ( $dir =~ /^\.\.?$/);
443 # Skip things we've previously tagged
444 my $out = `svn ls $args{'repository'}/tags/$dir`;
447 if ($dir =~ /^(.*)-(.*?)$/) {
448 `svn_load_dirs -no_user_input -t tags/$dir -v $args{'repository'} dists/$1 $moddir/$dir`;
449 `rm -rf $moddir/$dir`;
458 sub check_perl_version {
460 eval {require 5.008003};
462 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.");
465 found( ">=5.8.3($])", 1);
471 found("rt group (@RTGROUP@)", defined getgrnam("@RTGROUP@"));
472 found("bin owner (@BIN_OWNER@)", defined getpwnam("@BIN_OWNER@"));
473 found("libs owner (@LIBS_OWNER@)", defined getpwnam("@LIBS_OWNER@"));
474 found("libs group (@LIBS_GROUP@)", defined getgrnam("@LIBS_GROUP@"));
475 found("web owner (@WEB_USER@)", defined getpwnam("@WEB_USER@"));
476 found("web group (@WEB_GROUP@)", defined getgrnam("@WEB_GROUP@"));