mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 02:58:13 +00:00
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:
@@ -8,6 +8,7 @@ function loadSettings($sProjectDir)
|
|||||||
// set of settings.
|
// set of settings.
|
||||||
defined('CONST_DataDir') or define('CONST_DataDir', $_SERVER['NOMINATIM_DATADIR']);
|
defined('CONST_DataDir') or define('CONST_DataDir', $_SERVER['NOMINATIM_DATADIR']);
|
||||||
defined('CONST_BinDir') or define('CONST_BinDir', $_SERVER['NOMINATIM_BINDIR']);
|
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)
|
function getSetting($sConfName, $sDefault = null)
|
||||||
|
|||||||
@@ -148,7 +148,9 @@ class SetupFunctions
|
|||||||
// (aka we are running from the build dir).
|
// (aka we are running from the build dir).
|
||||||
$sDest = CONST_InstallDir.'/module';
|
$sDest = CONST_InstallDir.'/module';
|
||||||
if ($sDest != CONST_Default_ModulePath) {
|
if ($sDest != CONST_Default_ModulePath) {
|
||||||
mkdir($sDest);
|
if (!file_exists($sDest)) {
|
||||||
|
mkdir($sDest);
|
||||||
|
}
|
||||||
if (!copy(CONST_Default_ModulePath.'/nominatim.so', $sDest.'/nominatim.so')) {
|
if (!copy(CONST_Default_ModulePath.'/nominatim.so', $sDest.'/nominatim.so')) {
|
||||||
echo "Failed to copy database module to $sDest.";
|
echo "Failed to copy database module to $sDest.";
|
||||||
exit(1);
|
exit(1);
|
||||||
@@ -158,6 +160,8 @@ class SetupFunctions
|
|||||||
} else {
|
} else {
|
||||||
info('Running from build directory. Leaving database module as is.');
|
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
|
// Try accessing the C module, so we know early if something is wrong
|
||||||
$this->checkModulePresence(); // raises exception on failure
|
$this->checkModulePresence(); // raises exception on failure
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class CommandlineParser:
|
|||||||
|
|
||||||
for arg in ('module_dir', 'osm2pgsql_path', 'phplib_dir', 'data_dir', 'phpcgi_path'):
|
for arg in ('module_dir', 'osm2pgsql_path', 'phplib_dir', 'data_dir', 'phpcgi_path'):
|
||||||
setattr(args, arg, Path(kwargs[arg]))
|
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,
|
logging.basicConfig(stream=sys.stderr,
|
||||||
format='%(asctime)s: %(message)s',
|
format='%(asctime)s: %(message)s',
|
||||||
@@ -91,7 +91,7 @@ class CommandlineParser:
|
|||||||
args.config = Configuration(args.project_dir, args.data_dir / 'settings')
|
args.config = Configuration(args.project_dir, args.data_dir / 'settings')
|
||||||
|
|
||||||
log = logging.getLogger()
|
log = logging.getLogger()
|
||||||
log.warn('Using project directory: %s', str(args.project_dir))
|
log.warning('Using project directory: %s', str(args.project_dir))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
return args.command.run(args)
|
return args.command.run(args)
|
||||||
|
|||||||
@@ -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_env.config.get_os_env()
|
||||||
env['NOMINATIM_DATADIR'] = str(nominatim_env.data_dir)
|
env['NOMINATIM_DATADIR'] = str(nominatim_env.data_dir)
|
||||||
env['NOMINATIM_BINDIR'] = str(nominatim_env.data_dir / 'utils')
|
env['NOMINATIM_BINDIR'] = str(nominatim_env.data_dir / 'utils')
|
||||||
if not env['NOMINATIM_DATABASE_MODULE_PATH']:
|
env['NOMINATIM_DATABASE_MODULE_SRC_PATH'] = nominatim_env.module_dir
|
||||||
env['NOMINATIM_DATABASE_MODULE_PATH'] = nominatim_env.module_dir
|
|
||||||
if not env['NOMINATIM_OSM2PGSQL_BINARY']:
|
if not env['NOMINATIM_OSM2PGSQL_BINARY']:
|
||||||
env['NOMINATIM_OSM2PGSQL_BINARY'] = nominatim_env.osm2pgsql_path
|
env['NOMINATIM_OSM2PGSQL_BINARY'] = nominatim_env.osm2pgsql_path
|
||||||
|
|
||||||
|
|||||||
@@ -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,
|
assert 0 == exec_utils.run_legacy_script(fname, nominatim_env=nominatim_env,
|
||||||
throw_on_fail=True)
|
throw_on_fail=True)
|
||||||
|
|
||||||
def test_run_legacy_use_given__module_path(nominatim_env, test_script):
|
def test_run_legacy_use_given_module_path(nominatim_env, test_script):
|
||||||
fname = test_script("exit($_SERVER['NOMINATIM_DATABASE_MODULE_PATH'] == 'module' ? 0 : 23);")
|
fname = test_script("exit($_SERVER['NOMINATIM_DATABASE_MODULE_PATH'] == '' ? 0 : 23);")
|
||||||
|
|
||||||
assert 0 == exec_utils.run_legacy_script(fname, nominatim_env=nominatim_env)
|
assert 0 == exec_utils.run_legacy_script(fname, nominatim_env=nominatim_env)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user