Revision 424d6ead
Von Moritz Bunkus vor mehr als 13 Jahren hinzugefügt
SL/LxOfficeConf.pm | ||
---|---|---|
5 | 5 |
use Config::Std; |
6 | 6 |
use Encode; |
7 | 7 |
|
8 |
my $environment_initialized; |
|
9 |
|
|
8 | 10 |
sub read { |
9 | 11 |
my ($class, $file_name) = @_; |
10 | 12 |
|
... | ... | |
18 | 20 |
_decode_recursively(\%local_conf); |
19 | 21 |
_flat_merge(\%::lx_office_conf, \%local_conf); |
20 | 22 |
} |
23 |
|
|
24 |
_init_environment(); |
|
25 |
_determine_application_paths(); |
|
21 | 26 |
} |
22 | 27 |
|
23 | 28 |
sub _decode_recursively { |
... | ... | |
45 | 50 |
} |
46 | 51 |
} |
47 | 52 |
|
53 |
sub _init_environment { |
|
54 |
return if $environment_initialized; |
|
55 |
|
|
56 |
my %key_map = ( lib => { name => 'PERL5LIB', append_path => 1 }, |
|
57 |
path => { name => 'PATH', append_path => 1 }, |
|
58 |
); |
|
59 |
my $cfg = $::lx_office_conf{environment} || {}; |
|
60 |
|
|
61 |
while (my ($key, $value) = each %{ $cfg }) { |
|
62 |
next unless $value; |
|
63 |
|
|
64 |
my $info = $key_map{$key} || {}; |
|
65 |
$key = $info->{name} || $key; |
|
66 |
|
|
67 |
if ($info->{append_path}) { |
|
68 |
$value = ':' . $value unless $value =~ m/^:/ || !$ENV{$key}; |
|
69 |
$value = $ENV{$key} . $value; |
|
70 |
} |
|
71 |
|
|
72 |
$ENV{$key} = $value; |
|
73 |
} |
|
74 |
|
|
75 |
$environment_initialized = 1; |
|
76 |
} |
|
77 |
|
|
78 |
sub _determine_application_paths { |
|
79 |
my @paths = grep { $_ } split m/:/, $ENV{PATH}; |
|
80 |
|
|
81 |
foreach my $key (keys %{ $::lx_office_conf{applications} }) { |
|
82 |
my ($program) = split m/\s+/, $::lx_office_conf{applications}->{$key}; |
|
83 |
next if $program =~ m|/|; |
|
84 |
|
|
85 |
foreach my $path (@paths) { |
|
86 |
next unless -f "${path}/${program}"; |
|
87 |
$::lx_office_conf{applications}->{$key} = "${path}/" . $::lx_office_conf{applications}->{$key}; |
|
88 |
last; |
|
89 |
} |
|
90 |
} |
|
91 |
} |
|
92 |
|
|
48 | 93 |
1; |
Auch abrufbar als: Unified diff
In Konfiguration angegebene Anwendungen in PATH suchen
Fix für Bug 1690.