Re: multi-install PostgresNode - Mailing list pgsql-hackers

From ilmari@ilmari.org (Dagfinn Ilmari Mannsåker)
Subject Re: multi-install PostgresNode
Date
Msg-id 87eeg4py1w.fsf@wibble.ilmari.org
Whole thread Raw
In response to Re: multi-install PostgresNode  (Andrew Dunstan <andrew@dunslane.net>)
Responses Re: multi-install PostgresNode  (Andrew Dunstan <andrew@dunslane.net>)
Re: multi-install PostgresNode  (Alvaro Herrera <alvherre@alvh.no-ip.org>)
List pgsql-hackers
Andrew Dunstan <andrew@dunslane.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



pgsql-hackers by date:

Previous
From: Stephen Frost
Date:
Subject: Re: Autovacuum worker doesn't immediately exit on postmaster death
Next
From: Andrew Dunstan
Date:
Subject: Re: multi-install PostgresNode