introduce InstallPath, so that stuff can be executed from build dir

This commit is contained in:
Sarah Hoffmann
2016-02-28 16:42:24 +01:00
parent 932abeb0e2
commit 1ad6f4a1ce
7 changed files with 40 additions and 22 deletions

View File

@@ -53,6 +53,26 @@ find_package(BZip2 REQUIRED)
find_package(LibXml2 REQUIRED) find_package(LibXml2 REQUIRED)
include_directories(${LIBXML2_INCLUDE_DIR}) 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) add_subdirectory(module)

View File

@@ -2,7 +2,7 @@
@define('CONST_BasePath', dirname(dirname(__FILE__))); @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/lib.php');
require_once(CONST_BasePath.'/lib/leakybucket.php'); require_once(CONST_BasePath.'/lib/leakybucket.php');
require_once(CONST_BasePath.'/lib/db.php'); require_once(CONST_BasePath.'/lib/db.php');

View File

@@ -1,5 +1,6 @@
<?php <?php
if (file_exists(CONST_BasePath.'/settings/local.php')) require_once(CONST_BasePath.'/settings/local.php'); @define('CONST_InstallPath', dirname(dirname(__FILE__)));
if (file_exists(CONST_InstallPath.'/settings/local.php')) require_once(CONST_InstallPath.'/settings/local.php');
if (isset($_GET['debug']) && $_GET['debug']) @define('CONST_Debug', true); if (isset($_GET['debug']) && $_GET['debug']) @define('CONST_Debug', true);
// General settings // General settings
@@ -23,7 +24,7 @@
// Paths // Paths
@define('CONST_Path_Postgresql_Contrib', '/usr/share/postgresql/'.CONST_Postgresql_Version.'/contrib'); @define('CONST_Path_Postgresql_Contrib', '/usr/share/postgresql/'.CONST_Postgresql_Version.'/contrib');
@define('CONST_Path_Postgresql_Postgis', CONST_Path_Postgresql_Contrib.'/postgis-'.CONST_Postgis_Version); @define('CONST_Path_Postgresql_Postgis', CONST_Path_Postgresql_Contrib.'/postgis-'.CONST_Postgis_Version);
@define('CONST_Osm2pgsql_Binary', CONST_BasePath.'/osm2pgsql/osm2pgsql'); @define('CONST_Osm2pgsql_Binary', CONST_InstallPath.'/osm2pgsql/osm2pgsql');
@define('CONST_Osmosis_Binary', '/usr/bin/osmosis'); @define('CONST_Osmosis_Binary', '/usr/bin/osmosis');
@define('CONST_Tiger_Data_Path', CONST_BasePath.'/data/tiger'); @define('CONST_Tiger_Data_Path', CONST_BasePath.'/data/tiger');

View File

