use SL::Common;
use SL::DBUpgrade2::Base;
use SL::DBUtils;
+use SL::System::Process;
use strict;
$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;
# 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 strict;
use Encode;
+use SL::System::Process;
my $environment_initialized;
# 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);
- $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);
use parent qw(Rose::Object);
use English qw(-no_match_vars);
+use FindBin;
use File::Spec;
use File::Basename;
+use List::Util qw(first);
+
+my $cached_exe_dir;
sub 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 $dir;
+ return $cached_exe_dir;
}
1;
use strict;
+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 strict;
+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');
#!/usr/bin/perl
BEGIN {
- use SL::System::Process;
- my $exe_dir = SL::System::Process::exe_dir;
+ use FindBin;
- 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.
}
use strict;
#!/usr/bin/perl
BEGIN {
- if (! -d "bin" || ! -d "SL") {
- print("This tool must be run from the kivitendo ERP base directory.\n");
- exit(1);
- }
+ use FindBin;
- 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;
#!/usr/bin/perl -l
+
+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;
'files-with-match|l' => \ my $l,
);
+chmod($FindBin::Bin . '/..');
+
find(sub {
return unless /(\.p[lm]|console)$/;
use warnings;
use File::Slurp;
+use FindBin;
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")) {
$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";
#!/usr/bin/perl -w
-use strict;
-use Getopt::Long;
-use Pod::Usage;
-use Term::ANSIColor;
-use Text::Wrap;
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
- $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 ;
+------------------------------------------------------------------------------+
use strict;
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 . '/..');
+ push (@INC, $FindBin::Bin . '/../modules/fallback'); # Only use our own versions of modules if there's no system version.
}
use Carp;
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;
$OUTPUT_AUTOFLUSH = 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} || [] }) {
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';
use strict;
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.
}
use CGI qw( -no_xhtml);
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;
#!/usr/bin/perl
-
-use List::MoreUtils qw(any);
-
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 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 SL::LxOfficeConf;
use SL::Locale;
use SL::Mailer;
+use SL::System::Process;
use SL::System::TaskServer;
use Template;
}
}
-chdir $exe_dir;
+$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();
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 = (