Neue Perl-Versionen werden das aktuelle Verzeichnis '.' aus dem
Standard-Include-Pfad @INC entfernen. Das bedeutet für uns, dass wir
nicht mehr einfach »use SL::Dispatcher;« und ähnliche Konstrukte machen
können.
Daher stellt dieser Commit all diejenigen Perl-Dateien, die als externe
Einstiegsquelle dienen, auf die Verwendung von FindBin um. Es werden
nicht nur die Verzeichnisse »modules/override« und »modules/fallback«
behandelt, sondern auch das Installationsverzeichins selber mit in @INC
aufgenommen, um für die Entfernung von '.' gewappnet zu sein.
Zusätzlich wurden die meisten Scripte so modifiziert, dass sie nicht
mehr direkt aus dem kivitendo-Installationsverzeichnis heraus aufgerufen
werden müssen sondern aus beliebigen Verzeichnissen heraus aufgerufen
werden können. Sie wechseln schlicht zu allererst das aktuelle
Verzeichnis ins kivitendo-Installationsverzeichnis.
Perl-Module, die nicht direkt Scripte sind und den Pfad zum
Installationsverzeichnis benötigen (also z.B. SL/DBUpgrade2.pm), dürfen
allerdings FindBin nicht benutzen, weil $FindBin::Bin das Verzeichnis
zum aufgerufenen Perl-Script enthält, und das kann mal dispatcher.pl
sein, mal scripts/dbupgrade2.pl. Für diese Module gibt es weiterhin
SL::System::Process->exe_dir, die das kivitendo-Installationsverzeichnis
zuverlässig ermittelt.
Leider ist es nicht möglich, nur SL::System::Process->exe_dir anstelle
von $FindBin::Bin zu nutzen, da zuerst SL::System::Process eingebunden
werden muss, und um das zu tun, muss das Installationsverzeichnis ja
bereits im Include-Pfad vorhanden sein — typical case of catch 22.
16 files changed:
use SL::Common;
use SL::DBUpgrade2::Base;
use SL::DBUtils;
use SL::Common;
use SL::DBUpgrade2::Base;
use SL::DBUtils;
+use SL::System::Process;
$params{path_suffix} ||= '';
$params{schema} ||= '';
$params{path_suffix} ||= '';
$params{schema} ||= '';
- $params{path} ||= "sql/Pg-upgrade2" . $params{path_suffix};
+ $params{path} ||= SL::System::Process->exe_dir . "/sql/Pg-upgrade2" . $params{path_suffix};
map { $self->{$_} = $params{$_} } keys %params;
map { $self->{$_} = $params{$_} } keys %params;
# parse_html_template('login_screen/user_login')
# parse_html_template('generic/error')
# parse_html_template('login_screen/user_login')
# parse_html_template('generic/error')
-BEGIN {
- use SL::System::Process;
- my $exe_dir = SL::System::Process::exe_dir;
-
- unshift @INC, "${exe_dir}/modules/override"; # Use our own versions of various modules (e.g. YAML).
- push @INC, "${exe_dir}/modules/fallback"; # Only use our own versions of modules if there's no system version.
- unshift @INC, $exe_dir;
-}
-
use Carp;
use CGI qw( -no_xhtml);
use Config::Std;
use Carp;
use CGI qw( -no_xhtml);
use Config::Std;
+use SL::System::Process;
my $environment_initialized;
my $environment_initialized;
# Backwards compatibility: read lx_office.conf.default if
# kivitendo.conf.default does't exist.
# Backwards compatibility: read lx_office.conf.default if
# kivitendo.conf.default does't exist.
- my $default_config = -f "config/kivitendo.conf.default" ? 'kivitendo' : 'lx_office';
- read_config("config/${default_config}.conf.default" => \%::lx_office_conf);
+ my $dir = SL::System::Process->exe_dir;
+ my $default_config = -f "${dir}/config/kivitendo.conf.default" ? 'kivitendo' : 'lx_office';
+ read_config("${dir}/config/${default_config}.conf.default" => \%::lx_office_conf);
_decode_recursively(\%::lx_office_conf);
_decode_recursively(\%::lx_office_conf);
- $file_name ||= -f 'config/kivitendo.conf' ? 'config/kivitendo.conf' : 'config/lx_office.conf';
+ $file_name ||= -f "${dir}/config/kivitendo.conf" ? "${dir}/config/kivitendo.conf" : "${dir}/config/lx_office.conf";
if (-f $file_name) {
read_config($file_name => \ my %local_conf);
if (-f $file_name) {
read_config($file_name => \ my %local_conf);
use parent qw(Rose::Object);
use English qw(-no_match_vars);
use parent qw(Rose::Object);
use English qw(-no_match_vars);
use File::Spec;
use File::Basename;
use File::Spec;
use File::Basename;
+use List::Util qw(first);
+
+my $cached_exe_dir;
- my $dir = dirname(File::Spec->rel2abs($PROGRAM_NAME));
- my $system_dir = File::Spec->catdir($dir, 'SL', 'System');
- return $dir if -d $system_dir && -f File::Spec->catfile($system_dir, 'TaskServer.pm');
+ return $cached_exe_dir if defined $cached_exe_dir;
+
+ my $bin_dir = File::Spec->rel2abs($FindBin::Bin);
+ my @dirs = File::Spec->splitdir($bin_dir);
- my @dirs = reverse File::Spec->splitdir($dir);
- shift @dirs;
- $dir = File::Spec->catdir(reverse @dirs);
- $system_dir = File::Spec->catdir($dir, 'SL', 'System');
- return File::Spec->curdir unless -d $system_dir && -f File::Spec->catfile($system_dir, 'TaskServer.pm');
+ $cached_exe_dir = first { -f File::Spec->catdir(@dirs[0..$_], 'SL', 'System', 'TaskServer.pm') }
+ reverse(0..scalar(@dirs) - 1);
+ $cached_exe_dir = defined($cached_exe_dir) ? File::Spec->catdir(@dirs[0..$cached_exe_dir]) : File::Spec->curdir;
+ return $cached_exe_dir;
+BEGIN {
+ use FindBin;
+
+ unshift(@INC, $FindBin::Bin . '/modules/override'); # Use our own versions of various modules (e.g. YAML).
+ push (@INC, $FindBin::Bin); # '.' will be removed from @INC soon.
+ push (@INC, $FindBin::Bin . '/modules/fallback'); # Only use our own versions of modules if there's no system version.
+}
+
use SL::Dispatcher;
use SL::FCGIFixes;
use SL::LXDebug;
use SL::Dispatcher;
use SL::FCGIFixes;
use SL::LXDebug;
+BEGIN {
+ use FindBin;
+
+ unshift(@INC, $FindBin::Bin . '/modules/override'); # Use our own versions of various modules (e.g. YAML).
+ push (@INC, $FindBin::Bin); # '.' will be removed from @INC soon.
+ push (@INC, $FindBin::Bin . '/modules/fallback'); # Only use our own versions of modules if there's no system version.
+}
+
use SL::Dispatcher;
our $dispatcher = SL::Dispatcher->new('CGI');
use SL::Dispatcher;
our $dispatcher = SL::Dispatcher->new('CGI');
- use SL::System::Process;
- my $exe_dir = SL::System::Process::exe_dir;
- unshift @INC, "${exe_dir}/modules/override"; # Use our own versions of various modules (e.g. YAML).
- push @INC, "${exe_dir}/modules/fallback"; # Only use our own versions of modules if there's no system version.
- unshift @INC, $exe_dir;
+ unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML).
+ push (@INC, $FindBin::Bin . '/..'); # '.' will be removed from @INC soon.
+ push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version.
- if (! -d "bin" || ! -d "SL") {
- print("This tool must be run from the kivitendo ERP base directory.\n");
- exit(1);
- }
- unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML).
- push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version.
+ unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML).
+ push (@INC, $FindBin::Bin . '/..');
+ push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version.
use strict;
use warnings;
use strict;
use warnings;
+
+BEGIN {
+ use FindBin;
+
+ unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML).
+ push (@INC, $FindBin::Bin . '/..'); # '.' will be removed from @INC soon.
+ push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version.
+}
+
use strict;
#use warnings; # corelist and find throw tons of warnings
use File::Find;
use strict;
#use warnings; # corelist and find throw tons of warnings
use File::Find;
'files-with-match|l' => \ my $l,
);
'files-with-match|l' => \ my $l,
);
+chmod($FindBin::Bin . '/..');
+
find(sub {
return unless /(\.p[lm]|console)$/;
find(sub {
return unless /(\.p[lm]|console)$/;
use warnings;
use File::Slurp;
use warnings;
use File::Slurp;
use List::Util qw(first max);
use Template;
use List::Util qw(first max);
use Template;
-my $rel_dir = (first { -f "${_}/SL/ClientJS.pm" } qw(. ..)) || die "ClientJS.pm not found";
+my $rel_dir = $FindBin::Bin . '/..';
my @actions;
foreach (read_file("${rel_dir}/SL/ClientJS.pm")) {
my @actions;
foreach (read_file("${rel_dir}/SL/ClientJS.pm")) {
$output .= sprintf "\n else\%sconsole.log('Unknown action: ' + action[0]);\n", ' ' x (4 + 2 + 6 + 3 + 4 + 2 + $longest + 1);
$output .= sprintf "\n else\%sconsole.log('Unknown action: ' + action[0]);\n", ' ' x (4 + 2 + 6 + 3 + 4 + 2 + $longest + 1);
-my $template = Template->new({ RELATIVE => 1 });
+my $template = Template->new({ ABSOLUTE => 1 });
$template->process($rel_dir . '/scripts/generate_client_js_actions.tpl', { actions => $output }, $rel_dir . '/js/client_js.js') || die $template->error(), "\n";
print "js/client_js.js generated automatically.\n";
$template->process($rel_dir . '/scripts/generate_client_js_actions.tpl', { actions => $output }, $rel_dir . '/js/client_js.js') || die $template->error(), "\n";
print "js/client_js.js generated automatically.\n";
-use strict;
-use Getopt::Long;
-use Pod::Usage;
-use Term::ANSIColor;
-use Text::Wrap;
our $master_templates;
BEGIN {
our $master_templates;
BEGIN {
- unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML).
- push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version.
+ use FindBin;
+
+ unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML).
+ push (@INC, $FindBin::Bin . '/..'); # '.' will be removed from @INC soon.
+ push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version.
# this is a default dir. may be wrong in your installation, change it then
# this is a default dir. may be wrong in your installation, change it then
- $master_templates = './templates/print/';
+ $master_templates = $FindBin::Bin . '/../templates/print/';
+use strict;
+use Getopt::Long;
+use Pod::Usage;
+use Term::ANSIColor;
+use Text::Wrap;
+
unless (eval { require Config::Std; 1 }){
print STDERR <<EOL ;
+------------------------------------------------------------------------------+
unless (eval { require Config::Std; 1 }){
print STDERR <<EOL ;
+------------------------------------------------------------------------------+
- unshift(@INC, 'modules/override'); # Use our own versions of various modules (e.g. YAML).
- push (@INC, 'modules/fallback'); # Only use our own versions of modules if there's no system version.
+ use FindBin;
+
+ unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML).
+ push (@INC, $FindBin::Bin . '/..');
+ push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version.
use YAML ();
use YAML::Loader (); # YAML tries to load Y:L at runtime, but can't find it after we chdir'ed
use SL::DBUpgrade2;
use YAML ();
use YAML::Loader (); # YAML tries to load Y:L at runtime, but can't find it after we chdir'ed
use SL::DBUpgrade2;
+use SL::System::Process;
# we only need to do this for auth atm, because only auth scripts can include new rights, which are translateable
my $auth = 1;
# we only need to do this for auth atm, because only auth scripts can include new rights, which are translateable
my $auth = 1;
- my $dbu = SL::DBUpgrade2->new(auth => $auth, path => '../../sql/Pg-upgrade2-auth');
+ my $dbu = SL::DBUpgrade2->new(auth => $auth, path => SL::System::Process->exe_dir . '/sql/Pg-upgrade2-auth');
for my $upgrade ($dbu->sort_dbupdate_controls) {
for my $string (@{ $upgrade->{locales} || [] }) {
for my $upgrade ($dbu->sort_dbupdate_controls) {
for my $string (@{ $upgrade->{locales} || [] }) {
use Pod::Html;
use File::Find;
use Pod::Html;
use File::Find;
+use FindBin;
+
+chdir($FindBin::Bin . '/..');
my $doc_path = "doc/online";
#my $pod2html_bin = `which pod2html` or die 'cannot find pod2html on your system';
my $doc_path = "doc/online";
#my $pod2html_bin = `which pod2html` or die 'cannot find pod2html on your system';
- unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML).
- push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version.
+ use FindBin;
+
+ unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML).
+ push (@INC, $FindBin::Bin . '/..'); # '.' will be removed from @INC soon.
+ push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version.
}
use CGI qw( -no_xhtml);
}
use CGI qw( -no_xhtml);
use SL::DB::Helper::ALL;
use SL::DB::Helper::Mappings;
use SL::DB::Helper::ALL;
use SL::DB::Helper::Mappings;
+chdir($FindBin::Bin . '/..');
+
my %blacklist = SL::DB::Helper::Mappings->get_blacklist;
my %package_names = SL::DB::Helper::Mappings->get_package_names;
my %blacklist = SL::DB::Helper::Mappings->get_blacklist;
my %package_names = SL::DB::Helper::Mappings->get_package_names;
-
-use List::MoreUtils qw(any);
-
use strict;
my $exe_dir;
BEGIN {
use FindBin;
use strict;
my $exe_dir;
BEGIN {
use FindBin;
- use lib "$FindBin::Bin/..";
- use SL::System::Process;
- $exe_dir = SL::System::Process::exe_dir;
-
- unshift @INC, "${exe_dir}/modules/override"; # Use our own versions of various modules (e.g. YAML).
- push @INC, "${exe_dir}/modules/fallback"; # Only use our own versions of modules if there's no system version.
- unshift @INC, $exe_dir;
-
- chdir($exe_dir) || die "Cannot change directory to ${exe_dir}\n";
+ unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML).
+ push (@INC, $FindBin::Bin . '/..'); # '.' will be removed from @INC soon.
+ push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version.
}
use CGI qw( -no_xhtml);
}
use CGI qw( -no_xhtml);
use Encode qw();
use English qw(-no_match_vars);
use File::Spec;
use Encode qw();
use English qw(-no_match_vars);
use File::Spec;
+use List::MoreUtils qw(any);
use List::Util qw(first);
use POSIX qw(setuid setgid);
use SL::Auth;
use List::Util qw(first);
use POSIX qw(setuid setgid);
use SL::Auth;
use SL::LxOfficeConf;
use SL::Locale;
use SL::Mailer;
use SL::LxOfficeConf;
use SL::Locale;
use SL::Mailer;
+use SL::System::Process;
use SL::System::TaskServer;
use Template;
use SL::System::TaskServer;
use Template;
+$exe_dir = SL::System::Process->exe_dir;
+chdir($exe_dir) || die "Cannot change directory to ${exe_dir}\n";
mkdir SL::System::TaskServer::PID_BASE() if !-d SL::System::TaskServer::PID_BASE();
mkdir SL::System::TaskServer::PID_BASE() if !-d SL::System::TaskServer::PID_BASE();
use Getopt::Long;
BEGIN {
use Getopt::Long;
BEGIN {
- $ENV{HARNESS_OPTIONS} = 'c';
- unshift @INC, 'modules/override';
- push @INC, 'modules/fallback';
+ use FindBin;
+
+ unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML).
+ push (@INC, $FindBin::Bin . '/..'); # '.' will be removed from @INC soon.
+ push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version.
+
+ $ENV{HARNESS_OPTIONS} = 'c';
+
+ chdir($FindBin::Bin . '/..');
}
my @exclude_for_fast = (
}
my @exclude_for_fast = (