2 # BEGIN BPS TAGGED BLOCK {{{
6 # This software is Copyright (c) 1996-2012 Best Practical Solutions, LLC
7 # <sales@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-MODPERL1', 'with-MODPERL2',
86 Pod::Usage::pod2usage( { verbose => 2 } );
97 'with-DEV' => @RT_DEVEL_MODE@,
98 'with-GPG' => @RT_GPG@,
101 'with-GRAPHVIZ' => @RT_GRAPHVIZ@,
102 'with-GD' => @RT_GD@,
103 'with-DASHBOARDS' => 1,
104 'with-USERLOGO' => 1,
105 'with-SSL-MAILGATE' => @RT_SSL_MAILGATE@,
107 $args{$_} = $default{$_} foreach grep !exists $args{$_}, keys %default;
111 my %always_show_sections = (
119 print "$s:\n" unless $args{'list-deps'};
127 unless ( $args{'list-deps'} ) {
128 if ( $args{'v'} or not $test or $always_show_sections{$section} ) {
130 print $test ? "found" : "MISSING";
134 print "\t\t$extra\n" if defined $extra;
140 my %missing_by_type = @_;
142 unless ( $args{'list-deps'} ) {
143 unless ( keys %missing_by_type ) {
144 print "\nAll dependencies have been found.\n";
148 print "\nSOME DEPENDENCIES WERE MISSING.\n";
150 for my $type ( keys %missing_by_type ) {
151 my $missing = $missing_by_type{$type};
153 print "$type missing dependencies:\n";
154 for my $name ( keys %$missing ) {
155 my $module = $missing->{$name};
156 my $version = $module->{version};
157 my $error = $module->{error};
158 print_found( $name . ( $version && !$error ? " >= $version" : "" ),
159 0, $module->{error} );
168 for my $line ( split /\n/, $_[0] ) {
169 my($key, $value) = $line =~ /(\S+)\s*(\S*)/;
171 $hash{$key} = $value;
177 $deps{'CORE'} = [ text_to_hash( << '.') ];
180 DateTime::Locale 0.40
185 Class::ReturnValue 0.40
186 DBIx::SearchBuilder 1.59
196 Locale::Maketext 1.06
197 Locale::Maketext::Lexicon 0.32
198 Locale::Maketext::Fuzzy
211 Module::Versions::Report 1.05
212 Cache::Simple::TimedExpiry
216 Devel::StackTrace 1.19
217 Text::Password::Pronounceable
218 Devel::GlobalDestruction
221 Regexp::Common::net::CIDR
225 $deps{'MASON'} = [ text_to_hash( << '.') ];
233 Text::WikiFormat 0.76
235 Devel::StackTrace 1.19
240 $deps{'PSGI'} = [ text_to_hash( << '.') ];
243 HTML::Mason::PSGIHandler 0.52
245 Plack::Handler::Starlet
249 $deps{'MAILGATE'} = [ text_to_hash( << '.') ];
255 $deps{'SSL-MAILGATE'} = [ text_to_hash( << '.') ];
263 $deps{'CLI'} = [ text_to_hash( << '.') ];
266 HTTP::Request::Common
272 $deps{'DEV'} = [ text_to_hash( << '.') ];
278 Test::WWW::Mechanize 1.30
283 Test::Deep 0 # needed for shredder tests
284 String::ShellQuote 0 # needed for gnupg-incoming.t
287 Test::Builder 0.90 # needed for is_passing
290 Test::WWW::Mechanize::PSGI
291 Plack::Middleware::Test::StashWarnings 0.06
295 $deps{'FASTCGI'} = [ text_to_hash( << '.') ];
300 $deps{'MODPERL1'} = [ text_to_hash( << '.') ];
305 $deps{'MODPERL2'} = [ text_to_hash( << '.') ];
310 $deps{'MYSQL'} = [ text_to_hash( << '.') ];
314 $deps{'ORACLE'} = [ text_to_hash( << '.') ];
318 $deps{'POSTGRESQL'} = [ text_to_hash( << '.') ];
322 $deps{'SQLITE'} = [ text_to_hash( << '.') ];
326 $deps{'GPG'} = [ text_to_hash( << '.') ];
331 $deps{'ICAL'} = [ text_to_hash( << '.') ];
335 $deps{'SMTP'} = [ text_to_hash( << '.') ];
339 $deps{'DASHBOARDS'} = [ text_to_hash( << '.') ];
340 HTML::RewriteAttributes 0.04
345 $deps{'GRAPHVIZ'} = [ text_to_hash( << '.') ];
350 $deps{'GD'} = [ text_to_hash( << '.') ];
356 $deps{'USERLOGO'} = [ text_to_hash( << '.') ];
361 'DBD::Oracle' => [qw(1.23)],
364 if ($args{'download'}) {
369 check_perl_version();
373 my %Missing_By_Type = ();
374 foreach my $type (sort grep $args{$_}, keys %args) {
375 next unless ($type =~ /^with-(.*?)$/) and $deps{$1};
378 section("$type dependencies");
381 my @deps = @{ $deps{$type} };
383 my %missing = test_deps(@deps);
385 if ( $args{'install'} ) {
386 for my $module (keys %missing) {
387 resolve_dep($module, $missing{$module}{version});
388 my $m = $module . '.pm';
390 if ( delete $INC{$m} ) {
391 my $symtab = $module . '::';
393 for my $symbol ( keys %{$symtab} ) {
394 next if substr( $symbol, -2, 2 ) eq '::';
395 delete $symtab->{$symbol};
398 delete $missing{$module}
399 if test_dep($module, $missing{$module}{version}, $AVOID{$module});
403 $Missing_By_Type{$type} = \%missing if keys %missing;
406 conclude(%Missing_By_Type);
413 my $module = shift @deps;
414 my $version = shift @deps;
415 my($test, $error) = test_dep($module, $version, $AVOID{$module});
416 my $msg = $module . ($version && !$error ? " >= $version" : '');
417 print_found($msg, $test, $error);
419 $missing{$module} = { version => $version, error => $error } unless $test;
430 if ( $args{'list-deps'} ) {
431 print $module, ': ', $version || 0, "\n";
434 eval "use $module $version ()";
435 if ( my $error = $@ ) {
436 return 0 unless wantarray;
438 $error =~ s/\n(.*)$//s;
439 $error =~ s/at \(eval \d+\) line \d+\.$//;
440 undef $error if $error =~ /this is only/;
442 return ( 0, $error );
446 my $version = $module->VERSION;
447 if ( grep $version eq $_, @$avoid ) {
448 return 0 unless wantarray;
449 return (0, "It's known that there are problems with RT and version '$version' of '$module' module. If it's the latest available version of the module then you have to downgrade manually.");
461 print "\nInstall module $module\n";
463 my $ext = $ENV{'RT_FIX_DEPS_CMD'} || $ENV{'PERL_PREFER_CPAN_CLIENT'};
468 if ( $ENV{'HOME'} ) {
469 unshift @INC, "$ENV{'HOME'}/.cpan";
471 $configured = eval { require CPAN::MyConfig } || eval { require CPAN::Config };
473 unless ( $configured ) {
475 You haven't configured the CPAN shell yet.
476 Please run `@PERL@ -MCPAN -e shell` to configure it.
480 my $rv = eval { require CPAN; CPAN::Shell->install($module) };
481 return $rv unless $@;
484 Failed to load module CPAN.
486 -------- Error ---------
488 ------------------------
490 When we tried to start installing RT's perl dependencies,
491 we were unable to load the CPAN client. This module is usually distributed
492 with Perl. This usually indicates that your vendor has shipped an unconfigured
493 or incorrectly configured CPAN client.
494 The error above may (or may not) give you a hint about what went wrong
496 You have several choices about how to install dependencies in
499 1) use a different tool to install dependencies by running setting the following
500 shell environment variable and rerunning this tool:
501 RT_FIX_DEPS_CMD='@PERL@ -MCPAN -e"install %s"'
502 2) Attempt to configure CPAN by running:
503 `@PERL@ -MCPAN -e shell` program from shell.
504 If this fails, you may have to manually upgrade CPAN (see below)
505 3) Try to update the CPAN client. Download it from:
506 http://search.cpan.org/dist/CPAN and try again
507 4) Install each dependency manually by downloading them one by one from
508 http://search.cpan.org
515 $ext =~ s/\%s/$module/g; # sprintf( $ext, $module );
519 print "\t\tcommand: '$ext'\n";
520 return scalar `$ext 1>&2`;
527 foreach my $key (keys %deps) {
528 my @deps = (@{$deps{$key}});
530 my $mod = shift @deps;
531 my $ver = shift @deps;
532 next if ($mod =~ /^(DBD-|Apache-Request)/);
533 $modules{$mod} = $ver;
536 my @mods = keys %modules;
538 my $moddir = $args{'download'};
539 foreach my $mod (@mods) {
540 $CPAN::Config->{'build_dir'} = $moddir;
544 opendir(DIR, $moddir);
545 while ( my $dir = readdir(DIR)) {
546 print "Dir is $dir\n";
547 next if ( $dir =~ /^\.\.?$/);
549 # Skip things we've previously tagged
550 my $out = `svn ls $args{'repository'}/tags/$dir`;
553 if ($dir =~ /^(.*)-(.*?)$/) {
554 `svn_load_dirs -no_user_input -t tags/$dir -v $args{'repository'} dists/$1 $moddir/$dir`;
555 `rm -rf $moddir/$dir`;
564 sub check_perl_version {
566 eval {require 5.008003};
568 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.");
571 print_found( sprintf(">=5.8.3(%vd)", $^V), 1 );
577 print_found("rt group (@RTGROUP@)", defined getgrnam("@RTGROUP@"));
578 print_found("bin owner (@BIN_OWNER@)", defined getpwnam("@BIN_OWNER@"));
579 print_found("libs owner (@LIBS_OWNER@)", defined getpwnam("@LIBS_OWNER@"));
580 print_found("libs group (@LIBS_GROUP@)", defined getgrnam("@LIBS_GROUP@"));
581 print_found("web owner (@WEB_USER@)", defined getpwnam("@WEB_USER@"));
582 print_found("web group (@WEB_GROUP@)", defined getgrnam("@WEB_GROUP@"));
591 rt-test-dependencies - test rt's dependencies
596 rt-test-dependencies --install
597 rt-test-dependencies --with-mysql --with-fastcgi
601 by default, C<rt-test-dependencies> determines whether you have installed all
602 the perl modules RT needs to run.
604 the "RT_FIX_DEPS_CMD" environment variable, if set, will be used instead of
605 the standard CPAN shell by --install to install any required modules. it will
606 be called with the module name, or, if "RT_FIX_DEPS_CMD" contains a "%s", will
607 replace the "%s" with the module name before calling the program.
615 install missing modules
619 list the status of all dependencies, rather than just the missing ones.
621 -v is equal to --verbose
623 =item specify dependencies
629 database interface for mysql
631 =item --with-postgresql
633 database interface for postgresql
637 database interface for oracle
641 database interface and driver for sqlite (unsupported)
645 libraries needed to support the fastcgi handler
649 libraries needed to support the modperl 1 handler
653 libraries needed to support the modperl 2 handler
657 tools needed for RT development