From 371e34d52beedf73ebc124688ec6cf6692d96acf Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Thu, 9 Nov 2017 05:23:48 +0100 Subject: [PATCH] Introduce support for a basedir This is meant to help pass the tests again. --- src/configure.c | 31 ++++++++++++++++++++++++------- src/configure.h | 1 + 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/configure.c b/src/configure.c index 3a2112b..00df646 100644 --- a/src/configure.c +++ b/src/configure.c @@ -371,15 +371,32 @@ static int _configure_detect_programs(Configure * configure) if(config_set(configure->programs, section, programs[i].name, programs[i].program) != 0) return -1; - if(config_load(configure->programs, filename) != 0) - configure_warning(0, "%s: %s", filename, - "Could not load program definitions"); - if((filename = string_new_append(DATADIR "/" PACKAGE "/platform/", - sHostOS[configure->os], ".conf", NULL)) - != NULL - && config_load(configure->programs, filename) != 0) + /* load the global database */ + if(configure->prefs->basedir != NULL + && (filename = string_new_append( + configure->prefs->basedir, + "../data/" PACKAGE ".conf", + NULL)) == NULL) + 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, "Could not load program definitions"); + string_delete(filename); return ret; } diff --git a/src/configure.h b/src/configure.h index 61f4e3b..75c9e50 100644 --- a/src/configure.h +++ b/src/configure.h @@ -130,6 +130,7 @@ extern const struct ExtensionType * sExtensionType; typedef struct _ConfigurePrefs { int flags; + char * basedir; char * bindir; char * destdir; char * includedir;