diff options
author | Rasmus Johansson <rasmus@mariadb.com> | 2020-03-20 16:41:54 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2020-03-21 20:20:29 +0100 |
commit | 9e1b3af4a490d6fb6704756aba90281ff5ac033a (patch) | |
tree | 513967006d4809562e38a04ae741916c2c32e119 /scripts/CMakeLists.txt | |
parent | 6fb59d525b7047c82e350d2b721bffc50431eb12 (diff) | |
download | mariadb-git-9e1b3af4a490d6fb6704756aba90281ff5ac033a.tar.gz |
MDEV-21303 Make executables MariaDB named
To change all executables to have a mariadb name I had to:
- Do name changes in every CMakeLists.txt that produces executables
- CREATE_MARIADB_SYMLINK was removed and GET_SYMLINK added by Wlad to reuse the function in other places also
- The scripts/CMakeLists.txt could make use of GET_SYMLINK instead of introducing redundant code, but I thought I'll leave that for next release
- A lot of changes to debian/.install and debian/.links files due to swapping of real executable and symlink. I did not however change the name of the manpages, so the real name is still mysql there and mariadb are symlinks.
- The Windows part needed a change now when we made the executables mariadb -named. MSI (and ZIP) do not support symlinks and to not break backward compatibility we had to include mysql named binaries also. Done by Wlad
Diffstat (limited to 'scripts/CMakeLists.txt')
-rw-r--r-- | scripts/CMakeLists.txt | 133 |
1 files changed, 69 insertions, 64 deletions
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt index 7be46ac1985..8fcae8d5fd2 100644 --- a/scripts/CMakeLists.txt +++ b/scripts/CMakeLists.txt @@ -1,27 +1,39 @@ # Copyright (c) 2006, 2017, Oracle and/or its affiliates. # Copyright (c) 2011, 2017, MariaDB Corporation -# +# # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. -# +# # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. -# +# # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1335 USA # Build comp_sql - used for embedding SQL in C or C++ programs + +MACRO(INSTALL_LINK old new destination component) + EXECUTE_PROCESS( + COMMAND ${CMAKE_COMMAND} -E create_symlink ${old} ${new} + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + ) + INSTALL( + PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/${new} + DESTINATION ${destination} + COMPONENT ${component} + ) +ENDMACRO() + IF(NOT CMAKE_CROSSCOMPILING) INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include) ADD_EXECUTABLE(comp_sql comp_sql.c) TARGET_LINK_LIBRARIES(comp_sql) ENDIF() - # Build mysql_fix_privilege_tables.sql (concatenate 3 sql scripts) IF(NOT WIN32 OR CMAKE_CROSSCOMPILING) FIND_PROGRAM(CAT_EXECUTABLE cat DOC "path to the executable") @@ -29,7 +41,7 @@ IF(NOT WIN32 OR CMAKE_CROSSCOMPILING) ENDIF() IF(CAT_EXECUTABLE) - SET(CAT_COMMAND COMMAND + SET(CAT_COMMAND COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_CURRENT_SOURCE_DIR} ${CAT_EXECUTABLE} mysql_system_tables_fix.sql mysql_system_tables.sql mysql_performance_tables.sql > ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables.sql @@ -67,7 +79,7 @@ ADD_CUSTOM_TARGET(GenFixPrivs ) IF(UNIX) - FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/make_binary_distribution + FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/make_binary_distribution "cd ${CMAKE_BINARY_DIR} && '${CMAKE_CPACK_COMMAND}' -G TGZ --config CPackConfig.cmake\n" ) EXECUTE_PROCESS( COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/make_binary_distribution @@ -92,8 +104,8 @@ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/maria_add_gis_sp.sql.in ${CMAKE_CURRENT_BINARY_DIR}/maria_add_gis_sp_bootstrap.sql ESCAPE_QUOTES @ONLY) IF (NOT WITHOUT_SERVER) -INSTALL(FILES - ${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql +INSTALL(FILES + ${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql ${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_data.sql ${CMAKE_CURRENT_SOURCE_DIR}/mysql_performance_tables.sql ${CMAKE_CURRENT_SOURCE_DIR}/mysql_test_db.sql @@ -120,7 +132,6 @@ IF(CMAKE_GENERATOR MATCHES "Makefiles|Ninja") ENDFOREACH() ENDIF() - IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") SET (PERL_PATH "/usr/local/bin/perl") ELSE() @@ -130,18 +141,18 @@ ENDIF() IF(UNIX) # FIND_PROC and CHECK_PID are used by mysqld_safe IF(CMAKE_SYSTEM_NAME MATCHES "Linux") - SET (FIND_PROC + SET (FIND_PROC "ps wwwp $PID | grep -v mysqld_safe | grep -- $MYSQLD > /dev/null") ENDIF() IF(NOT FIND_PROC AND CMAKE_SYSTEM_NAME MATCHES "SunOS") - SET (FIND_PROC + SET (FIND_PROC "ps -p $PID | grep -v mysqld_safe | grep -- $MYSQLD > /dev/null") ENDIF() IF(NOT FIND_PROC) # BSD style EXECUTE_PROCESS(COMMAND ps -uaxww OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE result) - IF(result MATCHES 0) + IF(result MATCHES 0) SET( FIND_PROC "ps -uaxww | grep -v mysqld_safe | grep -- $MYSQLD | grep $PID > /dev/null") ENDIF() @@ -154,7 +165,7 @@ IF(NOT FIND_PROC) SET( FIND_PROC "ps -ef | grep -v mysqld_safe | grep -- $MYSQLD | grep $PID > /dev/null") ENDIF() ENDIF() - + EXECUTE_PROCESS(COMMAND sh -c "kill -0 $$" OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE result) IF(result MATCHES 0) SET(CHECK_PID "kill -0 $PID > /dev/null 2> /dev/null") @@ -195,18 +206,19 @@ SET(mysqld_locations "$basedir/${INSTALL_SBINDIR} $basedir/libexec $basedir/sbin SET(errmsg_locations "$basedir/${INSTALL_MYSQLSHAREDIR}/english $basedir/share/english $basedir/share/mysql/english") SET(pkgdata_locations "$basedir/${INSTALL_MYSQLSHAREDIR} $basedir/share $basedir/share/mysql") +# install mysql_install_db.sh at this point since it needs +# different values for the above variables that will change +# afterwards IF(UNIX) -CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_install_db.sh - ${CMAKE_CURRENT_BINARY_DIR}/mysql_install_db ESCAPE_QUOTES @ONLY) - EXECUTE_PROCESS( - COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/mysql_install_db - ) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysql_install_db.sh + ${CMAKE_CURRENT_BINARY_DIR}/mariadb-install-db ESCAPE_QUOTES @ONLY) -INSTALL_SCRIPT( - "${CMAKE_CURRENT_BINARY_DIR}/mysql_install_db" - DESTINATION ${INSTALL_SCRIPTDIR} - COMPONENT Server - ) + INSTALL_SCRIPT( + "${CMAKE_CURRENT_BINARY_DIR}/mariadb-install-db" + DESTINATION ${INSTALL_SCRIPTDIR} + COMPONENT Server) + + INSTALL_LINK(mariadb-install-db mysql_install_db ${INSTALL_SCRIPTDIR} Server) ENDIF() SET(prefix "${CMAKE_INSTALL_PREFIX}") @@ -245,7 +257,7 @@ SET(mysql_find_rows_COMPONENT COMPONENT Client) SET(mytop_COMPONENT Mytop) IF(WIN32) - # On Windows, some .sh and some .pl.in files are configured + # On Windows, some .sh and some .pl.in files are configured # The resulting files will have .pl extension (those are perl scripts) # Input files with pl.in extension @@ -284,10 +296,10 @@ ELSE() ENDIF() IF (NOT WITHOUT_SERVER) SET(SERVER_SCRIPTS - mysql_fix_extensions - mysqld_multi - mysqld_safe - mysqldumpslow + mariadb-fix-extensions + mariadbd-multi + mariadbd-safe + mariadb-dumpslow ) ENDIF() # Configure this one, for testing, but do not install it. @@ -296,60 +308,53 @@ ELSE() # On Unix, most of the files end up in the bin directory SET(BIN_SCRIPTS msql2mysql - mysql_config - mysql_setpermission - mysql_secure_installation - mysqlaccess - mysql_convert_table_format - mysql_find_rows + mariadb-setpermission + mariadb-secure-installation + mariadb-access + mariadb-convert-table-format + mariadb-find-rows mytop - mysqlhotcopy + mariadb-hotcopy ${SERVER_SCRIPTS} ${WSREP_SCRIPTS} ${SYSTEMD_SCRIPTS} ) + FOREACH(file ${BIN_SCRIPTS}) - IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh + # set name of executable + GET_SYMLINK(${file} binname) + + if("${binname}" STREQUAL "") + set(binname ${file}) + endif() + + IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${binname}.sh) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${binname}.sh ${CMAKE_CURRENT_BINARY_DIR}/${file} ESCAPE_QUOTES @ONLY) - ELSEIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}) - CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file} - ${CMAKE_CURRENT_BINARY_DIR}/${file} COPYONLY) + ELSEIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${binname}) + CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${binname} + ${CMAKE_CURRENT_BINARY_DIR}/${file} COPYONLY) ELSE() - MESSAGE(FATAL_ERROR "Can not find ${file}.sh or ${file} in " + MESSAGE(FATAL_ERROR "Can not find ${binname}.sh or ${binname} in " "${CMAKE_CURRENT_SOURCE_DIR}" ) ENDIF() - # TODO: The following EXECUTE could be redundant as INSTALL_SCRIPT - # macro does an INSTALL(PROGRAMS ..) that automatically sets +x on - # the executable. - EXECUTE_PROCESS(COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/${file}) + IF(NOT ${file}_COMPONENT) SET(${file}_COMPONENT Server) ENDIF() INSTALL_SCRIPT( - ${CMAKE_CURRENT_BINARY_DIR}/${file} + ${CMAKE_CURRENT_BINARY_DIR}/${file} DESTINATION ${INSTALL_BINDIR} COMPONENT ${${file}_COMPONENT} - ) - ENDFOREACH() + ) - SET (wsrep_sst_rsync_wan ${CMAKE_CURRENT_BINARY_DIR}/wsrep_sst_rsync_wan) - ADD_CUSTOM_COMMAND( - OUTPUT ${wsrep_sst_rsync_wan} - COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink - wsrep_sst_rsync - wsrep_sst_rsync_wan - ) - ADD_CUSTOM_TARGET(symlink_wsrep_sst_rsync - ALL - DEPENDS ${wsrep_sst_rsync_wan} - ) - INSTALL( - FILES ${wsrep_sst_rsync_wan} - DESTINATION ${INSTALL_BINDIR} - COMPONENT Server - ) + # Create symlink + IF (NOT ${binname} STREQUAL ${file}) + INSTALL_LINK(${file} ${binname} ${INSTALL_BINDIR} ${${file}_COMPONENT}) + ENDIF() + ENDFOREACH() + INSTALL_LINK(wsrep_sst_rsync wsrep_sst_rsync_wan ${INSTALL_BINDIR} Server) FOREACH(file ${WSREP_SOURCE}) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh ${CMAKE_CURRENT_BINARY_DIR}/${file} ESCAPE_QUOTES @ONLY) |