From: Sarah Hoffmann Date: Sun, 28 Feb 2016 15:42:24 +0000 (+0100) Subject: introduce InstallPath, so that stuff can be executed from build dir X-Git-Tag: v3.0.0~198^2~3 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/1ad6f4a1cee50ff5b3f851ffcb49cf198e584d01 introduce InstallPath, so that stuff can be executed from build dir --- diff --git a/CMakeLists.txt b/CMakeLists.txt index e5587741..ceffb6fc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,6 +53,26 @@ find_package(BZip2 REQUIRED) find_package(LibXml2 REQUIRED) include_directories(${LIBXML2_INCLUDE_DIR}) +#----------------------------------------------------------------------------- +# +# Setup settings and paths +# +#----------------------------------------------------------------------------- + +configure_file( + ${PROJECT_SOURCE_DIR}/settings/settings.php + ${PROJECT_BINARY_DIR}/settings/settings.php +) + +configure_file( + ${PROJECT_SOURCE_DIR}/settings/phrase_settings.php + ${PROJECT_BINARY_DIR}/settings/phrase_settings.php +) + +execute_process( + COMMAND ln -s -t ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/utils +) + #----------------------------------------------------------------------------- add_subdirectory(module) diff --git a/lib/init.php b/lib/init.php index 67efdbfd..db984ef8 100644 --- a/lib/init.php +++ b/lib/init.php @@ -2,7 +2,7 @@ @define('CONST_BasePath', dirname(dirname(__FILE__))); - require_once(CONST_BasePath.'/settings/settings.php'); + require_once('settings/settings.php'); require_once(CONST_BasePath.'/lib/lib.php'); require_once(CONST_BasePath.'/lib/leakybucket.php'); require_once(CONST_BasePath.'/lib/db.php'); diff --git a/settings/settings.php b/settings/settings.php index 04ffe162..93d3a9d5 100644 --- a/settings/settings.php +++ b/settings/settings.php @@ -1,5 +1,6 @@ 1000) fail("unable to obtain state file"); - file_put_contents(CONST_BasePath.'/settings/state.txt', $sStateFile); + file_put_contents(CONST_InstallPath.'/settings/state.txt', $sStateFile); echo "Updating DB status\n"; pg_query($oDB->connection, 'TRUNCATE import_status'); $sSQL = "INSERT INTO import_status VALUES('".$aRepMatch[2]."')"; @@ -657,7 +657,7 @@ $bDidSomething = true; $sOutputFile = ''; if (isset($aCMDResult['index-output'])) $sOutputFile = ' -F '.$aCMDResult['index-output']; - $sBaseCmd = CONST_BasePath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$iInstances.$sOutputFile; + $sBaseCmd = CONST_InstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$iInstances.$sOutputFile; passthruCheckReturn($sBaseCmd.' -R 4'); if (!$aCMDResult['index-noanalyse']) pgsqlRunScript('ANALYSE'); passthruCheckReturn($sBaseCmd.' -r 5 -R 25'); diff --git a/utils/specialphrases.php b/utils/specialphrases.php index 97b60dde..020f5f80 100755 --- a/utils/specialphrases.php +++ b/utils/specialphrases.php @@ -15,7 +15,7 @@ ); getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true); - include(CONST_BasePath.'/settings/phrase_settings.php'); + include(CONST_InstallPath.'/settings/phrase_settings.php'); if ($aCMDResult['countries']) { diff --git a/utils/update.php b/utils/update.php index cc275463..a91eb30e 100755 --- a/utils/update.php +++ b/utils/update.php @@ -64,9 +64,6 @@ } */ - // Assume osm2pgsql is in the folder above - $sBasePath = dirname(dirname(__FILE__)); - date_default_timezone_set('Etc/UTC'); $oDB =& getDB(); @@ -349,7 +346,7 @@ if ($aResult['index']) { - passthru(CONST_BasePath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances'].' -r '.$aResult['index-rank']); + passthru(CONST_InstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances'].' -r '.$aResult['index-rank']); } if ($aResult['import-osmosis'] || $aResult['import-osmosis-all']) @@ -361,11 +358,11 @@ $sImportFile = CONST_BasePath.'/data/osmosischange.osc'; $sOsmosisCMD = CONST_Osmosis_Binary; - $sOsmosisConfigDirectory = CONST_BasePath.'/settings'; + $sOsmosisConfigDirectory = CONST_InstallPath.'/settings'; $sCMDDownload = $sOsmosisCMD.' --read-replication-interval workingDirectory='.$sOsmosisConfigDirectory.' --simplify-change --write-xml-change '.$sImportFile; $sCMDCheckReplicationLag = $sOsmosisCMD.' -q --read-replication-lag workingDirectory='.$sOsmosisConfigDirectory; $sCMDImport = $sOsm2pgsqlCmd.' '.$sImportFile; - $sCMDIndex = $sBasePath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances']; + $sCMDIndex = $sInstallPath.'/nominatim/nominatim -i -d '.$aDSNInfo['database'].' -P '.$aDSNInfo['port'].' -t '.$aResult['index-instances']; if (!$aResult['no-npi']) { $sCMDIndex .= '-F '; } @@ -542,8 +539,8 @@ var_dump($iNPIID); exit(1); } - $sConfigDirectory = CONST_BasePath.'/settings'; - $sCMDImportTemplate = $sBasePath.'/nominatim/nominatim -d gazetteer -P 5433 -I -T '.$sBasePath.'/nominatim/partitionedtags.def -F '; + $sConfigDirectory = CONST_InstallPath.'/settings'; + $sCMDImportTemplate = $sBasePath.'/nominatim/nominatim -d gazetteer -P 5433 -I -T '.CONST_BasePath.'/nominatim/partitionedtags.def -F '; while(true) { $fStartTime = time();