From ed426ca30da5c61b9aaf7805bdd5c0166c2d0cd1 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Sun, 26 Apr 2015 06:21:28 +0300 Subject: [PATCH] Updated packaging install layout, moved some cmake files around. --- CMakeLists.txt | 14 +++++++++----- cmake/install_layout.cmake | 29 +++++++++++++++++++++++++++++ macros.cmake => cmake/macros.cmake | 28 ---------------------------- etc/postinst.in | 3 +++ plugins/CMakeLists.txt | 10 +++++----- server/core/gateway.c | 14 ++++++++++---- server/core/service.c | 8 +++++--- 7 files changed, 61 insertions(+), 45 deletions(-) create mode 100644 cmake/install_layout.cmake rename macros.cmake => cmake/macros.cmake (83%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 48bf38e8e..bf7e135e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,13 +6,16 @@ endif() message(STATUS "CMake version: ${CMAKE_VERSION}") -include(macros.cmake) - +include(${CMAKE_SOURCE_DIR}/cmake/macros.cmake) +include(${CMAKE_SOURCE_DIR}/cmake/install_layout.cmake) enable_testing() set_variables() set_maxscale_version() -set(CMAKE_INSTALL_PREFIX "/usr/local/mariadb-maxscale" CACHE PATH "Prefix prepended to install directories.") + +set(INSTALL_LAYOUT "STANDALONE" CACHE STRING "Install layout, options are: STANDALONE, RPM, DEB") +set_install_layout(${INSTALL_LAYOUT}) + set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel.") set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake") @@ -37,6 +40,7 @@ if(NOT CURL_FOUND) message(FATAL_ERROR "Failed to locate dependency: libcurl") endif() +set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_MODULE_DIR}:${MAXSCALE_LIBRARY_DIR}) # Make sure the release notes for this release are present if it is a stable one if(${MAXSCALE_VERSION} MATCHES "-stable") @@ -144,7 +148,7 @@ install(FILES ${CMAKE_BINARY_DIR}/ReleaseNotes.txt DESTINATION ${MAXSCALE_SHARE_ install(FILES ${CMAKE_BINARY_DIR}/UpgradingToMaxScale110.txt DESTINATION ${MAXSCALE_SHARE_DIR}) install(FILES server/MaxScale_template.cnf DESTINATION ${MAXSCALE_CONFIG_DIR}) install(FILES server/MaxScale_BinlogServer_template.cnf DESTINATION ${MAXSCALE_CONFIG_DIR}) -install(FILES ${ERRMSG} DESTINATION ${MAXSCALE_LANG_DIR}) +install(FILES ${ERRMSG} DESTINATION ${MAXSCALE_SHARE_DIR}) install(FILES ${CMAKE_SOURCE_DIR}/COPYRIGHT DESTINATION ${MAXSCALE_SHARE_DIR}) install(FILES ${CMAKE_SOURCE_DIR}/README DESTINATION ${MAXSCALE_SHARE_DIR}) install(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION ${MAXSCALE_SHARE_DIR}) @@ -225,7 +229,7 @@ if(PACKAGE) endif() endif() -add_custom_target(buildtests +add_custom_target(buildtestsx COMMAND ${CMAKE_COMMAND} -DDEPS_OK=Y -DBUILD_TESTS=Y -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR} -DWITH_SCRIPTS=N ${CMAKE_SOURCE_DIR} COMMAND make COMMENT "Building test suite..." VERBATIM diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake new file mode 100644 index 000000000..0d594188f --- /dev/null +++ b/cmake/install_layout.cmake @@ -0,0 +1,29 @@ +# Set the install layout +# Possible values: +# STANDALONE - Installs to /usr/local/mariadb-maxscale +# RPM - Installs to /usr +# DEB - Installs to /usr +function(set_install_layout TYPE) + + if(${TYPE} MATCHES "STANDALONE") + + set(CMAKE_INSTALL_PREFIX "/usr/local/mariadb-maxscale" CACHE PATH "Prefix prepended to install directories.") + +# RPM and DEB are the same until differences are found + elseif(${TYPE} MATCHES "RPM") + + set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Prefix prepended to install directories.") + + elseif(${TYPE} MATCHES "DEB") + + set(CMAKE_INSTALL_PREFIX "/usr" CACHE PATH "Prefix prepended to install directories.") + + endif() + + set(MAXSCALE_MODULE_INSTALL lib64/maxscale CACHE PATH "Module installation path") + set(MAXSCALE_LIBRARY_INSTALL lib64/maxscale CACHE PATH "Library installation path") + set(MAXSCALE_EXECUTABLE_INSTALL bin CACHE PATH "Executable installation path") + set(MAXSCALE_SHARE_DIR share/maxscale CACHE PATH "Share file installation path, includes licence and readme files") + set(MAXSCALE_DOC_DIR ${MAXSCALE_SHARE_DIR}/doc CACHE PATH "Documentation installation path, text versions only") + set(MAXSCALE_CONFIG_DIR ${MAXSCALE_SHARE_DIR}/etc CACHE PATH "Configuration file installation path, example configurations will be placed here") +endfunction() diff --git a/macros.cmake b/cmake/macros.cmake similarity index 83% rename from macros.cmake rename to cmake/macros.cmake index d80202534..440c3fed5 100644 --- a/macros.cmake +++ b/cmake/macros.cmake @@ -74,34 +74,6 @@ macro(set_variables) # Build extra tools set(BUILD_TOOLS FALSE CACHE BOOL "Build extra utility tools") - # Change installation directories to standard locations for packages - if(PACKAGE) - set(MAXSCALE_MODULE_INSTALL /lib64/maxscale CACHE PATH "Module installation path") - set(MAXSCALE_LIBRARY_INSTALL /lib64/maxscale CACHE PATH "Library installation path") - message(STATUS "Installing MaxScale modules to: ${MAXSCALE_MODULE_INSTALL}/") - set(MAXSCALE_EXECUTABLE_INSTALL /bin CACHE PATH "Executable installation path") - message(STATUS "Installing MaxScale binaries to: ${MAXSCALE_EXECUTABLE_INSTALL}/") - set(MAXSCALE_CONFIG_DIR /etc CACHE PATH "Configuration file installation path") - set(MAXSCALE_DOC_DIR /usr/share/maxscale/doc CACHE PATH "Documentation installation path") - set(MAXSCALE_LOG_DIR /var/log/maxscale CACHE PATH "Log file directory") - message(STATUS "MaxScale log directory: ${MAXSCALE_LOG_DIR}/") - set(MAXSCALE_CACHE_DIR /var/cache/maxscale CACHE PATH "Service cache file directory") - set(MAXSCALE_LANG_DIR /var/cache/maxscale CACHE PATH "Language file directory(errmsg.sys)") - set(MAXSCALE_SHARE_DIR /usr/share/maxscale CACHE PATH "Share file installation path") - set(CMAKE_INSTALL_RPATH ${CMAKE_INSTALL_RPATH}:${MAXSCALE_MODULE_DIR}:${MAXSCALE_LIBRARY_DIR}) - else() - message(STATUS "Installing MaxScale to: ${CMAKE_INSTALL_PREFIX}/") - set(MAXSCALE_MODULE_INSTALL lib64/maxscale CACHE PATH "Module installation path") - set(MAXSCALE_LIBRARY_INSTALL lib64/maxscale CACHE PATH "Library installation path") - set(MAXSCALE_EXECUTABLE_INSTALL bin CACHE PATH "Executable installation path") - set(MAXSCALE_CONFIG_DIR etc CACHE PATH "Configuration file installation path") - set(MAXSCALE_DOC_DIR doc CACHE PATH "Documentation installation path") - set(MAXSCALE_LOG_DIR log CACHE PATH "Log file directory") - set(MAXSCALE_CACHE_DIR cache CACHE PATH "Service cache file directory") - set(MAXSCALE_LANG_DIR cache CACHE PATH "Log file directory") - set(MAXSCALE_SHARE_DIR . CACHE PATH "Share file installation path") - endif() - endmacro() macro(check_deps) diff --git a/etc/postinst.in b/etc/postinst.in index 4bd193958..46772ca16 100755 --- a/etc/postinst.in +++ b/etc/postinst.in @@ -1,5 +1,8 @@ #!/bin/sh +mkdir -p /var/log/maxscale +mkdir -p /var/cache/maxscale +mkdir -p /var/run/maxscale cp @CMAKE_INSTALL_PREFIX@/maxscale /etc/init.d/ cp @CMAKE_INSTALL_PREFIX@/maxscale.conf /etc/ld.so.conf.d/ /sbin/ldconfig diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index 3ea1eb028..1936ebe84 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -1,5 +1,5 @@ -install(FILES nagios/check_maxscale_monitors.pl DESTINATION plugins/nagios) -install(FILES nagios/check_maxscale_resources.pl DESTINATION plugins/nagios) -install(FILES nagios/check_maxscale_threads.pl DESTINATION plugins/nagios) -install(FILES nagios/maxscale_commands.cfg DESTINATION plugins/nagios) -install(FILES nagios/server1.cfg DESTINATION plugins/nagios) +install(FILES nagios/check_maxscale_monitors.pl DESTINATION ${MAXSCALE_SHARE_DIR}/plugins/nagios) +install(FILES nagios/check_maxscale_resources.pl DESTINATION ${MAXSCALE_SHARE_DIR}/plugins/nagios) +install(FILES nagios/check_maxscale_threads.pl DESTINATION ${MAXSCALE_SHARE_DIR}/plugins/nagios) +install(FILES nagios/maxscale_commands.cfg DESTINATION ${MAXSCALE_SHARE_DIR}/plugins/nagios) +install(FILES nagios/server1.cfg DESTINATION ${MAXSCALE_SHARE_DIR}/plugins/nagios) diff --git a/server/core/gateway.c b/server/core/gateway.c index d2bcd13a9..6b55b2661 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -1276,6 +1276,7 @@ int main(int argc, char **argv) { moduledir = tmp_path; } + break; case 'A': if(handle_path_arg(&tmp_path,optarg,NULL,true,true)) { @@ -1739,7 +1740,6 @@ int main(int argc, char **argv) if(cachedir == NULL) cachedir = strdup(default_cachedir); - if(langdir == NULL) langdir = strdup(default_langdir); if(moduledir == NULL) @@ -1780,11 +1780,13 @@ int main(int argc, char **argv) "Configuration file : %s\n" "Log directory : %s\n" "Data directory : %s\n" - "Module directory : %s\n\n", + "Module directory : %s\n" + "Service cache : %s\n\n", cnf_file_path, logdir, datadir, - moduledir); + moduledir, + cachedir); } LOGIF(LM, @@ -1806,6 +1808,10 @@ int main(int argc, char **argv) (skygw_log_write_flush(LOGFILE_MESSAGE, "Module directory: %s", moduledir))); + LOGIF(LM, + (skygw_log_write_flush(LOGFILE_MESSAGE, + "Service cache: %s", + cachedir))); /*< Update the server options */ for (i = 0; server_options[i]; i++) @@ -1882,7 +1888,7 @@ int main(int argc, char **argv) if (!config_load(cnf_file_path)) { char* fprerr = "Failed to load MaxScale configuration " - "file. Exiting."; + "file. Exiting. See the error log for details."; print_log_n_stderr(false, !daemon_mode, fprerr, fprerr, 0); LOGIF(LE, (skygw_log_write_flush( LOGFILE_ERROR, diff --git a/server/core/service.c b/server/core/service.c index 4584ded24..9455921b7 100644 --- a/server/core/service.c +++ b/server/core/service.c @@ -61,6 +61,7 @@ #include #include #include +#include /** Defined in log_manager.cc */ extern int lm_enabled_logfiles_bitmask; @@ -112,7 +113,7 @@ SERVICE *service; return NULL; if ((service->router = load_module(router, MODULE_ROUTER)) == NULL) { - char* home = get_maxscale_home(); + char* home = get_moduledir(); char* ldpath = getenv("LD_LIBRARY_PATH"); LOGIF(LE, (skygw_log_write_flush( @@ -120,12 +121,13 @@ SERVICE *service; "Error : Unable to load %s module \"%s\".\n\t\t\t" " Ensure that lib%s.so exists in one of the " "following directories :\n\t\t\t " - "- %s/modules\n\t\t\t - %s", + "- %s/modules\n%s%s", MODULE_ROUTER, router, router, home, - ldpath))); + ldpath?"\t\t\t - ":"", + ldpath?ldpath:""))); free(service); return NULL; }