On 04.01.23 23:53, Andres Freund wrote:
  dir_data = get_option('datadir')
-if not (dir_data.contains('pgsql') or dir_data.contains('postgres'))
+if not ((dir_prefix/dir_data).contains('pgsql') or 
(dir_prefix/dir_data).contains('postgres'))
    dir_data = dir_data / pkg
  endif
Hm. Perhaps we should just test once whether prefix contains pgsql/postgres,
and then just otherwise leave the test as is? There afaict can't be a
dir_prefix/dir_* that matches postgres/pgsql that won't also match either of
the components.

You mean something like

    dir_prefix_contains_pg =
      (dir_prefix.contains('pgsql') or dir_prefix.contains('postgres'))

and

    if not (dir_prefix_contains_pg or
           (dir_data.contains('pgsql') or dir_data.contains('postgres'))

Seems more complicated to me.

I think there is also an adjacent issue: The subdir options may be absolute or relative. So if you specify --prefix=/usr/local and --sysconfdir=/etc/postgresql, then

    config_paths_data.set_quoted('SYSCONFDIR', dir_prefix / dir_sysconf)

would produce something like /usr/local/etc/postgresql.

I think maybe we should make all the dir_* variables absolute right at the beginning, like

    dir_lib = get_option('libdir')
    if not fs.is_absolute(dir_lib)
        dir_lib = dir_prefix / dir_lib
    endif

And then the appending stuff could be done after that, keeping the current code.



Reply via email to