2 # BEGIN BPS TAGGED BLOCK {{{
6 # This software is Copyright (c) 1996-2014 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.
56 no warnings qw(numeric redefine);
61 my @orig_argv = @ARGV;
62 # Save our path because installers or tests can change cwd
63 my $script_path = abs_path($0);
68 'with-MYSQL', 'with-PG', 'with-SQLITE', 'with-ORACLE',
69 'with-FASTCGI', 'with-MODPERL1', 'with-MODPERL2', 'with-STANDALONE',
87 Pod::Usage::pod2usage( { verbose => 2 } );
96 'with-DEVELOPER' => 0,
100 'with-GRAPHVIZ' => 1,
102 'with-DASHBOARDS' => 1,
103 'with-USERLOGO' => 1,
104 'with-HTML-DOC' => 0,
106 $args{$_} = $default{$_} foreach grep !exists $args{$_}, keys %default;
110 my %always_show_sections = (
118 print "$s:\n" unless $args{'list-deps'};
126 unless ( $args{'list-deps'} ) {
127 if ( $args{'v'} or not $test or $always_show_sections{$section} ) {
129 print $test ? "found" : "MISSING";
133 print "\t\t$extra\n" if defined $extra;
139 my %missing_by_type = @_;
141 unless ( $args{'list-deps'} ) {
142 unless ( keys %missing_by_type ) {
143 print "\nAll dependencies have been found.\n";
147 print "\nSOME DEPENDENCIES WERE MISSING.\n";
149 for my $type ( keys %missing_by_type ) {
150 my $missing = $missing_by_type{$type};
152 print "$type missing dependencies:\n";
153 for my $name ( keys %$missing ) {
154 my $module = $missing->{$name};
155 my $version = $module->{version};
156 my $error = $module->{error};
157 print_found( $name . ( $version && !$error ? " >= $version" : "" ),
158 0, $module->{error} );
162 print "\nPerl library path for /usr/bin/perl:\n";
163 print " $_\n" for @INC;
171 for my $line ( split /\n/, $_[0] ) {
172 my($key, $value) = $line =~ /(\S+)\s*(\S*)/;
174 $hash{$key} = $value;
180 my ($name, $module, $version) = @_;
181 my %list = @{$deps{$name}};
182 $list{$module} = ($version || '');
183 $deps{$name} = [ %list ];
186 $deps{'CORE'} = [ text_to_hash( << '.') ];
199 DateTime::Format::Natural 0.67
200 DateTime::Locale 0.40
202 DBIx::SearchBuilder 1.65
203 Devel::GlobalDestruction
204 Devel::StackTrace 1.19
209 Email::Address::List 0.02
217 HTML::FormatText::WithLinks 0.14
218 HTML::FormatText::WithLinks::AndTables
220 HTML::Mason::PSGIHandler 0.52
222 HTML::RewriteAttributes 0.05
229 Locale::Maketext 1.06
230 Locale::Maketext::Fuzzy 0.11
231 Locale::Maketext::Lexicon 0.32
237 Module::Versions::Report 1.05
240 Plack::Handler::Starlet
242 Regexp::Common::net::CIDR
247 Symbol::Global::Name 0.04
249 Text::Password::Pronounceable
252 Text::WikiFormat 0.76
260 set_dep( CORE => 'Symbol::Global::Name' => 0.05 ) if $] >= 5.019003;
261 set_dep( CORE => CGI => 4.00 ) if $] > 5.019003;
263 $deps{'MAILGATE'} = [ text_to_hash( << '.') ];
273 $deps{'CLI'} = [ text_to_hash( << '.') ];
275 HTTP::Request::Common
282 $deps{'DEVELOPER'} = [ text_to_hash( << '.') ];
289 Plack::Middleware::Test::StashWarnings 0.08
291 String::ShellQuote 0 # needed for gnupg-incoming.t
292 Test::Builder 0.90 # needed for is_passing
293 Test::Deep 0 # needed for shredder tests
301 Test::WWW::Mechanize 1.30
302 Test::WWW::Mechanize::PSGI
307 $deps{'FASTCGI'} = [ text_to_hash( << '.') ];
312 $deps{'MODPERL1'} = [ text_to_hash( << '.') ];
317 $deps{'MODPERL2'} = [ text_to_hash( << '.') ];
321 $deps{'MYSQL'} = [ text_to_hash( << '.') ];
325 $deps{'ORACLE'} = [ text_to_hash( << '.') ];
329 $deps{'PG'} = [ text_to_hash( << '.') ];
330 DBIx::SearchBuilder 1.66
334 $deps{'SQLITE'} = [ text_to_hash( << '.') ];
338 $deps{'GPG'} = [ text_to_hash( << '.') ];
344 $deps{'SMIME'} = [ text_to_hash( << '.') ];
350 $deps{'ICAL'} = [ text_to_hash( << '.') ];
354 $deps{'DASHBOARDS'} = [ text_to_hash( << '.') ];
360 $deps{'GRAPHVIZ'} = [ text_to_hash( << '.') ];
365 $deps{'GD'} = [ text_to_hash( << '.') ];
371 $deps{'USERLOGO'} = [ text_to_hash( << '.') ];
375 $deps{'HTML-DOC'} = [ text_to_hash( <<'.') ];
381 'DBD::Oracle' => [qw(1.23)],
382 'Devel::StackTrace' => [qw(1.28 1.29)],
385 if ($args{'download'}) {
390 check_perl_version();
394 my %Missing_By_Type = ();
395 foreach my $type (sort grep $args{$_}, keys %args) {
396 next unless ($type =~ /^with-(.*?)$/) and $deps{$1};
399 section("$type dependencies");
402 my @deps = @{ $deps{$type} };
404 my %missing = test_deps(@deps);
406 if ( $args{'install'} ) {
407 for my $module (keys %missing) {
408 resolve_dep($module, $missing{$module}{version});
409 my $m = $module . '.pm';
411 if ( delete $INC{$m} ) {
412 my $symtab = $module . '::';
414 for my $symbol ( keys %{$symtab} ) {
415 next if substr( $symbol, -2, 2 ) eq '::';
416 delete $symtab->{$symbol};
419 delete $missing{$module}
420 if test_dep($module, $missing{$module}{version}, $AVOID{$module});
424 $Missing_By_Type{$type} = \%missing if keys %missing;
427 if ( $args{'install'} && keys %Missing_By_Type ) {
428 exec($script_path, @orig_argv, '--no-install');
431 conclude(%Missing_By_Type);
439 my $module = shift @deps;
440 my $version = shift @deps;
441 my($test, $error) = test_dep($module, $version, $AVOID{$module});
442 my $msg = $module . ($version && !$error ? " >= $version" : '');
443 print_found($msg, $test, $error);
445 $missing{$module} = { version => $version, error => $error } unless $test;
456 if ( $args{'list-deps'} ) {
457 print $module, ': ', $version || 0, "\n";
460 no warnings 'deprecated';
461 eval "{ local \$ENV{__WARN__}; use $module $version () }";
462 if ( my $error = $@ ) {
463 return 0 unless wantarray;
465 $error =~ s/\n(.*)$//s;
466 $error =~ s/at \(eval \d+\) line \d+\.$//;
467 undef $error if $error =~ /this is only/;
471 undef $error if defined $error and $error =~ /^Can't locate $path\.pm in \@INC/;
473 return ( 0, $error );
477 my $version = $module->VERSION;
478 if ( grep $version eq $_, @$avoid ) {
479 return 0 unless wantarray;
480 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.");
492 print "\nInstall module $module\n";
494 my $ext = $ENV{'RT_FIX_DEPS_CMD'} || $ENV{'PERL_PREFER_CPAN_CLIENT'};
499 if ( $ENV{'HOME'} ) {
500 unshift @INC, "$ENV{'HOME'}/.cpan";
502 $configured = eval { require CPAN::MyConfig } || eval { require CPAN::Config };
504 unless ( $configured ) {
506 You haven't configured the CPAN shell yet.
507 Please run `/usr/bin/perl -MCPAN -e shell` to configure it.
511 my $rv = eval { require CPAN; CPAN::Shell->install($module) };
512 return $rv unless $@;
515 Failed to load module CPAN.
517 -------- Error ---------
519 ------------------------
521 When we tried to start installing RT's perl dependencies,
522 we were unable to load the CPAN client. This module is usually distributed
523 with Perl. This usually indicates that your vendor has shipped an unconfigured
524 or incorrectly configured CPAN client.
525 The error above may (or may not) give you a hint about what went wrong
527 You have several choices about how to install dependencies in
530 1) use a different tool to install dependencies by running setting the following
531 shell environment variable and rerunning this tool:
532 RT_FIX_DEPS_CMD='/usr/bin/perl -MCPAN -e"install %s"'
533 2) Attempt to configure CPAN by running:
534 `/usr/bin/perl -MCPAN -e shell` program from shell.
535 If this fails, you may have to manually upgrade CPAN (see below)
536 3) Try to update the CPAN client. Download it from:
537 http://search.cpan.org/dist/CPAN and try again
538 4) Install each dependency manually by downloading them one by one from
539 http://search.cpan.org
546 $ext =~ s/\%s/$module/g; # sprintf( $ext, $module );
550 print "\t\tcommand: '$ext'\n";
551 return scalar `$ext 1>&2`;
554 sub check_perl_version {
556 eval {require 5.010_001};
558 print_found("5.10.1", 0, sprintf("RT requires Perl v5.10.1 or newer. Your current Perl is v%vd", $^V));
561 print_found( sprintf(">=5.10.1(%vd)", $^V), 1 );
567 print_found("rt group (uio-rt)", defined getgrnam("uio-rt"));
568 print_found("bin owner (root)", defined getpwnam("root"));
569 print_found("libs owner (root)", defined getpwnam("root"));
570 print_found("libs group (bin)", defined getgrnam("bin"));
571 print_found("web owner (httpd)", defined getpwnam("httpd"));
572 print_found("web group (httpd)", defined getgrnam("httpd"));
581 rt-test-dependencies - test rt's dependencies
586 rt-test-dependencies --install
587 rt-test-dependencies --with-mysql --with-fastcgi
591 by default, C<rt-test-dependencies> determines whether you have installed all
592 the perl modules RT needs to run.
594 the "RT_FIX_DEPS_CMD" environment variable, if set, will be used instead of
595 the standard CPAN shell by --install to install any required modules. it will
596 be called with the module name, or, if "RT_FIX_DEPS_CMD" contains a "%s", will
597 replace the "%s" with the module name before calling the program.
605 install missing modules
609 list the status of all dependencies, rather than just the missing ones.
611 -v is equal to --verbose
613 =item specify dependencies
619 database interface for mysql
623 database interface for postgresql
627 database interface for oracle
631 database interface and driver for sqlite (unsupported)
635 libraries needed to support the fastcgi handler
637 =item --with-modperl1
639 libraries needed to support the modperl 1 handler
641 =item --with-modperl2
643 libraries needed to support the modperl 2 handler
645 =item --with-developer
647 tools needed for RT development