Skip to content

Commit

Permalink
fix: Fix running from sources from using symbolic links
Browse files Browse the repository at this point in the history
  • Loading branch information
g-bougard committed Apr 26, 2024
1 parent dbf3bd3 commit 676721d
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions lib/setup.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use warnings;
use parent qw(Exporter);

use File::Spec;
use Cwd qw(abs_path);
use File::Basename qw(dirname);

our @EXPORT = ('%setup');

Expand All @@ -16,19 +16,18 @@ our %setup = (
vardir => './var',
);

# Compute directly libdir from this setup file as it should be installed
# in expected directory
# Compute directly libdir from this setup file as it should be installed in expected directory
eval {
$setup{libdir} = abs_path(File::Spec->rel2abs('..', __FILE__))
unless ($setup{libdir} && File::Spec->file_name_is_absolute($setup{libdir}));
$setup{libdir} = File::Spec->rel2abs(dirname(__FILE__))
unless $setup{libdir} && File::Spec->file_name_is_absolute($setup{libdir});

# If run from sources, we can try to rebase setup keys to absolute folders related to libdir
if (File::Spec->file_name_is_absolute($setup{libdir})) {
foreach my $key (qw(datadir vardir)) {
# Anyway don't update if target still absolute
next if ($setup{$key} && File::Spec->file_name_is_absolute($setup{$key}));
next if $setup{$key} && File::Spec->file_name_is_absolute($setup{$key});

my $folder = abs_path(File::Spec->rel2abs('../'.$setup{$key}, $setup{libdir}));
my $folder = File::Spec->rel2abs($setup{$key}, dirname($setup{libdir}));
$setup{$key} = $folder if $folder && -d $folder;
}
}
Expand Down

0 comments on commit 676721d

Please sign in to comment.