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);
59 my @orig_argv = @ARGV;
62 'install!', 'with-MYSQL',
63 'with-POSTGRESQL|with-pg|with-pgsql', 'with-SQLITE',
64 'with-ORACLE', 'with-FASTCGI',
65 'with-MODPERL1', 'with-MODPERL2',
87 Pod::Usage::pod2usage( { verbose => 2 } );
98 'with-DEV' => @RT_DEVEL_MODE@,
99 'with-GPG' => @RT_GPG@,
102 'with-GRAPHVIZ' => @RT_GRAPHVIZ@,
103 'with-GD' => @RT_GD@,
104 'with-DASHBOARDS' => 1,
105 'with-USERLOGO' => 1,
106 'with-SSL-MAILGATE' => @RT_SSL_MAILGATE@,
108 $args{$_} = $default{$_} foreach grep !exists $args{$_}, keys %default;
112 my %always_show_sections = (
120 print "$s:\n" unless $args{'list-deps'};
128 unless ( $args{'list-deps'} ) {
129 if ( $args{'v'} or not $test or $always_show_sections{$section} ) {
131 print $test ? "found" : "MISSING";
135 print "\t\t$extra\n" if defined $extra;
141 my %missing_by_type = @_;
143 unless ( $args{'list-deps'} ) {
144 unless ( keys %missing_by_type ) {
145 print "\nAll dependencies have been found.\n";
149 print "\nSOME DEPENDENCIES WERE MISSING.\n";
151 for my $type ( keys %missing_by_type ) {
152 my $missing = $missing_by_type{$type};
154 print "$type missing dependencies:\n";
155 for my $name ( keys %$missing ) {
156 my $module = $missing->{$name};
157 my $version = $module->{version};
158 my $error = $module->{error};
159 print_found( $name . ( $version && !$error ? " >= $version" : "" ),
160 0, $module->{error} );
169 for my $line ( split /\n/, $_[0] ) {
170 my($key, $value) = $line =~ /(\S+)\s*(\S*)/;
172 $hash{$key} = $value;
178 $deps{'CORE'} = [ text_to_hash( << '.') ];
181 DateTime::Locale 0.40
186 Class::ReturnValue 0.40
187 DBIx::SearchBuilder 1.59
197 Locale::Maketext 1.06
198 Locale::Maketext::Lexicon 0.32
199 Locale::Maketext::Fuzzy
212 Module::Versions::Report 1.05
213 Cache::Simple::TimedExpiry
217 Devel::StackTrace 1.19
218 Text::Password::Pronounceable
219 Devel::GlobalDestruction
222 Regexp::Common::net::CIDR
226 $deps{'MASON'} = [ text_to_hash( << '.') ];
234 Text::WikiFormat 0.76
236 Devel::StackTrace 1.19
241 $deps{'PSGI'} = [ text_to_hash( << '.') ];
244 HTML::Mason::PSGIHandler 0.52
246 Plack::Handler::Starlet
250 $deps{'MAILGATE'} = [ text_to_hash( << '.') ];
256 $deps{'SSL-MAILGATE'} = [ text_to_hash( << '.') ];
264 $deps{'CLI'} = [ text_to_hash( << '.') ];
267 HTTP::Request::Common
273 $deps{'DEV'} = [ text_to_hash( << '.') ];
279 Test::WWW::Mechanize 1.30
284 Test::Deep 0 # needed for shredder tests
285 String::ShellQuote 0 # needed for gnupg-incoming.t
288 Test::Builder 0.90 # needed for is_passing
291 Test::WWW::Mechanize::PSGI
292 Plack::Middleware::Test::StashWarnings 0.06
296 $deps{'FASTCGI'} = [ text_to_hash( << '.') ];
301 $deps{'MODPERL1'} = [ text_to_hash( << '.') ];
306 $deps{'MODPERL2'} = [ text_to_hash( << '.') ];
311 $deps{'MYSQL'} = [ text_to_hash( << '.') ];
315 $deps{'ORACLE'} = [ text_to_hash( << '.') ];
319 $deps{'POSTGRESQL'} = [ text_to_hash( << '.') ];
323 $deps{'SQLITE'} = [ text_to_hash( << '.') ];
327 $deps{'GPG'} = [ text_to_hash( << '.') ];
332 $deps{'ICAL'} = [ text_to_hash( << '.') ];
336 $deps{'SMTP'} = [ text_to_hash( << '.') ];
340 $deps{'DASHBOARDS'} = [ text_to_hash( << '.') ];
341 HTML::RewriteAttributes 0.04
346 $deps{'GRAPHVIZ'} = [ text_to_hash( << '.') ];
351 $deps{'GD'} = [ text_to_hash( << '.') ];
357 $deps{'USERLOGO'} = [ text_to_hash( << '.') ];
362 'DBD::Oracle' => [qw(1.23)],
363 'Email::Address' => [qw(1.893 1.894)],
366 if ($args{'download'}) {
371 check_perl_version();
375 my %Missing_By_Type = ();
376 foreach my $type (sort grep $args{$_}, keys %args) {
377 next unless ($type =~ /^with-(.*?)$/) and $deps{$1};
380 section("$type dependencies");
383 my @deps = @{ $deps{$type} };
385 my %missing = test_deps(@deps);
387 if ( $args{'install'} ) {
388 for my $module (keys %missing) {
389 resolve_dep($module, $missing{$module}{version});
390 my $m = $module . '.pm';
392 if ( delete $INC{$m} ) {
393 my $symtab = $module . '::';
395 for my $symbol ( keys %{$symtab} ) {
396 next if substr( $symbol, -2, 2 ) eq '::';
397 delete $symtab->{$symbol};
400 delete $missing{$module}
401 if test_dep($module, $missing{$module}{version}, $AVOID{$module});
405 $Missing_By_Type{$type} = \%missing if keys %missing;
408 if ( $args{'install'} && keys %Missing_By_Type ) {
409 exec($0, @orig_argv, '--no-install');
412 conclude(%Missing_By_Type);
420 my $module = shift @deps;
421 my $version = shift @deps;
422 my($test, $error) = test_dep($module, $version, $AVOID{$module});
423 my $msg = $module . ($version && !$error ? " >= $version" : '');
424 print_found($msg, $test, $error);
426 $missing{$module} = { version => $version, error => $error } unless $test;
437 if ( $args{'list-deps'} ) {
438 print $module, ': ', $version || 0, "\n";
441 eval "use $module $version ()";
442 if ( my $error = $@ ) {
443 return 0 unless wantarray;
445 $error =~ s/\n(.*)$//s;
446 $error =~ s/at \(eval \d+\) line \d+\.$//;
447 undef $error if $error =~ /this is only/;
449 return ( 0, $error );
453 my $version = $module->VERSION;
454 if ( grep $version eq $_, @$avoid ) {
455 return 0 unless wantarray;
456 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.");
468 print "\nInstall module $module\n";
470 my $ext = $ENV{'RT_FIX_DEPS_CMD'} || $ENV{'PERL_PREFER_CPAN_CLIENT'};
475 if ( $ENV{'HOME'} ) {
476 unshift @INC, "$ENV{'HOME'}/.cpan";
478 $configured = eval { require CPAN::MyConfig } || eval { require CPAN::Config };
480 unless ( $configured ) {
482 You haven't configured the CPAN shell yet.
483 Please run `@PERL@ -MCPAN -e shell` to configure it.
487 my $rv = eval { require CPAN; CPAN::Shell->install($module) };
488 return $rv unless $@;
491 Failed to load module CPAN.
493 -------- Error ---------
495 ------------------------
497 When we tried to start installing RT's perl dependencies,
498 we were unable to load the CPAN client. This module is usually distributed
499 with Perl. This usually indicates that your vendor has shipped an unconfigured
500 or incorrectly configured CPAN client.
501 The error above may (or may not) give you a hint about what went wrong
503 You have several choices about how to install dependencies in
506 1) use a different tool to install dependencies by running setting the following
507 shell environment variable and rerunning this tool:
508 RT_FIX_DEPS_CMD='@PERL@ -MCPAN -e"install %s"'
509 2) Attempt to configure CPAN by running:
510 `@PERL@ -MCPAN -e shell` program from shell.
511 If this fails, you may have to manually upgrade CPAN (see below)
512 3) Try to update the CPAN client. Download it from:
513 http://search.cpan.org/dist/CPAN and try again
514 4) Install each dependency manually by downloading them one by one from
515 http://search.cpan.org
522 $ext =~ s/\%s/$module/g; # sprintf( $ext, $module );
526 print "\t\tcommand: '$ext'\n";
527 return scalar `$ext 1>&2`;
534 foreach my $key (keys %deps) {
535 my @deps = (@{$deps{$key}});
537 my $mod = shift @deps;
538 my $ver = shift @deps;
539 next if ($mod =~ /^(DBD-|Apache-Request)/);
540 $modules{$mod} = $ver;
543 my @mods = keys %modules;
545 my $moddir = $args{'download'};
546 foreach my $mod (@mods) {
547 $CPAN::Config->{'build_dir'} = $moddir;
551 opendir(DIR, $moddir);
552 while ( my $dir = readdir(DIR)) {
553 print "Dir is $dir\n";
554 next if ( $dir =~ /^\.\.?$/);
556 # Skip things we've previously tagged
557 my $out = `svn ls $args{'repository'}/tags/$dir`;
560 if ($dir =~ /^(.*)-(.*?)$/) {
561 `svn_load_dirs -no_user_input -t tags/$dir -v $args{'repository'} dists/$1 $moddir/$dir`;
562 `rm -rf $moddir/$dir`;
571 sub check_perl_version {
573 eval {require 5.008003};
575 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.");
578 print_found( sprintf(">=5.8.3(%vd)", $^V), 1 );
584 print_found("rt group (@RTGROUP@)", defined getgrnam("@RTGROUP@"));
585 print_found("bin owner (@BIN_OWNER@)", defined getpwnam("@BIN_OWNER@"));
586 print_found("libs owner (@LIBS_OWNER@)", defined getpwnam("@LIBS_OWNER@"));
587 print_found("libs group (@LIBS_GROUP@)", defined getgrnam("@LIBS_GROUP@"));
588 print_found("web owner (@WEB_USER@)", defined getpwnam("@WEB_USER@"));
589 print_found("web group (@WEB_GROUP@)", defined getgrnam("@WEB_GROUP@"));
598 rt-test-dependencies - test rt's dependencies
603 rt-test-dependencies --install
604 rt-test-dependencies --with-mysql --with-fastcgi
608 by default, C<rt-test-dependencies> determines whether you have installed all
609 the perl modules RT needs to run.
611 the "RT_FIX_DEPS_CMD" environment variable, if set, will be used instead of
612 the standard CPAN shell by --install to install any required modules. it will
613 be called with the module name, or, if "RT_FIX_DEPS_CMD" contains a "%s", will
614 replace the "%s" with the module name before calling the program.
622 install missing modules
626 list the status of all dependencies, rather than just the missing ones.
628 -v is equal to --verbose
630 =item specify dependencies
636 database interface for mysql
638 =item --with-postgresql
640 database interface for postgresql
644 database interface for oracle
648 database interface and driver for sqlite (unsupported)
652 libraries needed to support the fastcgi handler
656 libraries needed to support the modperl 1 handler
660 libraries needed to support the modperl 2 handler
664 tools needed for RT development