]> git.openstreetmap.org Git - nominatim.git/commitdiff
test for existance of country grid in cmake already
authorSarah Hoffmann <lonvia@denofr.de>
Wed, 10 Feb 2021 09:40:36 +0000 (10:40 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Wed, 10 Feb 2021 09:40:36 +0000 (10:40 +0100)
Given that the file potentially gets installed, it needs to be
present during build time already. Checking during the import
is too late.

CMakeLists.txt
lib-php/setup/SetupClass.php

index 02bc490fa4afcd2fac9a80b84d2118ac3c650c0b..691c9adcaafad309533699558a0d7dc33af85b25 100644 (file)
@@ -97,6 +97,17 @@ endif()
 #-----------------------------------------------------------------------------
 
 if (BUILD_IMPORTER)
+   find_file(COUNTRY_GRID_FILE country_osm_grid.sql.gz
+             PATHS ${PROJECT_SOURCE_DIR}/data
+             NO_DEFAULT_PATH
+             DOC "Location of the country grid file."
+            )
+
+   if (NOT COUNTRY_GRID_FILE)
+       message(FATAL_ERROR "\nYou need to download the country_osm_grid first:\n"
+                           "    wget -O ${PROJECT_SOURCE_DIR}/data/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz")
+   endif()
+
    set(CUSTOMSCRIPTS
        check_import_finished.php
        country_languages.php
@@ -221,7 +232,7 @@ if (BUILD_IMPORTER)
     install(DIRECTORY lib-sql DESTINATION ${NOMINATIM_LIBDIR})
 
     install(FILES data/country_name.sql
-                  data/country_osm_grid.sql.gz
+                  ${COUNTRY_GRID_FILE}
                   data/words.sql
             DESTINATION ${NOMINATIM_DATADIR})
 endif()
index 03b0163153ac2ed3775097432663d0e902c65278..fedbb644b4238289a97086a06856c2b7d7ab5d65 100755 (executable)
@@ -166,11 +166,6 @@ class SetupFunctions
         // Try accessing the C module, so we know early if something is wrong
         $this->checkModulePresence(); // raises exception on failure
 
-        if (!file_exists(CONST_DataDir.'/country_osm_grid.sql.gz')) {
-            echo 'Error: you need to download the country_osm_grid first:';
-            echo "\n    wget -O ".CONST_DataDir."/country_osm_grid.sql.gz https://www.nominatim.org/data/country_grid.sql.gz\n";
-            exit(1);
-        }
         $this->pgsqlRunScriptFile(CONST_DataDir.'/country_name.sql');
         $this->pgsqlRunScriptFile(CONST_DataDir.'/country_osm_grid.sql.gz');