Re: multi-install PostgresNode

From: ilmari(at)ilmari(dot)org (Dagfinn Ilmari Mannsåker )
To: Andrew Dunstan <andrew(at)dunslane(dot)net>
Cc: Michael Paquier <michael(at)paquier(dot)xyz>, Alvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, Peter Eisentraut <peter(dot)eisentraut(at)enterprisedb(dot)com>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: multi-install PostgresNode
Date: 2021-03-24 11:54:03
Message-ID: 87eeg4py1w.fsf@wibble.ilmari.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Andrew Dunstan <andrew(at)dunslane(dot)net> writes:

> And here it is. No subclass, no eval, no magic :-) Some of my colleagues
> are a lot happier ;-)
>
> The downside is that we need to litter PostgresNode with a bunch of
> lines like:
>
> local %ENV = %ENV;
> _set_install_env($self);

I think it would be even neater having a method that returns the desired
environment and then have the other methods do:

local %ENV = $self->_get_install_env();

The function could be something like this:

sub _get_install_env
{
my $self = shift;
my $inst = $self->{_install_path};
return %ENV unless $inst;

my %install_env;
if ($TestLib::windows_os)
{
# Windows picks up DLLs from the PATH rather than *LD_LIBRARY_PATH
# choose the right path separator
if ($Config{osname} eq 'MSWin32')
{
$install_env{PATH} = "$inst/bin;$inst/lib;$ENV{PATH}";
}
else
{
$install_env{PATH} = "$inst/bin:$inst/lib:$ENV{PATH}";
}
}
else
{
my $dylib_name =
$Config{osname} eq 'darwin' ? "DYLD_LIBRARY_PATH" : "LD_LIBRARY_PATH";
$install_env{PATH} = "$inst/bin:$ENV{PATH}";
if (exists $ENV{$dylib_name})
{
$install_env{$dylib_name} = "$inst/lib:$ENV{$dylib_name}";
}
else
{
$install_env{$dylib_name} = "$inst/lib";
}
}

return (%ENV, %install_env);
}

- ilmari
--
"A disappointingly low fraction of the human race is,
at any given time, on fire." - Stig Sandbeck Mathisen

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andrew Dunstan 2021-03-24 12:11:41 Re: multi-install PostgresNode
Previous Message Stephen Frost 2021-03-24 11:46:26 Re: Autovacuum worker doesn't immediately exit on postmaster death