Introduce support for a basedir

This is meant to help pass the tests again.
This commit is contained in:
Pierre Pronchery 2017-11-09 05:23:48 +01:00
parent 62e8819deb
commit 371e34d52b
2 changed files with 25 additions and 7 deletions

View File

@ -371,15 +371,32 @@ static int _configure_detect_programs(Configure * configure)
if(config_set(configure->programs, section, programs[i].name, if(config_set(configure->programs, section, programs[i].name,
programs[i].program) != 0) programs[i].program) != 0)
return -1; return -1;
if(config_load(configure->programs, filename) != 0) /* load the global database */
configure_warning(0, "%s: %s", filename, if(configure->prefs->basedir != NULL
"Could not load program definitions"); && (filename = string_new_append(
if((filename = string_new_append(DATADIR "/" PACKAGE "/platform/", configure->prefs->basedir,
sHostOS[configure->os], ".conf", NULL)) "../data/" PACKAGE ".conf",
!= NULL NULL)) == NULL)
&& config_load(configure->programs, filename) != 0) return -configure_error(1, "%s", error_get(NULL));
if(filename != NULL && config_load(configure->programs, filename) != 0)
configure_warning(0, "%s: %s", filename,
"Could not load program definitions");
if(configure->prefs->basedir != NULL)
string_delete(filename);
/* load the database for the current system */
if(configure->prefs->basedir != NULL)
filename = string_new_append(configure->prefs->basedir,
"/platform/", sHostOS[configure->os], ".conf",
NULL);
else
filename = string_new_append(DATADIR "/" PACKAGE "/platform/",
sHostOS[configure->os], ".conf", NULL);
if(filename == NULL)
return -configure_error(1, "%s", error_get(NULL));
else if(config_load(configure->programs, filename) != 0)
configure_warning(0, "%s: %s", filename, configure_warning(0, "%s: %s", filename,
"Could not load program definitions"); "Could not load program definitions");
string_delete(filename);
return ret; return ret;
} }

View File

@ -130,6 +130,7 @@ extern const struct ExtensionType * sExtensionType;
typedef struct _ConfigurePrefs typedef struct _ConfigurePrefs
{ {
int flags; int flags;
char * basedir;
char * bindir; char * bindir;
char * destdir; char * destdir;
char * includedir; char * includedir;