From 6f33e54648eaa13cc1809904db0d83d22bd75803 Mon Sep 17 00:00:00 2001 From: Adriano dos Santos Fernandes <529415+asfernandes@users.noreply.github.com> Date: Thu, 14 Dec 2023 07:23:07 -0300 Subject: [PATCH] Allow to configure Firebird in posix using relative directories with options --with-fb* (#7918) * Allow to configure Firebird in posix using relative directories with options --with-fb*. Relative directories will be interpreted based in the runtime root prefix. --- configure.ac | 16 +++++++++++++--- src/common/TimeZoneUtil.cpp | 4 +++- src/common/utils.cpp | 12 ++++++++++-- src/yvalve/gds.cpp | 5 ++++- 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/configure.ac b/configure.ac index 8cdabafd15..3d03ce3f3f 100644 --- a/configure.ac +++ b/configure.ac @@ -26,9 +26,19 @@ dnl XE_CONF_DIR(param, help, variable, default) define([XE_CONF_DIR],[ AC_ARG_WITH([$1], [AS_HELP_STRING([--with-$1],[$2])], - [[$3]="$withval" - CHANGE_PATH_SUPPORT=no - AC_DEFINE_UNQUOTED([$3], "$[$3]", [$2])], + [ + case "$withval" in + /*) + CHANGE_PATH_SUPPORT=no + [$3]="$withval" + ;; + *) + [$3]='${fb_install_prefix}'/"${withval}" + ;; + esac + + AC_DEFINE_UNQUOTED([$3], "${withval}", [$2]) + ], [[$3]='${fb_install_prefix}[$4]' AC_DEFINE_UNQUOTED([$3], [""], [$2])] ) diff --git a/src/common/TimeZoneUtil.cpp b/src/common/TimeZoneUtil.cpp index 092b04e282..06cf3383c8 100644 --- a/src/common/TimeZoneUtil.cpp +++ b/src/common/TimeZoneUtil.cpp @@ -121,7 +121,9 @@ namespace PathName temp; // Could not call fb_utils::getPrefix here. - if (FB_TZDATADIR[0]) + if (FB_TZDATADIR[0] && PathUtils::isRelative(FB_TZDATADIR)) + PathUtils::concatPath(temp, Config::getRootDirectory(), FB_TZDATADIR); + else if (FB_TZDATADIR[0]) temp = FB_TZDATADIR; else { diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 958fe1c419..d16cc6268b 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -1232,10 +1232,18 @@ Firebird::PathName getPrefix(unsigned int prefType, const char* name) { if (prefType != Firebird::IConfigManager::DIR_CONF && prefType != Firebird::IConfigManager::DIR_MSG && + prefType != Firebird::IConfigManager::DIR_TZDATA && configDir[prefType][0]) { // Value is set explicitly and is not environment overridable PathUtils::concatPath(s, configDir[prefType], name); + + if (PathUtils::isRelative(s)) + { + gds__prefix(tmp, s.c_str()); + return tmp; + } + return s; } } @@ -1316,11 +1324,11 @@ Firebird::PathName getPrefix(unsigned int prefType, const char* name) } if (s.hasData() && name[0]) - { s += PathUtils::dir_sep; - } + s += name; gds__prefix(tmp, s.c_str()); + return tmp; #endif } diff --git a/src/yvalve/gds.cpp b/src/yvalve/gds.cpp index 3f77850f92..6d5149ea3f 100644 --- a/src/yvalve/gds.cpp +++ b/src/yvalve/gds.cpp @@ -4146,7 +4146,10 @@ public: Firebird::PathName msgPrefix; if (!fb_utils::readenv(FB_MSG_ENV, msgPrefix)) { - msgPrefix = FB_MSGDIR[0] ? FB_MSGDIR : prefix; + if (FB_MSGDIR[0] && PathUtils::isRelative(FB_MSGDIR)) + PathUtils::concatPath(msgPrefix, prefix, FB_MSGDIR); + else + msgPrefix = FB_MSGDIR[0] ? FB_MSGDIR : prefix; } msgPrefix.copyTo(fb_prefix_msg_val, sizeof(fb_prefix_msg_val)); fb_prefix_msg = fb_prefix_msg_val;