Revision cff913a1
Von Moritz Bunkus vor etwa 8 Jahren hinzugefügt
SL/DBUpgrade2.pm | ||
---|---|---|
7 | 7 |
use SL::Common; |
8 | 8 |
use SL::DBUpgrade2::Base; |
9 | 9 |
use SL::DBUtils; |
10 |
use SL::System::Process; |
|
10 | 11 |
|
11 | 12 |
use strict; |
12 | 13 |
|
... | ... | |
26 | 27 |
|
27 | 28 |
$params{path_suffix} ||= ''; |
28 | 29 |
$params{schema} ||= ''; |
29 |
$params{path} ||= "sql/Pg-upgrade2" . $params{path_suffix};
|
|
30 |
$params{path} ||= SL::System::Process->exe_dir . "/sql/Pg-upgrade2" . $params{path_suffix};
|
|
30 | 31 |
|
31 | 32 |
map { $self->{$_} = $params{$_} } keys %params; |
32 | 33 |
|
SL/Dispatcher.pm | ||
---|---|---|
7 | 7 |
# parse_html_template('login_screen/user_login') |
8 | 8 |
# parse_html_template('generic/error') |
9 | 9 |
|
10 |
BEGIN { |
|
11 |
use SL::System::Process; |
|
12 |
my $exe_dir = SL::System::Process::exe_dir; |
|
13 |
|
|
14 |
unshift @INC, "${exe_dir}/modules/override"; # Use our own versions of various modules (e.g. YAML). |
|
15 |
push @INC, "${exe_dir}/modules/fallback"; # Only use our own versions of modules if there's no system version. |
|
16 |
unshift @INC, $exe_dir; |
|
17 |
} |
|
18 |
|
|
19 | 10 |
use Carp; |
20 | 11 |
use CGI qw( -no_xhtml); |
21 | 12 |
use Config::Std; |
SL/LxOfficeConf.pm | ||
---|---|---|
3 | 3 |
use strict; |
4 | 4 |
|
5 | 5 |
use Encode; |
6 |
use SL::System::Process; |
|
6 | 7 |
|
7 | 8 |
my $environment_initialized; |
8 | 9 |
|
... | ... | |
32 | 33 |
|
33 | 34 |
# Backwards compatibility: read lx_office.conf.default if |
34 | 35 |
# kivitendo.conf.default does't exist. |
35 |
my $default_config = -f "config/kivitendo.conf.default" ? 'kivitendo' : 'lx_office'; |
|
36 |
read_config("config/${default_config}.conf.default" => \%::lx_office_conf); |
|
36 |
my $dir = SL::System::Process->exe_dir; |
|
37 |
my $default_config = -f "${dir}/config/kivitendo.conf.default" ? 'kivitendo' : 'lx_office'; |
|
38 |
read_config("${dir}/config/${default_config}.conf.default" => \%::lx_office_conf); |
|
37 | 39 |
_decode_recursively(\%::lx_office_conf); |
38 | 40 |
|
39 |
$file_name ||= -f 'config/kivitendo.conf' ? 'config/kivitendo.conf' : 'config/lx_office.conf';
|
|
41 |
$file_name ||= -f "${dir}/config/kivitendo.conf" ? "${dir}/config/kivitendo.conf" : "${dir}/config/lx_office.conf";
|
|
40 | 42 |
|
41 | 43 |
if (-f $file_name) { |
42 | 44 |
read_config($file_name => \ my %local_conf); |
SL/System/Process.pm | ||
---|---|---|
5 | 5 |
use parent qw(Rose::Object); |
6 | 6 |
|
7 | 7 |
use English qw(-no_match_vars); |
8 |
use FindBin; |
|
8 | 9 |
use File::Spec; |
9 | 10 |
use File::Basename; |
11 |
use List::Util qw(first); |
|
12 |
|
|
13 |
my $cached_exe_dir; |
|
10 | 14 |
|
11 | 15 |
sub exe_dir { |
12 |
my $dir = dirname(File::Spec->rel2abs($PROGRAM_NAME)); |
|
13 |
my $system_dir = File::Spec->catdir($dir, 'SL', 'System'); |
|
14 |
return $dir if -d $system_dir && -f File::Spec->catfile($system_dir, 'TaskServer.pm'); |
|
16 |
return $cached_exe_dir if defined $cached_exe_dir; |
|
17 |
|
|
18 |
my $bin_dir = File::Spec->rel2abs($FindBin::Bin); |
|
19 |
my @dirs = File::Spec->splitdir($bin_dir); |
|
15 | 20 |
|
16 |
my @dirs = reverse File::Spec->splitdir($dir); |
|
17 |
shift @dirs; |
|
18 |
$dir = File::Spec->catdir(reverse @dirs); |
|
19 |
$system_dir = File::Spec->catdir($dir, 'SL', 'System'); |
|
20 |
return File::Spec->curdir unless -d $system_dir && -f File::Spec->catfile($system_dir, 'TaskServer.pm'); |
|
21 |
$cached_exe_dir = first { -f File::Spec->catdir(@dirs[0..$_], 'SL', 'System', 'TaskServer.pm') } |
|
22 |
reverse(0..scalar(@dirs) - 1); |
|
23 |
$cached_exe_dir = defined($cached_exe_dir) ? File::Spec->catdir(@dirs[0..$cached_exe_dir]) : File::Spec->curdir; |
|
21 | 24 |
|
22 |
return $dir; |
|
25 |
return $cached_exe_dir;
|
|
23 | 26 |
} |
24 | 27 |
|
25 | 28 |
1; |
dispatcher.fpl | ||
---|---|---|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
5 |
BEGIN { |
|
6 |
use FindBin; |
|
7 |
|
|
8 |
unshift(@INC, $FindBin::Bin . '/modules/override'); # Use our own versions of various modules (e.g. YAML). |
|
9 |
push (@INC, $FindBin::Bin); # '.' will be removed from @INC soon. |
|
10 |
push (@INC, $FindBin::Bin . '/modules/fallback'); # Only use our own versions of modules if there's no system version. |
|
11 |
} |
|
12 |
|
|
5 | 13 |
use SL::Dispatcher; |
6 | 14 |
use SL::FCGIFixes; |
7 | 15 |
use SL::LXDebug; |
dispatcher.pl | ||
---|---|---|
2 | 2 |
|
3 | 3 |
use strict; |
4 | 4 |
|
5 |
BEGIN { |
|
6 |
use FindBin; |
|
7 |
|
|
8 |
unshift(@INC, $FindBin::Bin . '/modules/override'); # Use our own versions of various modules (e.g. YAML). |
|
9 |
push (@INC, $FindBin::Bin); # '.' will be removed from @INC soon. |
|
10 |
push (@INC, $FindBin::Bin . '/modules/fallback'); # Only use our own versions of modules if there's no system version. |
|
11 |
} |
|
12 |
|
|
5 | 13 |
use SL::Dispatcher; |
6 | 14 |
|
7 | 15 |
our $dispatcher = SL::Dispatcher->new('CGI'); |
scripts/dbconnect.pl | ||
---|---|---|
1 | 1 |
#!/usr/bin/perl |
2 | 2 |
|
3 | 3 |
BEGIN { |
4 |
use SL::System::Process; |
|
5 |
my $exe_dir = SL::System::Process::exe_dir; |
|
4 |
use FindBin; |
|
6 | 5 |
|
7 |
unshift @INC, "${exe_dir}/modules/override"; # Use our own versions of various modules (e.g. YAML).
|
|
8 |
push @INC, "${exe_dir}/modules/fallback"; # Only use our own versions of modules if there's no system version.
|
|
9 |
unshift @INC, $exe_dir;
|
|
6 |
unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML).
|
|
7 |
push (@INC, $FindBin::Bin . '/..'); # '.' will be removed from @INC soon.
|
|
8 |
push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version.
|
|
10 | 9 |
} |
11 | 10 |
|
12 | 11 |
use strict; |
scripts/dbupgrade2_tool.pl | ||
---|---|---|
1 | 1 |
#!/usr/bin/perl |
2 | 2 |
|
3 | 3 |
BEGIN { |
4 |
if (! -d "bin" || ! -d "SL") { |
|
5 |
print("This tool must be run from the kivitendo ERP base directory.\n"); |
|
6 |
exit(1); |
|
7 |
} |
|
4 |
use FindBin; |
|
8 | 5 |
|
9 |
unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML). |
|
10 |
push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version. |
|
6 |
unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML). |
|
7 |
push (@INC, $FindBin::Bin . '/..'); |
|
8 |
push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version. |
|
11 | 9 |
} |
12 | 10 |
|
13 |
|
|
14 | 11 |
use strict; |
15 | 12 |
use warnings; |
16 | 13 |
|
scripts/find-use.pl | ||
---|---|---|
1 | 1 |
#!/usr/bin/perl -l |
2 |
|
|
3 |
BEGIN { |
|
4 |
use FindBin; |
|
5 |
|
|
6 |
unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML). |
|
7 |
push (@INC, $FindBin::Bin . '/..'); # '.' will be removed from @INC soon. |
|
8 |
push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version. |
|
9 |
} |
|
10 |
|
|
2 | 11 |
use strict; |
3 | 12 |
#use warnings; # corelist and find throw tons of warnings |
4 | 13 |
use File::Find; |
... | ... | |
55 | 64 |
'files-with-match|l' => \ my $l, |
56 | 65 |
); |
57 | 66 |
|
67 |
chmod($FindBin::Bin . '/..'); |
|
68 |
|
|
58 | 69 |
find(sub { |
59 | 70 |
return unless /(\.p[lm]|console)$/; |
60 | 71 |
|
scripts/generate_client_js_actions.pl | ||
---|---|---|
4 | 4 |
use warnings; |
5 | 5 |
|
6 | 6 |
use File::Slurp; |
7 |
use FindBin; |
|
7 | 8 |
use List::Util qw(first max); |
8 | 9 |
use Template; |
9 | 10 |
|
10 |
my $rel_dir = (first { -f "${_}/SL/ClientJS.pm" } qw(. ..)) || die "ClientJS.pm not found";
|
|
11 |
my $rel_dir = $FindBin::Bin . '/..';
|
|
11 | 12 |
my @actions; |
12 | 13 |
|
13 | 14 |
foreach (read_file("${rel_dir}/SL/ClientJS.pm")) { |
... | ... | |
58 | 59 |
|
59 | 60 |
$output .= sprintf "\n else\%sconsole.log('Unknown action: ' + action[0]);\n", ' ' x (4 + 2 + 6 + 3 + 4 + 2 + $longest + 1); |
60 | 61 |
|
61 |
my $template = Template->new({ RELATIVE => 1 });
|
|
62 |
my $template = Template->new({ ABSOLUTE => 1 });
|
|
62 | 63 |
$template->process($rel_dir . '/scripts/generate_client_js_actions.tpl', { actions => $output }, $rel_dir . '/js/client_js.js') || die $template->error(), "\n"; |
63 | 64 |
print "js/client_js.js generated automatically.\n"; |
scripts/installation_check.pl | ||
---|---|---|
1 | 1 |
#!/usr/bin/perl -w |
2 | 2 |
|
3 |
use strict; |
|
4 |
use Getopt::Long; |
|
5 |
use Pod::Usage; |
|
6 |
use Term::ANSIColor; |
|
7 |
use Text::Wrap; |
|
8 | 3 |
our $master_templates; |
9 | 4 |
BEGIN { |
10 |
unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML). |
|
11 |
push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version. |
|
5 |
use FindBin; |
|
6 |
|
|
7 |
unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML). |
|
8 |
push (@INC, $FindBin::Bin . '/..'); # '.' will be removed from @INC soon. |
|
9 |
push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version. |
|
12 | 10 |
|
13 | 11 |
# this is a default dir. may be wrong in your installation, change it then |
14 |
$master_templates = './templates/print/';
|
|
12 |
$master_templates = $FindBin::Bin . '/../templates/print/';
|
|
15 | 13 |
} |
16 | 14 |
|
15 |
use strict; |
|
16 |
use Getopt::Long; |
|
17 |
use Pod::Usage; |
|
18 |
use Term::ANSIColor; |
|
19 |
use Text::Wrap; |
|
20 |
|
|
17 | 21 |
unless (eval { require Config::Std; 1 }){ |
18 | 22 |
print STDERR <<EOL ; |
19 | 23 |
+------------------------------------------------------------------------------+ |
scripts/locales.pl | ||
---|---|---|
10 | 10 |
use strict; |
11 | 11 |
|
12 | 12 |
BEGIN { |
13 |
unshift(@INC, 'modules/override'); # Use our own versions of various modules (e.g. YAML). |
|
14 |
push (@INC, 'modules/fallback'); # Only use our own versions of modules if there's no system version. |
|
13 |
use FindBin; |
|
14 |
|
|
15 |
unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML). |
|
16 |
push (@INC, $FindBin::Bin . '/..'); |
|
17 |
push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version. |
|
15 | 18 |
} |
16 | 19 |
|
17 | 20 |
use Carp; |
... | ... | |
28 | 31 |
use YAML (); |
29 | 32 |
use YAML::Loader (); # YAML tries to load Y:L at runtime, but can't find it after we chdir'ed |
30 | 33 |
use SL::DBUpgrade2; |
34 |
use SL::System::Process; |
|
31 | 35 |
|
32 | 36 |
$OUTPUT_AUTOFLUSH = 1; |
33 | 37 |
|
... | ... | |
546 | 550 |
# we only need to do this for auth atm, because only auth scripts can include new rights, which are translateable |
547 | 551 |
my $auth = 1; |
548 | 552 |
|
549 |
my $dbu = SL::DBUpgrade2->new(auth => $auth, path => '../../sql/Pg-upgrade2-auth');
|
|
553 |
my $dbu = SL::DBUpgrade2->new(auth => $auth, path => SL::System::Process->exe_dir . '/sql/Pg-upgrade2-auth');
|
|
550 | 554 |
|
551 | 555 |
for my $upgrade ($dbu->sort_dbupdate_controls) { |
552 | 556 |
for my $string (@{ $upgrade->{locales} || [] }) { |
scripts/make_docs.pl | ||
---|---|---|
4 | 4 |
|
5 | 5 |
use Pod::Html; |
6 | 6 |
use File::Find; |
7 |
use FindBin; |
|
8 |
|
|
9 |
chdir($FindBin::Bin . '/..'); |
|
7 | 10 |
|
8 | 11 |
my $doc_path = "doc/online"; |
9 | 12 |
#my $pod2html_bin = `which pod2html` or die 'cannot find pod2html on your system'; |
scripts/rose_auto_create_model.pl | ||
---|---|---|
3 | 3 |
use strict; |
4 | 4 |
|
5 | 5 |
BEGIN { |
6 |
unshift @INC, "modules/override"; # Use our own versions of various modules (e.g. YAML). |
|
7 |
push @INC, "modules/fallback"; # Only use our own versions of modules if there's no system version. |
|
6 |
use FindBin; |
|
7 |
|
|
8 |
unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML). |
|
9 |
push (@INC, $FindBin::Bin . '/..'); # '.' will be removed from @INC soon. |
|
10 |
push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version. |
|
8 | 11 |
} |
9 | 12 |
|
10 | 13 |
use CGI qw( -no_xhtml); |
... | ... | |
30 | 33 |
use SL::DB::Helper::ALL; |
31 | 34 |
use SL::DB::Helper::Mappings; |
32 | 35 |
|
36 |
chdir($FindBin::Bin . '/..'); |
|
37 |
|
|
33 | 38 |
my %blacklist = SL::DB::Helper::Mappings->get_blacklist; |
34 | 39 |
my %package_names = SL::DB::Helper::Mappings->get_package_names; |
35 | 40 |
|
scripts/task_server.pl | ||
---|---|---|
1 | 1 |
#!/usr/bin/perl |
2 | 2 |
|
3 |
|
|
4 |
use List::MoreUtils qw(any); |
|
5 |
|
|
6 | 3 |
use strict; |
7 | 4 |
|
8 | 5 |
my $exe_dir; |
9 | 6 |
|
10 | 7 |
BEGIN { |
11 | 8 |
use FindBin; |
12 |
use lib "$FindBin::Bin/.."; |
|
13 | 9 |
|
14 |
use SL::System::Process; |
|
15 |
$exe_dir = SL::System::Process::exe_dir; |
|
16 |
|
|
17 |
unshift @INC, "${exe_dir}/modules/override"; # Use our own versions of various modules (e.g. YAML). |
|
18 |
push @INC, "${exe_dir}/modules/fallback"; # Only use our own versions of modules if there's no system version. |
|
19 |
unshift @INC, $exe_dir; |
|
20 |
|
|
21 |
chdir($exe_dir) || die "Cannot change directory to ${exe_dir}\n"; |
|
10 |
unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML). |
|
11 |
push (@INC, $FindBin::Bin . '/..'); # '.' will be removed from @INC soon. |
|
12 |
push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version. |
|
22 | 13 |
} |
23 | 14 |
|
24 | 15 |
use CGI qw( -no_xhtml); |
... | ... | |
29 | 20 |
use Encode qw(); |
30 | 21 |
use English qw(-no_match_vars); |
31 | 22 |
use File::Spec; |
23 |
use List::MoreUtils qw(any); |
|
32 | 24 |
use List::Util qw(first); |
33 | 25 |
use POSIX qw(setuid setgid); |
34 | 26 |
use SL::Auth; |
... | ... | |
43 | 35 |
use SL::LxOfficeConf; |
44 | 36 |
use SL::Locale; |
45 | 37 |
use SL::Mailer; |
38 |
use SL::System::Process; |
|
46 | 39 |
use SL::System::TaskServer; |
47 | 40 |
use Template; |
48 | 41 |
|
... | ... | |
294 | 287 |
} |
295 | 288 |
} |
296 | 289 |
|
297 |
chdir $exe_dir; |
|
290 |
$exe_dir = SL::System::Process->exe_dir; |
|
291 |
chdir($exe_dir) || die "Cannot change directory to ${exe_dir}\n"; |
|
298 | 292 |
|
299 | 293 |
mkdir SL::System::TaskServer::PID_BASE() if !-d SL::System::TaskServer::PID_BASE(); |
300 | 294 |
|
t/test.pl | ||
---|---|---|
8 | 8 |
use Getopt::Long; |
9 | 9 |
|
10 | 10 |
BEGIN { |
11 |
$ENV{HARNESS_OPTIONS} = 'c'; |
|
12 |
unshift @INC, 'modules/override'; |
|
13 |
push @INC, 'modules/fallback'; |
|
11 |
use FindBin; |
|
12 |
|
|
13 |
unshift(@INC, $FindBin::Bin . '/../modules/override'); # Use our own versions of various modules (e.g. YAML). |
|
14 |
push (@INC, $FindBin::Bin . '/..'); # '.' will be removed from @INC soon. |
|
15 |
push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version. |
|
16 |
|
|
17 |
$ENV{HARNESS_OPTIONS} = 'c'; |
|
18 |
|
|
19 |
chdir($FindBin::Bin . '/..'); |
|
14 | 20 |
} |
15 | 21 |
|
16 | 22 |
my @exclude_for_fast = ( |
Auch abrufbar als: Unified diff
Startup: Include-Pfade mittels FindBin ermitteln
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.