You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-15 01:04:37 +02:00
Set config path in configure script.
This allows the config path to be modified with a parameter to the configure script, though this commit does not do that. Update the Perl code generator to allow literals so that defaults can be C defines rather than static strings.
This commit is contained in:
@ -200,10 +200,12 @@ sub renderOptional
|
||||
{
|
||||
$strBuildSourceOptional .=
|
||||
(defined($strBuildSourceOptional) && !$bSingleLine ? "\n" : '') .
|
||||
"${strIndent} PARSE_RULE_OPTION_OPTIONAL_DEFAULT(\"" .
|
||||
"${strIndent} PARSE_RULE_OPTION_OPTIONAL_DEFAULT(" .
|
||||
($rhOptional->{&CFGDEF_DEFAULT_LITERAL} ? '' : '"') .
|
||||
(defined($rhOptional->{&CFGDEF_TYPE}) && $rhOptional->{&CFGDEF_TYPE} eq CFGDEF_TYPE_TIME ?
|
||||
$rhOptional->{&CFGDEF_DEFAULT} * 1000 : $rhOptional->{&CFGDEF_DEFAULT}) .
|
||||
"\"),\n";
|
||||
($rhOptional->{&CFGDEF_DEFAULT_LITERAL} ? '' : '"') .
|
||||
"),\n";
|
||||
|
||||
$bSingleLine = true;
|
||||
}
|
||||
|
@ -49,6 +49,9 @@
|
||||
# Sets a default for the option for all commands if listed in the global section, or for specific commands if listed in the
|
||||
# CFGDEF_COMMAND section. All boolean types require a default.
|
||||
#
|
||||
# CFGDEF_DEFAULT_LITERAL:
|
||||
# If the default is a string output it as-is without quoting. This allows C defines to be used as defaults.
|
||||
#
|
||||
# CFGDEF_NEGATE:
|
||||
# The option can be negated with "no" e.g. --no-compress. This applies to options that are only valid on the command line (i.e.
|
||||
# no config section defined) and if not specifically defined, the default is false. All config file boolean options are
|
||||
@ -406,10 +409,6 @@ use constant CFGDEF_DEFAULT_BUFFER_SIZE_MIN => 16384;
|
||||
use constant CFGDEF_DEFAULT_COMPRESS_LEVEL_MIN => 0;
|
||||
use constant CFGDEF_DEFAULT_COMPRESS_LEVEL_MAX => 9;
|
||||
|
||||
use constant CFGDEF_DEFAULT_CONFIG_PATH => '/etc/' . PROJECT_EXE;
|
||||
use constant CFGDEF_DEFAULT_CONFIG => CFGDEF_DEFAULT_CONFIG_PATH . '/' . PROJECT_CONF;
|
||||
use constant CFGDEF_DEFAULT_CONFIG_INCLUDE_PATH => CFGDEF_DEFAULT_CONFIG_PATH . '/conf.d';
|
||||
|
||||
use constant CFGDEF_DEFAULT_DB_TIMEOUT => 1800;
|
||||
use constant CFGDEF_DEFAULT_DB_TIMEOUT_MIN => WAIT_TIME_MINIMUM;
|
||||
use constant CFGDEF_DEFAULT_DB_TIMEOUT_MAX => 86400 * 7;
|
||||
@ -472,6 +471,8 @@ use constant CFGDEF_ALLOW_RANGE => 'allow-ra
|
||||
push @EXPORT, qw(CFGDEF_ALLOW_RANGE);
|
||||
use constant CFGDEF_DEFAULT => 'default';
|
||||
push @EXPORT, qw(CFGDEF_DEFAULT);
|
||||
use constant CFGDEF_DEFAULT_LITERAL => 'default-literal';
|
||||
push @EXPORT, qw(CFGDEF_DEFAULT_LITERAL);
|
||||
use constant CFGDEF_DEPEND => 'depend';
|
||||
push @EXPORT, qw(CFGDEF_DEPEND);
|
||||
use constant CFGDEF_DEPEND_OPTION => 'depend-option';
|
||||
@ -768,7 +769,8 @@ my %hConfigDefine =
|
||||
&CFGOPT_CONFIG =>
|
||||
{
|
||||
&CFGDEF_TYPE => CFGDEF_TYPE_STRING,
|
||||
&CFGDEF_DEFAULT => CFGDEF_DEFAULT_CONFIG,
|
||||
&CFGDEF_DEFAULT => "CFGOPTDEF_CONFIG_PATH \"/\" PROJECT_CONFIG_FILE",
|
||||
&CFGDEF_DEFAULT_LITERAL => true,
|
||||
&CFGDEF_NEGATE => true,
|
||||
},
|
||||
|
||||
@ -776,7 +778,8 @@ my %hConfigDefine =
|
||||
{
|
||||
&CFGDEF_TYPE => CFGDEF_TYPE_PATH,
|
||||
&CFGDEF_INHERIT => CFGOPT_CONFIG,
|
||||
&CFGDEF_DEFAULT => CFGDEF_DEFAULT_CONFIG_INCLUDE_PATH,
|
||||
&CFGDEF_DEFAULT => "CFGOPTDEF_CONFIG_PATH \"/\" PROJECT_CONFIG_INCLUDE_PATH",
|
||||
&CFGDEF_DEFAULT_LITERAL => true,
|
||||
&CFGDEF_NEGATE => false,
|
||||
},
|
||||
|
||||
@ -784,7 +787,8 @@ my %hConfigDefine =
|
||||
{
|
||||
&CFGDEF_TYPE => CFGDEF_TYPE_PATH,
|
||||
&CFGDEF_INHERIT => CFGOPT_CONFIG,
|
||||
&CFGDEF_DEFAULT => CFGDEF_DEFAULT_CONFIG_PATH,
|
||||
&CFGDEF_DEFAULT => "CFGOPTDEF_CONFIG_PATH",
|
||||
&CFGDEF_DEFAULT_LITERAL => true,
|
||||
&CFGDEF_NEGATE => false,
|
||||
},
|
||||
|
||||
@ -2002,7 +2006,8 @@ my %hConfigDefine =
|
||||
&CFGDEF_GROUP => CFGOPTGRP_REPO,
|
||||
&CFGDEF_SECTION => CFGDEF_SECTION_GLOBAL,
|
||||
&CFGDEF_TYPE => CFGDEF_TYPE_STRING,
|
||||
&CFGDEF_DEFAULT => CFGDEF_DEFAULT_CONFIG,
|
||||
&CFGDEF_DEFAULT => "CFGOPTDEF_CONFIG_PATH \"/\" PROJECT_CONFIG_FILE",
|
||||
&CFGDEF_DEFAULT_LITERAL => true,
|
||||
&CFGDEF_NAME_ALT =>
|
||||
{
|
||||
'backup-config' => {&CFGDEF_INDEX => 1, &CFGDEF_RESET => false},
|
||||
@ -2024,14 +2029,16 @@ my %hConfigDefine =
|
||||
{
|
||||
&CFGDEF_TYPE => CFGDEF_TYPE_PATH,
|
||||
&CFGDEF_INHERIT => CFGOPT_REPO_HOST_CONFIG,
|
||||
&CFGDEF_DEFAULT => CFGDEF_DEFAULT_CONFIG_PATH,
|
||||
&CFGDEF_DEFAULT => "CFGOPTDEF_CONFIG_PATH",
|
||||
&CFGDEF_DEFAULT_LITERAL => true,
|
||||
},
|
||||
|
||||
&CFGOPT_REPO_HOST_CONFIG_INCLUDE_PATH =>
|
||||
{
|
||||
&CFGDEF_TYPE => CFGDEF_TYPE_PATH,
|
||||
&CFGDEF_INHERIT => CFGOPT_REPO_HOST_CONFIG,
|
||||
&CFGDEF_DEFAULT => CFGDEF_DEFAULT_CONFIG_INCLUDE_PATH,
|
||||
&CFGDEF_DEFAULT => "CFGOPTDEF_CONFIG_PATH \"/\" PROJECT_CONFIG_INCLUDE_PATH",
|
||||
&CFGDEF_DEFAULT_LITERAL => true,
|
||||
},
|
||||
|
||||
&CFGOPT_REPO_HOST_PORT =>
|
||||
@ -3224,7 +3231,8 @@ my %hConfigDefine =
|
||||
&CFGOPT_PG_HOST_CONFIG =>
|
||||
{
|
||||
&CFGDEF_INHERIT => CFGOPT_PG_HOST_CMD,
|
||||
&CFGDEF_DEFAULT => CFGDEF_DEFAULT_CONFIG,
|
||||
&CFGDEF_DEFAULT => "CFGOPTDEF_CONFIG_PATH \"/\" PROJECT_CONFIG_FILE",
|
||||
&CFGDEF_DEFAULT_LITERAL => true,
|
||||
&CFGDEF_REQUIRED => true,
|
||||
&CFGDEF_NAME_ALT =>
|
||||
{
|
||||
@ -3237,14 +3245,16 @@ my %hConfigDefine =
|
||||
{
|
||||
&CFGDEF_TYPE => CFGDEF_TYPE_PATH,
|
||||
&CFGDEF_INHERIT => CFGOPT_PG_HOST_CMD,
|
||||
&CFGDEF_DEFAULT => CFGDEF_DEFAULT_CONFIG_PATH,
|
||||
&CFGDEF_DEFAULT => "CFGOPTDEF_CONFIG_PATH",
|
||||
&CFGDEF_DEFAULT_LITERAL => true,
|
||||
},
|
||||
|
||||
&CFGOPT_PG_HOST_CONFIG_INCLUDE_PATH =>
|
||||
{
|
||||
&CFGDEF_TYPE => CFGDEF_TYPE_PATH,
|
||||
&CFGDEF_INHERIT => CFGOPT_PG_HOST_CMD,
|
||||
&CFGDEF_DEFAULT => CFGDEF_DEFAULT_CONFIG_INCLUDE_PATH,
|
||||
&CFGDEF_DEFAULT => "CFGOPTDEF_CONFIG_PATH \"/\" PROJECT_CONFIG_INCLUDE_PATH",
|
||||
&CFGDEF_DEFAULT_LITERAL => true,
|
||||
},
|
||||
|
||||
&CFGOPT_PG_HOST_PORT =>
|
||||
|
@ -1,6 +1,8 @@
|
||||
/***********************************************************************************************************************************
|
||||
Build Flags Generated by Configure
|
||||
***********************************************************************************************************************************/
|
||||
#include "version.h"
|
||||
|
||||
// Are test code and asserts disabled?
|
||||
#undef NDEBUG
|
||||
|
||||
@ -15,3 +17,6 @@ Build Flags Generated by Configure
|
||||
|
||||
// Is libzstd present?
|
||||
#undef HAVE_LIBZST
|
||||
|
||||
// Configuration path
|
||||
#undef CFGOPTDEF_CONFIG_PATH
|
||||
|
@ -150,6 +150,10 @@ AC_CHECK_LIB(
|
||||
[AC_DEFINE(HAVE_LIBZST) AC_SUBST(LIBS, "${LIBS} -lzstd")])],
|
||||
[AC_MSG_ERROR([header file <zstd.h> is required])])])
|
||||
|
||||
# Set configuration path
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------
|
||||
AC_DEFINE_UNQUOTED([CFGOPTDEF_CONFIG_PATH], ["/etc/" PROJECT_BIN], [Path for configuration files])
|
||||
|
||||
# Write output
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------
|
||||
AC_CONFIG_HEADERS([build.auto.h])
|
||||
|
@ -878,7 +878,7 @@ static const ParseRuleOption parseRuleOption[CFG_OPTION_TOTAL] =
|
||||
|
||||
PARSE_RULE_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/pgbackrest.conf"),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT(CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE),
|
||||
),
|
||||
),
|
||||
|
||||
@ -948,7 +948,7 @@ static const ParseRuleOption parseRuleOption[CFG_OPTION_TOTAL] =
|
||||
|
||||
PARSE_RULE_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/conf.d"),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT(CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH),
|
||||
),
|
||||
),
|
||||
|
||||
@ -1018,7 +1018,7 @@ static const ParseRuleOption parseRuleOption[CFG_OPTION_TOTAL] =
|
||||
|
||||
PARSE_RULE_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest"),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT(CFGOPTDEF_CONFIG_PATH),
|
||||
),
|
||||
),
|
||||
|
||||
@ -2359,7 +2359,7 @@ static const ParseRuleOption parseRuleOption[CFG_OPTION_TOTAL] =
|
||||
PARSE_RULE_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEPEND(cfgOptPgHost),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/pgbackrest.conf"),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT(CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE),
|
||||
),
|
||||
),
|
||||
|
||||
@ -2390,7 +2390,7 @@ static const ParseRuleOption parseRuleOption[CFG_OPTION_TOTAL] =
|
||||
PARSE_RULE_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEPEND(cfgOptPgHost),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/conf.d"),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT(CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH),
|
||||
),
|
||||
),
|
||||
|
||||
@ -2421,7 +2421,7 @@ static const ParseRuleOption parseRuleOption[CFG_OPTION_TOTAL] =
|
||||
PARSE_RULE_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEPEND(cfgOptPgHost),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest"),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT(CFGOPTDEF_CONFIG_PATH),
|
||||
),
|
||||
),
|
||||
|
||||
@ -4044,7 +4044,7 @@ static const ParseRuleOption parseRuleOption[CFG_OPTION_TOTAL] =
|
||||
PARSE_RULE_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/pgbackrest.conf"),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT(CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_FILE),
|
||||
),
|
||||
),
|
||||
|
||||
@ -4090,7 +4090,7 @@ static const ParseRuleOption parseRuleOption[CFG_OPTION_TOTAL] =
|
||||
PARSE_RULE_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest/conf.d"),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT(CFGOPTDEF_CONFIG_PATH "/" PROJECT_CONFIG_INCLUDE_PATH),
|
||||
),
|
||||
),
|
||||
|
||||
@ -4136,7 +4136,7 @@ static const ParseRuleOption parseRuleOption[CFG_OPTION_TOTAL] =
|
||||
PARSE_RULE_OPTION_OPTIONAL_LIST
|
||||
(
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEPEND(cfgOptRepoHost),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT("/etc/pgbackrest"),
|
||||
PARSE_RULE_OPTION_OPTIONAL_DEFAULT(CFGOPTDEF_CONFIG_PATH),
|
||||
),
|
||||
),
|
||||
|
||||
|
@ -36,8 +36,7 @@ typedef enum
|
||||
/***********************************************************************************************************************************
|
||||
Standard config file name and old default path and name
|
||||
***********************************************************************************************************************************/
|
||||
#define PGBACKREST_CONFIG_FILE PROJECT_BIN ".conf"
|
||||
#define PGBACKREST_CONFIG_ORIG_PATH_FILE "/etc/" PGBACKREST_CONFIG_FILE
|
||||
#define PGBACKREST_CONFIG_ORIG_PATH_FILE "/etc/" PROJECT_CONFIG_FILE
|
||||
STRING_STATIC(PGBACKREST_CONFIG_ORIG_PATH_FILE_STR, PGBACKREST_CONFIG_ORIG_PATH_FILE);
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
@ -49,11 +48,6 @@ Prefix for environment variables
|
||||
// In some environments this will not be extern'd
|
||||
extern char **environ;
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Standard config include path name
|
||||
***********************************************************************************************************************************/
|
||||
#define PGBACKREST_CONFIG_INCLUDE_PATH "conf.d"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Option value constants
|
||||
***********************************************************************************************************************************/
|
||||
@ -782,7 +776,7 @@ cfgFileLoad( // NOTE: Pas
|
||||
optConfigDefault = strNewFmt(
|
||||
"%s/%s", strZ(strLstGet(optionList[cfgOptConfigPath].indexList[0].valueList, 0)), strBaseZ(optConfigDefault));
|
||||
optConfigIncludePathDefault = strNewFmt(
|
||||
"%s/%s", strZ(strLstGet(optionList[cfgOptConfigPath].indexList[0].valueList, 0)), PGBACKREST_CONFIG_INCLUDE_PATH);
|
||||
"%s/%s", strZ(strLstGet(optionList[cfgOptConfigPath].indexList[0].valueList, 0)), PROJECT_CONFIG_INCLUDE_PATH);
|
||||
}
|
||||
|
||||
// If the --no-config option was passed then do not load the config file
|
||||
|
10
src/configure
vendored
10
src/configure
vendored
@ -4308,6 +4308,14 @@ fi
|
||||
fi
|
||||
|
||||
|
||||
# Set configuration path
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------
|
||||
|
||||
cat >>confdefs.h <<_ACEOF
|
||||
#define CFGOPTDEF_CONFIG_PATH "/etc/" PROJECT_BIN
|
||||
_ACEOF
|
||||
|
||||
|
||||
# Write output
|
||||
# ----------------------------------------------------------------------------------------------------------------------------------
|
||||
ac_config_headers="$ac_config_headers build.auto.h"
|
||||
@ -5586,4 +5594,4 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
|
||||
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
|
||||
fi
|
||||
|
||||
# Generated from src/build/configure.ac sha1 c101b90ac0cac36554f202f5cf4aff40c566d957
|
||||
# Generated from src/build/configure.ac sha1 af35157cc6b32faa6d20e46790a4ea22bd24ed3c
|
||||
|
@ -14,6 +14,16 @@ Standard binary name
|
||||
***********************************************************************************************************************************/
|
||||
#define PROJECT_BIN "pgbackrest"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Config file name. The path will vary based on configuration.
|
||||
***********************************************************************************************************************************/
|
||||
#define PROJECT_CONFIG_FILE PROJECT_BIN ".conf"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Config include path name. The parent path will vary based on configuration.
|
||||
***********************************************************************************************************************************/
|
||||
#define PROJECT_CONFIG_INCLUDE_PATH "conf.d"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Format Number -- defines format for info and manifest files as well as on-disk structure. If this number changes then the
|
||||
repository will be invalid unless migration functions are written.
|
||||
|
Reference in New Issue
Block a user