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',
91 'with-DEV' => @RT_DEVEL_MODE@,
92 'with-STANDALONE' => 1,
93 'with-GPG' => @RT_GPG@,
96 'with-GRAPHVIZ' => @RT_GRAPHVIZ@,
98 'with-DASHBOARDS' => 1
100 $args{$_} = $default{$_} foreach grep !exists $args{$_}, keys %default;
104 my %always_show_sections = (
112 print "$s:\n" unless $args{'list-deps'};
120 unless ( $args{'list-deps'} ) {
121 if ( $args{'v'} or not $test or $always_show_sections{$section} ) {
123 print $test ? "found" : "MISSING";
127 print "\t\t$extra\n" if defined $extra;
133 my %missing_by_type = @_;
135 unless ( $args{'list-deps'} ) {
136 unless ( keys %missing_by_type ) {
137 print "\nAll dependencies have been found.\n";
141 print "\nSOME DEPENDENCIES WERE MISSING.\n";
143 for my $type ( keys %missing_by_type ) {
144 my $missing = $missing_by_type{$type};
146 print "$type missing dependencies:\n";
147 for my $name ( keys %$missing ) {
148 my $module = $missing->{$name};
149 my $version = $module->{version};
150 print_found( $name . ( $version ? " >= $version" : "" ),
151 0, $module->{error} );
163 By default, testdeps determine whether you have
164 installed all the perl modules RT needs to run.
166 --install Install missing modules
168 The following switches will tell the tool to check for specific dependencies
170 --with-mysql Database interface for MySQL
171 --with-postgresql Database interface for PostgreSQL
172 --with-oracle Database interface for Oracle
173 --with-sqlite Database interface and driver for SQLite (unsupported)
175 --with-standalone Libraries needed to support the standalone simple pure perl server
176 --with-fastcgi Libraries needed to support the fastcgi handler
177 --with-speedycgi Libraries needed to support the speedycgi handler
178 --with-modperl1 Libraries needed to support the modperl 1 handler
179 --with-modperl2 Libraries needed to support the modperl 2 handler
181 --with-dev Tools needed for RT development
183 You can also specify -v or --verbose to list the status of all dependencies,
184 rather than just the missing ones.
186 The "RT_FIX_DEPS_CMD" environment variable, if set, will be used
187 instead of the standard CPAN shell by --install to install any
188 required modules. It will be called with the module name, or, if
189 "RT_FIX_DEPS_CMD" contains a "%s", will replace the "%s" with the
190 module name before calling the program.
197 for my $line ( split /\n/, $_[0] ) {
198 my($key, $value) = $line =~ /(\S+)\s*(\S*)/;
200 $hash{$key} = $value;
206 $deps{'CORE'} = [ text_to_hash( << '.') ];
210 Class::ReturnValue 0.40
211 DBIx::SearchBuilder 1.54
219 Locale::Maketext 1.06
220 Locale::Maketext::Lexicon 0.32
221 Locale::Maketext::Fuzzy
234 Module::Versions::Report 1.05
235 Cache::Simple::TimedExpiry
240 Devel::StackTrace 1.19
243 $deps{'MASON'} = [ text_to_hash( << '.') ];
251 Text::WikiFormat 0.76
253 Devel::StackTrace 1.19
256 $deps{'STANDALONE'} = [ text_to_hash( << '.') ];
257 HTTP::Server::Simple 0.34
258 HTTP::Server::Simple::Mason 0.09
262 $deps{'MAILGATE'} = [ text_to_hash( << '.') ];
270 $deps{'CLI'} = [ text_to_hash( << '.') ];
273 HTTP::Request::Common
279 $deps{'DEV'} = [ text_to_hash( << '.') ];
283 Test::WWW::Mechanize 1.04
288 Test::Deep 0 # needed for shredder tests
289 String::ShellQuote 0 # needed for gnupg-incoming.t
290 Test::HTTP::Server::Simple 0.09
291 Test::HTTP::Server::Simple::StashWarnings 0.02
294 Test::Builder 0.77 # needed to fix TODO test
297 HTTP::Server::Simple::Mason 0.13
300 $deps{'FASTCGI'} = [ text_to_hash( << '.') ];
306 $deps{'SPEEDYCGI'} = [ text_to_hash( << '.') ];
312 $deps{'MODPERL1'} = [ text_to_hash( << '.') ];
318 $deps{'MODPERL2'} = [ text_to_hash( << '.') ];
324 $deps{'MYSQL'} = [ text_to_hash( << '.') ];
328 $deps{'ORACLE'} = [ text_to_hash( << '.') ];
332 $deps{'POSTGRESQL'} = [ text_to_hash( << '.') ];
336 $deps{'SQLITE'} = [ text_to_hash( << '.') ];
340 $deps{'GPG'} = [ text_to_hash( << '.') ];
345 $deps{'ICAL'} = [ text_to_hash( << '.') ];
349 $deps{'SMTP'} = [ text_to_hash( << '.') ];
353 $deps{'DASHBOARDS'} = [ text_to_hash( << '.') ];
354 HTML::RewriteAttributes 0.02
358 $deps{'GRAPHVIZ'} = [ text_to_hash( << '.') ];
361 IPC::Run::SafeHandles
364 $deps{'GD'} = [ text_to_hash( << '.') ];
370 if ($args{'download'}) {
376 check_perl_version();
380 my %Missing_By_Type = ();
381 foreach my $type (sort grep $args{$_}, keys %args) {
382 next unless ($type =~ /^with-(.*?)$/);
385 section("$type dependencies");
388 my @deps = @{ $deps{$type} };
390 my %missing = test_deps(@deps);
392 if ( $args{'install'} ) {
393 for my $module (keys %missing) {
394 resolve_dep($module, $missing{$module}{version});
395 delete $missing{$module} if test_dep($module, $missing{$module}{version});
399 $Missing_By_Type{$type} = \%missing if keys %missing;
402 conclude(%Missing_By_Type);
409 my $module = shift @deps;
410 my $version = shift @deps;
411 my($test, $error) = test_dep($module, $version);
412 my $msg = $module . ($version ? " >= $version" : '');
413 print_found($msg, $test, $error);
415 $missing{$module} = { version => $version, error => $error } unless $test;
425 if ( $args{'list-deps'} ) {
426 print $module, ': ', $version || 0, "\n";
429 eval "use $module $version ()";
432 $error =~ s/\n(.*)$//s;
433 $error =~ s/at \(eval \d+\) line \d+\.$//;
434 undef $error unless $error =~ /this is only/;
436 return ( 0, $error );
448 print "\nInstall module $module\n";
450 my $ext = $ENV{'RT_FIX_DEPS_CMD'};
455 if ( $ENV{'HOME'} ) {
456 unshift @INC, "$ENV{'HOME'}/.cpan";
458 $configured = eval { require CPAN::MyConfig } || eval { require CPAN::Config };
460 unless ( $configured ) {
462 You haven't configured the CPAN shell yet.
463 Please run `@PERL@ -MCPAN -e shell` to configure it.
467 my $rv = eval { require CPAN; CPAN::Shell->install($module) };
468 return $rv unless $@;
471 Failed to load module CPAN.
473 -------- Error ---------
475 ------------------------
477 When we tried to start installing RT's perl dependencies,
478 we were unable to load the CPAN client. This module is usually distributed
479 with Perl. This usually indicates that your vendor has shipped an unconfigured
480 or incorrectly configured CPAN client.
481 The error above may (or may not) give you a hint about what went wrong
483 You have several choices about how to install dependencies in
486 1) use a different tool to install dependencies by running setting the following
487 shell environment variable and rerunning this tool:
488 RT_FIX_DEPS_CMD='@PERL@ -MCPAN -e"install %s"'
489 2) Attempt to configure CPAN by running:
490 `@PERL@ -MCPAN -e shell` program from shell.
491 If this fails, you may have to manually upgrade CPAN (see below)
492 3) Try to update the CPAN client. Download it from:
493 http://search.cpan.org/dist/CPAN and try again
494 4) Install each dependency manually by downloading them one by one from
495 http://search.cpan.org
502 $ext =~ s/\%s/$module/g; # sprintf( $ext, $module );
506 print "\t\tcommand: '$ext'\n";
507 return scalar `$ext 1>&2`;
514 foreach my $key (keys %deps) {
515 my @deps = (@{$deps{$key}});
517 my $mod = shift @deps;
518 my $ver = shift @deps;
519 next if ($mod =~ /^(DBD-|Apache-Request)/);
520 $modules{$mod} = $ver;
523 my @mods = keys %modules;
525 my $moddir = $args{'download'};
526 foreach my $mod (@mods) {
527 $CPAN::Config->{'build_dir'} = $moddir;
531 opendir(DIR, $moddir);
532 while ( my $dir = readdir(DIR)) {
533 print "Dir is $dir\n";
534 next if ( $dir =~ /^\.\.?$/);
536 # Skip things we've previously tagged
537 my $out = `svn ls $args{'repository'}/tags/$dir`;
540 if ($dir =~ /^(.*)-(.*?)$/) {
541 `svn_load_dirs -no_user_input -t tags/$dir -v $args{'repository'} dists/$1 $moddir/$dir`;
542 `rm -rf $moddir/$dir`;
551 sub check_perl_version {
553 eval {require 5.008003};
555 print_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.");
558 print_found( sprintf(">=5.8.3(%vd)", $^V), 1 );
564 print_found("rt group (@RTGROUP@)", defined getgrnam("@RTGROUP@"));
565 print_found("bin owner (@BIN_OWNER@)", defined getpwnam("@BIN_OWNER@"));
566 print_found("libs owner (@LIBS_OWNER@)", defined getpwnam("@LIBS_OWNER@"));
567 print_found("libs group (@LIBS_GROUP@)", defined getgrnam("@LIBS_GROUP@"));
568 print_found("web owner (@WEB_USER@)", defined getpwnam("@WEB_USER@"));
569 print_found("web group (@WEB_GROUP@)", defined getgrnam("@WEB_GROUP@"));