do not overwrite custom set module paths

Given that the module is now copied to the project directory
when no module path is set, we need the information that the
module path is empty. Therefore hand in the default module path
in a separate variable.
This commit is contained in:
Sarah Hoffmann 2021-02-02 17:33:41 +01:00
parent 36447c488a
commit cb06d1f4ca
5 changed files with 11 additions and 7 deletions

View File

@ -8,6 +8,7 @@ function loadSettings($sProjectDir)
// set of settings.
defined('CONST_DataDir') or define('CONST_DataDir', $_SERVER['NOMINATIM_DATADIR']);
defined('CONST_BinDir') or define('CONST_BinDir', $_SERVER['NOMINATIM_BINDIR']);
defined('CONST_Default_ModulePath') or define('CONST_Default_ModulePath', $_SERVER['NOMINATIM_DATABASE_MODULE_SRC_PATH']);
}
function getSetting($sConfName, $sDefault = null)

View File

@ -148,7 +148,9 @@ class SetupFunctions
// (aka we are running from the build dir).
$sDest = CONST_InstallDir.'/module';
if ($sDest != CONST_Default_ModulePath) {
mkdir($sDest);
if (!file_exists($sDest)) {
mkdir($sDest);
}
if (!copy(CONST_Default_ModulePath.'/nominatim.so', $sDest.'/nominatim.so')) {
echo "Failed to copy database module to $sDest.";
exit(1);
@ -158,6 +160,8 @@ class SetupFunctions
} else {
info('Running from build directory. Leaving database module as is.');
}
} else {
info('Using database module from DATABASE_MODULE_PATH ('.getSetting('DATABASE_MODULE_PATH').').');
}
// Try accessing the C module, so we know early if something is wrong
$this->checkModulePresence(); // raises exception on failure

View File

@ -81,7 +81,7 @@ class CommandlineParser:
for arg in ('module_dir', 'osm2pgsql_path', 'phplib_dir', 'data_dir', 'phpcgi_path'):
setattr(args, arg, Path(kwargs[arg]))
args.project_dir = Path(args.project_dir)
args.project_dir = Path(args.project_dir).resolve()
logging.basicConfig(stream=sys.stderr,
format='%(asctime)s: %(message)s',
@ -91,7 +91,7 @@ class CommandlineParser:
args.config = Configuration(args.project_dir, args.data_dir / 'settings')
log = logging.getLogger()
log.warn('Using project directory: %s', str(args.project_dir))
log.warning('Using project directory: %s', str(args.project_dir))
try:
return args.command.run(args)

View File

@ -26,8 +26,7 @@ def run_legacy_script(script, *args, nominatim_env=None, throw_on_fail=False):
env = nominatim_env.config.get_os_env()
env['NOMINATIM_DATADIR'] = str(nominatim_env.data_dir)
env['NOMINATIM_BINDIR'] = str(nominatim_env.data_dir / 'utils')
if not env['NOMINATIM_DATABASE_MODULE_PATH']:
env['NOMINATIM_DATABASE_MODULE_PATH'] = nominatim_env.module_dir
env['NOMINATIM_DATABASE_MODULE_SRC_PATH'] = nominatim_env.module_dir
if not env['NOMINATIM_OSM2PGSQL_BINARY']:
env['NOMINATIM_OSM2PGSQL_BINARY'] = nominatim_env.osm2pgsql_path

View File

@ -63,8 +63,8 @@ def test_run_legacy_return_dont_throw_on_success(nominatim_env, test_script):
assert 0 == exec_utils.run_legacy_script(fname, nominatim_env=nominatim_env,
throw_on_fail=True)
def test_run_legacy_use_given__module_path(nominatim_env, test_script):
fname = test_script("exit($_SERVER['NOMINATIM_DATABASE_MODULE_PATH'] == 'module' ? 0 : 23);")
def test_run_legacy_use_given_module_path(nominatim_env, test_script):
fname = test_script("exit($_SERVER['NOMINATIM_DATABASE_MODULE_PATH'] == '' ? 0 : 23);")
assert 0 == exec_utils.run_legacy_script(fname, nominatim_env=nominatim_env)