]> git.openstreetmap.org Git - nominatim.git/commitdiff
introduce InstallPath, so that stuff can be executed from build dir
authorSarah Hoffmann <lonvia@denofr.de>
Sun, 28 Feb 2016 15:42:24 +0000 (16:42 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Sat, 12 Mar 2016 08:40:43 +0000 (09:40 +0100)
CMakeLists.txt
lib/init.php
settings/settings.php
utils/country_languages.php
utils/setup.php
utils/specialphrases.php
utils/update.php

index e5587741a125892e7ac6a756854a577d5498a448..ceffb6fccd217d39e5594694ddc963f8b93afc50 100644 (file)
@@ -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)
index 67efdbfdf6edb3c8894f7d8a487adfde7d193633..db984ef8c4c893bac16f2b42680cb5845f85b78f 100644 (file)
@@ -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');
index 04ffe1621caa785362c4a6d55aa69875029b9b43..93d3a9d5b4cfc5733056ad60541b462bc310f4d8 100644 (file)
@@ -1,5 +1,6 @@
 <?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);
 
        // General settings
@@ -23,7 +24,7 @@
        // Paths
        @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_Osm2pgsql_Binary', CONST_BasePath.'/osm2pgsql/osm2pgsql');
+       @define('CONST_Osm2pgsql_Binary', CONST_InstallPath.'/osm2pgsql/osm2pgsql');
        @define('CONST_Osmosis_Binary', '/usr/bin/osmosis');
        @define('CONST_Tiger_Data_Path', CONST_BasePath.'/data/tiger');
 
index 8360ae6672c9bcafdb8c357f1859a0d9c9b876a8..7e200e5b4581be78ea29acd1ca6bb4129f835464 100755 (executable)
@@ -13,7 +13,7 @@
         );
         getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
 
-       include(CONST_BasePath.'/settings/phrase_settings.php');
+       include(CONST_InstallPath.'/settings/phrase_settings.php');
 
        if (true)
        {
index eff7b71b447fef7fd36bab87e3db8569fef84231..259201bfc1461d649d878c3418c165e59d1e0a7d 100755 (executable)
        {
                echo "Functions\n";
                $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 = 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-debug-statements']) $sTemplate = str_replace('--DEBUG:', '', $sTemplate);
                if (CONST_Limit_Reindexing) $sTemplate = str_replace('--LIMIT INDEXING:', '', $sTemplate);
                echo "Functions\n";
                $sTemplate = file_get_contents(CONST_BasePath.'/sql/functions.sql');
                $sTemplate = str_replace('{modulepath}',
-                                            CONST_BasePath.'/module', $sTemplate);
+                                            CONST_InstallPath.'/module', $sTemplate);
                pgsqlRunScript($sTemplate);
        }
 
                }
                else
                {
-                       if (file_exists(CONST_BasePath.'/settings/configuration.txt'))
+                       if (file_exists(CONST_InstallPath.'/settings/configuration.txt'))
                        {
                                echo "settings/configuration.txt already exists\n";
                        }
                        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
-                               passthru("sed -i 's!baseUrl=.*!baseUrl=".CONST_Replication_Url."!' ".CONST_BasePath.'/settings/configuration.txt');
-                               passthru("sed -i 's:maxInterval = .*:maxInterval = ".CONST_Replication_MaxInterval.":' ".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_InstallPath.'/settings/configuration.txt');
                        }
 
                        // Find the last node in the DB
                                echo "Getting state file: $sRepURL\n";
                                $sStateFile = file_get_contents($sRepURL);
                                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";
                                pg_query($oDB->connection, 'TRUNCATE import_status');
                                $sSQL = "INSERT INTO import_status VALUES('".$aRepMatch[2]."')";
                $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');
index 97b60dde39e974f15d24159061aadac2072bb1c9..020f5f8004a283547185af43423d36b6e6208444 100755 (executable)
@@ -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']) {
index cc2754633e262f34155afca5819c22074c73d45c..a91eb30ea1ddb16615d6d2e14cd9a3cb7672fc7e 100755 (executable)
@@ -64,9 +64,6 @@
        }
 */
 
-       // Assume osm2pgsql is in the folder above
-       $sBasePath = dirname(dirname(__FILE__));
-
        date_default_timezone_set('Etc/UTC');
 
        $oDB =& getDB();
 
        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'])
 
                $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 ';
                }
                        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();