From 5d95a72758f685ca6e08e5f5d82dccbe895aaa04 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sun, 17 Jan 2021 22:03:54 +0100 Subject: [PATCH 1/1] probe for php_cgi in cmake to be used for querying --- CMakeLists.txt | 13 ++++++++++++- cmake/tool.tmpl | 3 ++- nominatim/cli.py | 16 ++++++++++------ 3 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3a9ceed9..c6f63a8b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -86,8 +86,19 @@ if (BUILD_API OR BUILD_IMPORTER) # sanity check if PHP binary exists if (NOT EXISTS ${PHP_BIN}) message(FATAL_ERROR "PHP binary not found. Install php or provide location with -DPHP_BIN=/path/php ") + else() + message (STATUS "Using PHP binary " ${PHP_BIN}) + endif() + if (NOT PHPCGI_BIN) + find_program (PHPCGI_BIN php-cgi) + endif() + # sanity check if PHP binary exists + if (NOT EXISTS ${PHPCGI_BIN}) + message(WARNING "php-cgi binary not found. nominatim tool will not provide query functions.") + set (PHPCGI_BIN "") + else() + message (STATUS "Using php-cgi binary " ${PHPCGI_BIN}) endif() - message (STATUS "Using PHP binary " ${PHP_BIN}) endif() #----------------------------------------------------------------------------- diff --git a/cmake/tool.tmpl b/cmake/tool.tmpl index 43646792..3bba72c3 100755 --- a/cmake/tool.tmpl +++ b/cmake/tool.tmpl @@ -11,4 +11,5 @@ from nominatim import cli exit(cli.nominatim(module_dir='@CMAKE_BINARY_DIR@/module', osm2pgsql_path='@CMAKE_BINARY_DIR@/osm2pgsql/osm2pgsql', phplib_dir='@CMAKE_SOURCE_DIR@/lib', - data_dir='@CMAKE_SOURCE_DIR@')) + data_dir='@CMAKE_SOURCE_DIR@', + phpcgi_path='@PHPCGI_BIN@')) diff --git a/nominatim/cli.py b/nominatim/cli.py index 65ea90bb..4fadaa9f 100644 --- a/nominatim/cli.py +++ b/nominatim/cli.py @@ -435,7 +435,7 @@ class AdminWarm: class QueryExport: """\ - Export addresses as CSV file from a Nominatim database. + Export addresses as CSV file from the database. """ @staticmethod @@ -522,10 +522,14 @@ def nominatim(**kwargs): parser.add_subcommand('refresh', UpdateRefresh) parser.add_subcommand('export', QueryExport) - parser.add_subcommand('search', QueryTodo) - parser.add_subcommand('reverse', QueryTodo) - parser.add_subcommand('lookup', QueryTodo) - parser.add_subcommand('details', QueryTodo) - parser.add_subcommand('status', QueryTodo) + + if kwargs.get('phpcgi_path'): + parser.add_subcommand('search', QueryTodo) + parser.add_subcommand('reverse', QueryTodo) + parser.add_subcommand('lookup', QueryTodo) + parser.add_subcommand('details', QueryTodo) + parser.add_subcommand('status', QueryTodo) + else: + parser.parser.epilog = 'php-cgi not found. Query commands not available.' return parser.run(**kwargs) -- 2.39.5