2 package Module::Install::RTx::Factory;
3 use Module::Install::Base; @ISA = qw(Module::Install::Base);
9 my ($self, $action, $name, $version) = @_;
11 unshift @INC, substr(delete($INC{'RT.pm'}), 0, -5) if $INC{'RT.pm'};
14 unshift @INC, "$RT::LocalPath/lib" if $RT::LocalPath;
16 $RT::SbinPath ||= $RT::LocalPath;
17 $RT::SbinPath =~ s/local$/sbin/;
19 foreach my $file ($RT::CORE_CONFIG_FILE, $RT::SITE_CONFIG_FILE) {
20 next if !-e $file or -r $file;
21 die "No permission to read $file\n-- please re-run $0 with suitable privileges.\n";
28 my $lib_path = File::Basename::dirname($INC{'RT.pm'});
30 push @args, "-I$RT::LocalPath/lib" if $RT::LocalPath;
33 "$RT::SbinPath/rt-setup-database",
34 "--action" => $action,
35 ($action eq 'upgrade' ? () : ("--datadir" => "etc")),
36 (($action eq 'insert') ? ("--datafile" => "etc/initialdata") : ()),
37 "--dba" => $RT::DatabaseAdmin || $RT::DatabaseUser,
38 "--prompt-for-dba-password" => '',
39 (RT::System->can('AddUpgradeHistory') ? ("--package" => $name, "--ext-version" => $version) : ()),
41 # If we're upgrading against an RT which isn't at least 4.2 (has
42 # AddUpgradeHistory) then pass --package. Upgrades against later RT
43 # releases will pick up --package from AddUpgradeHistory.
44 if ($action eq 'upgrade' and
45 not RT::System->can('AddUpgradeHistory')) {
46 push @args, "--package" => $name;
50 (system($^X, @args) == 0) or die "...returned with error: $?\n";