@@ -13,7 +13,7 @@
); );
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true); getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
include(CONST_BasePath.'/settings/phrase_settings.php'); include(CONST_InstallPath.'/settings/phrase_settings.php');
if (true) if (true)
{ {

View File

@@ -219,9 +219,9 @@
{ {
echo "Functions\n"; echo "Functions\n";
$bDidSomething = true; $bDidSomething = true;
if (!file_exists(CONST_BasePath.'/module/nominatim.so')) fail("nominatim module not built"); if (!file_exists(CONST_InstallPath.'/module/nominatim.so')) fail("nominatim module not built");
$sTemplate = file_get_contents(CONST_BasePath.'/sql/functions.sql'); $sTemplate = file_get_contents(CONST_BasePath.'/sql/functions.sql');
$sTemplate = str_replace('{modulepath}', CONST_BasePath.'/module', $sTemplate); $sTemplate = str_replace('{modulepath}', CONST_InstallPath.'/module', $sTemplate);
if ($aCMDResult['enable-diff-updates']) $sTemplate = str_replace('RETURN NEW; -- @DIFFUPDATES@', '--', $sTemplate); if ($aCMDResult['enable-diff-updates']) $sTemplate = str_replace('RETURN NEW; -- @DIFFUPDATES@', '--', $sTemplate);
if ($aCMDResult['enable-debug-statements']) $sTemplate = str_replace('--DEBUG:', '', $sTemplate); if ($aCMDResult['enable-debug-statements']) $sTemplate = str_replace('--DEBUG:', '', $sTemplate);
if (CONST_Limit_Reindexing) $sTemplate = str_replace('--LIMIT INDEXING:', '', $sTemplate); if (CONST_Limit_Reindexing) $sTemplate = str_replace('--LIMIT INDEXING:', '', $sTemplate);
@@ -292,7 +292,7 @@
echo "Functions\n"; echo "Functions\n";
$sTemplate = file_get_contents(CONST_BasePath.'/sql/functions.sql'); $sTemplate = file_get_contents(CONST_BasePath.'/sql/functions.sql');
$sTemplate = str_replace('{modulepath}', $sTemplate = str_replace('{modulepath}',
CONST_BasePath.'/module', $sTemplate); CONST_InstallPath.'/module', $sTemplate);
pgsqlRunScript($sTemplate); pgsqlRunScript($sTemplate);
} }
@@ -573,16 +573,16 @@
} }
else else
{ {
if (file_exists(CONST_BasePath.'/settings/configuration.txt')) if (file_exists(CONST_InstallPath.'/settings/configuration.txt'))
{ {
echo "settings/configuration.txt already exists\n"; echo "settings/configuration.txt already exists\n";
} }
else else
{ {
passthru(CONST_Osmosis_Binary.' --read-replication-interval-init '.CONST_BasePath.'/settings'); passthru(CONST_Osmosis_Binary.' --read-replication-interval-init '.CONST_InstallPath.'/settings');
// update osmosis configuration.txt with our settings // update osmosis configuration.txt with our settings
passthru("sed -i 's!baseUrl=.*!baseUrl=".CONST_Replication_Url."!' ".CONST_BasePath.'/settings/configuration.txt'); passthru("sed -i 's!baseUrl=.*!baseUrl=".CONST_Replication_Url."!' ".CONST_InstallPath.'/settings/configuration.txt');
passthru("sed -i 's:maxInterval = .*:maxInterval = ".CONST_Replication_MaxInterval.":' ".CONST_BasePath.'/settings/configuration.txt'); passthru("sed -i 's:maxInterval = .*:maxInterval = ".CONST_Replication_MaxInterval.":' ".CONST_InstallPath.'/settings/configuration.txt');
} }
// Find the last node in the DB // Find the last node in the DB
@@ -636,7 +636,7 @@
echo "Getting state file: $sRepURL\n"; echo "Getting state file: $sRepURL\n";
$sStateFile = file_get_contents($sRepURL); $sStateFile = file_get_contents($sRepURL);
if (!$sStateFile || strlen($sStateFile) > 1000) fail("unable to obtain state file"); if (!$sStateFile || strlen($sStateFile) > 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"; echo "Updating DB status\n";
pg_query($oDB->connection, 'TRUNCATE import_status'); pg_query($oDB->connection, 'TRUNCATE import_status');
$sSQL = "INSERT INTO import_status VALUES('".$aRepMatch[2]."')"; $sSQL = "INSERT INTO import_status VALUES('".$aRepMatch[2]."')";
@@ -657,7 +657,7 @@
$bDidSomething = true; $bDidSomething = true;
$sOutputFile = ''; $sOutputFile = '';
if (isset($aCMDResult['index-output'])) $sOutputFile = ' -F '.$aCMDResult['index-output']; 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'); passthruCheckReturn($sBaseCmd.' -R 4');
if (!$aCMDResult['index-noanalyse']) pgsqlRunScript('ANALYSE'); if (!$aCMDResult['index-noanalyse']) pgsqlRunScript('ANALYSE');
passthruCheckReturn($sBaseCmd.' -r 5 -R 25'); passthruCheckReturn($sBaseCmd.' -r 5 -R 25');

View File

@@ -15,7 +15,7 @@
); );
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true); getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
include(CONST_BasePath.'/settings/phrase_settings.php'); include(CONST_InstallPath.'/settings/phrase_settings.php');
if ($aCMDResult['countries']) { if ($aCMDResult['countries']) {

View File

@@ -64,9 +64,6 @@
} }
*/ */
// Assume osm2pgsql is in the folder above
$sBasePath = dirname(dirname(__FILE__));
date_default_timezone_set('Etc/UTC'); date_default_timezone_set('Etc/UTC');
$oDB =& getDB(); $oDB =& getDB();
@@ -349,7 +346,7 @@
if ($aResult['index']) 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']) if ($aResult['import-osmosis'] || $aResult['import-osmosis-all'])
@@ -361,11 +358,11 @@
$sImportFile = CONST_BasePath.'/data/osmosischange.osc'; $sImportFile = CONST_BasePath.'/data/osmosischange.osc';
$sOsmosisCMD = CONST_Osmosis_Binary; $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; $sCMDDownload = $sOsmosisCMD.' --read-replication-interval workingDirectory='.$sOsmosisConfigDirectory.' --simplify-change --write-xml-change '.$sImportFile;
$sCMDCheckReplicationLag = $sOsmosisCMD.' -q --read-replication-lag workingDirectory='.$sOsmosisConfigDirectory; $sCMDCheckReplicationLag = $sOsmosisCMD.' -q --read-replication-lag workingDirectory='.$sOsmosisConfigDirectory;
$sCMDImport = $sOsm2pgsqlCmd.' '.$sImportFile; $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']) { if (!$aResult['no-npi']) {
$sCMDIndex .= '-F '; $sCMDIndex .= '-F ';
} }
@@ -542,8 +539,8 @@
var_dump($iNPIID); var_dump($iNPIID);
exit(1); exit(1);
} }
$sConfigDirectory = CONST_BasePath.'/settings'; $sConfigDirectory = CONST_InstallPath.'/settings';
$sCMDImportTemplate = $sBasePath.'/nominatim/nominatim -d gazetteer -P 5433 -I -T '.$sBasePath.'/nominatim/partitionedtags.def -F '; $sCMDImportTemplate = $sBasePath.'/nominatim/nominatim -d gazetteer -P 5433 -I -T '.CONST_BasePath.'/nominatim/partitionedtags.def -F ';
while(true) while(true)
{ {
$fStartTime = time(); $fStartTime = time();