From ddddda73284990c94e8db3820aff6c59dfcec981 Mon Sep 17 00:00:00 2001 From: mpilman Date: Sun, 10 Feb 2019 20:51:36 -0800 Subject: [PATCH] docker-compose can now build rpm weirdly it still generates a foundationd-unspecified rpm. However, it is empty and can be ignored for now --- CMakeLists.txt | 46 +-------------------- bindings/java/CMakeLists.txt | 7 +++- bindings/python/CMakeLists.txt | 3 +- build/cmake/build.sh | 2 +- cmake/InstallLayout.cmake | 73 +++++++++++++++++++++++----------- fdbbackup/CMakeLists.txt | 24 +++++------ 6 files changed, 72 insertions(+), 83 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 650819df48..f56f7857cd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -123,50 +123,6 @@ include(FlowCommands) include(CompileVexillographer) -# This macro can be used to install symlinks, which turns out to be -# non-trivial due to CMake version differences and limitations on how -# files can be installed when building binary packages. -# -# The rule for binary packaging is that files (including symlinks) must -# be installed with the standard CMake install() macro. -# -# The rule for non-binary packaging is that CMake 2.6 cannot install() -# symlinks, but can create the symlink at install-time via scripting. -# Though, we assume that CMake 2.6 isn't going to be used to generate -# packages because versions later than 2.8.3 are superior for that purpose. -# -# _filepath: the absolute path to the file to symlink -# _sympath: absolute path of the installed symlink - -macro(InstallSymlink _filepath _sympath) - get_filename_component(_symname ${_sympath} NAME) - get_filename_component(_installdir ${_sympath} PATH) - - if (BINARY_PACKAGING_MODE) - execute_process(COMMAND "${CMAKE_COMMAND}" -E create_symlink - ${_filepath} - ${CMAKE_CURRENT_BINARY_DIR}/${_symname}) - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${_symname} - DESTINATION ${_installdir} - COMPONENT clients) - else () - # scripting the symlink installation at install time should work - # for CMake 2.6.x and 2.8.x - install(CODE " - if (\"\$ENV{DESTDIR}\" STREQUAL \"\") - execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink - ${_filepath} - ${_installdir}/${_symname}) - else () - execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink - ${_filepath} - \$ENV{DESTDIR}/${_installdir}/${_symname}) - endif () - " - COMPONENT clients) - endif () -endmacro(InstallSymlink) - ################################################################################ # Generate config file ################################################################################ @@ -248,3 +204,5 @@ endif() ################################################################################ print_components() + +message(STATUS "CPACK_COMPONENTS_ALL ${CPACK_COMPONENTS_ALL}") diff --git a/bindings/java/CMakeLists.txt b/bindings/java/CMakeLists.txt index 9cfd3d7a93..b55579cbfc 100644 --- a/bindings/java/CMakeLists.txt +++ b/bindings/java/CMakeLists.txt @@ -131,8 +131,11 @@ add_dependencies(fdb-java fdb_java_options fdb_java) add_jar(foundationdb-tests SOURCES ${JAVA_TESTS_SRCS} INCLUDE_JARS fdb-java) add_dependencies(foundationdb-tests fdb_java_options) -install_jar(fdb-java DESTINATION ${FDB_SHARE_DIR}/java COMPONENT java) -install(TARGETS fdb_java DESTINATION ${FDB_LIB_DIR} COMPONENT java) +# TODO[mpilman]: The java RPM will require some more effort (mostly on debian). However, +# most people will use the fat-jar, so it is not clear how high this priority is. + +#install_jar(fdb-java DESTINATION ${FDB_SHARE_DIR}/java COMPONENT java) +#install(TARGETS fdb_java DESTINATION ${FDB_LIB_DIR} COMPONENT java) set(FAT_JAR_BINARIES "NOTFOUND" CACHE STRING "Path of a directory structure with libraries to include in fat jar (a lib directory)") diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index cb7a236e1f..57259e7337 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -41,7 +41,8 @@ vexillographer_compile(TARGET fdb_python_options LANG python OUT ${options_file} add_dependencies(python_binding fdb_python_options) set(out_files "${out_files};${options_file}") -install(FILES ${out_files} DESTINATION ${FDB_PYTHON_INSTALL_DIR} COMPONENT clients) +# TODO[mpilman]: it is not clear whether we want to have rpms for python +#install(FILES ${out_files} DESTINATION ${FDB_PYTHON_INSTALL_DIR} COMPONENT python) # Create sdist configure_file(${CMAKE_CURRENT_SOURCE_DIR}/setup.py.cmake ${CMAKE_CURRENT_BINARY_DIR}/setup.py) diff --git a/build/cmake/build.sh b/build/cmake/build.sh index 79150f5acf..c0de2cd11d 100644 --- a/build/cmake/build.sh +++ b/build/cmake/build.sh @@ -132,7 +132,7 @@ rpm() { then break fi - cpack + fakeroot cpack __res=$? if [ ${__res} -ne 0 ] then diff --git a/cmake/InstallLayout.cmake b/cmake/InstallLayout.cmake index a67fcdbeeb..de7b4c3329 100644 --- a/cmake/InstallLayout.cmake +++ b/cmake/InstallLayout.cmake @@ -1,3 +1,30 @@ +################################################################################ +# Helper Functions +################################################################################ + +function(install_symlink) + set(options "") + set(one_value_options COMPONENT FROM TO) + set(multi_value_options) + cmake_parse_arguments(SYM "${options}" "${one_value_options}" "${multi_value_options}" "${ARGN}") + + if(NOT SYM_COMPONENT OR NOT SYM_FROM OR NOT SYM_TO) + message(FATA_ERROR "Invalid call to install_symlink") + endif() + get_filename_component(dest_dir ${SYM_TO} DIRECTORY) + install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${dest_dir})" COMPONENT ${SYM_COMPONENT}) + install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${SYM_FROM} ${SYM_TO})" COMPONENT ${SYM_COMPONENT}) + install(CODE "message(\"-- Created symlink: ${SYM_FROM} -> ${SYM_TO}\")") +endfunction() +function(install_mkdir) + set(options "") + set(one_value_options COMPONENT NAME) + set(multi_value_options) + cmake_parse_arguments(MK "${options}" "${one_value_options}" "${multi_value_options}" "${ARGN}") + install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${MK_NAME})" COMPONENT ${MK_COMPONENT}) + install(CODE "message(\"-- Created directory: ${MK_NAME}\")") +endfunction() + if(NOT INSTALL_LAYOUT) if(WIN32) set(DEFAULT_INSTALL_LAYOUT "WIN") @@ -56,19 +83,24 @@ elseif(DIR_LAYOUT MATCHES "OSX") set(FDB_INCLUDE_INSTALL_DIR "usr/local/include") set(FDB_PYTHON_INSTALL_DIR "Library/Python/2.7/site-packages/fdb") set(FDB_SHARE_DIR "usr/local/share") -elseif(DIR_LAYOUT MATCHES "RPM") - set(CPACK_GENERATOR RPM) - set(CPACK_PACKAGE_INSTALL_DIRECTORY "/") +else() + if(DIR_LAYOUT MATCHES "RPM") + set(CPACK_GENERATOR RPM) + else() + # DEB + set(CPACK_GENERATOR "DEB") + set(LIBSUFFIX "") + endif() + set(CMAKE_INSTALL_PREFIX "/") + set(CPACK_PACKAGING_INSTALL_PREFIX "/") + set(FDB_CONFIG_DIR "etc/foundationdb") set(FDB_LIB_DIR "usr/lib${LIBSUFFIX}") - set(FDB_LIBEXEC_DIR "usr/${FDB_LIB_DIR}") + set(FDB_LIBEXEC_DIR ${FDB_LIB_DIR}) set(FDB_BIN_DIR "usr/bin") set(FDB_SBIN_DIR "usr/sbin") set(FDB_INCLUDE_INSTALL_DIR "usr/include") set(FDB_PYTHON_INSTALL_DIR "${FDB_LIB_DIR}/python2.7/site-packages/fdb") set(FDB_SHARE_DIR "usr/share") -else() - # DEB - set(CPACK_GENERATOR "DEB") endif() if(INSTALL_LAYOUT MATCHES "OSX") @@ -135,7 +167,9 @@ if(INSTALL_LAYOUT MATCHES "RPM") "/lib/systemd" "/lib/systemd/system" "/etc/rc.d/init.d") - set(CPACK_RPM_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_server_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_clients_DEBUGINFO_PACKAGE ON) + set(CPACK_RPM_BUILD_SOURCE_DIRS_PREFIX /usr/src) set(CPACK_RPM_COMPONENT_INSTALL ON) set(CPACK_RPM_clients_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/packaging/rpm/scripts/preclients.sh) @@ -149,6 +183,12 @@ if(INSTALL_LAYOUT MATCHES "RPM") ${CMAKE_SOURCE_DIR}/packaging/rpm/scripts/preunserver.sh) set(CPACK_RPM_server_PACKAGE_REQUIRES "foundationdb-clients = ${FDB_MAJOR}.${FDB_MINOR}.${FDB_PATCH}") + #set(CPACK_RPM_java_PACKAGE_REQUIRES + # "foundationdb-clients = ${FDB_MAJOR}.${FDB_MINOR}.${FDB_PATCH}") + set(CPACK_RPM_python_PACKAGE_REQUIRES + "foundationdb-clients = ${FDB_MAJOR}.${FDB_MINOR}.${FDB_PATCH}") + install_mkdir(NAME "var/log/foundationdb" COMPONENT server) + install_mkdir(NAME "var/lib/foundationdb" COMPONENT server) endif() ################################################################################ @@ -160,8 +200,8 @@ if(INSTALL_LAYOUT MATCHES "DEB") set(CPACK_DEBIAN_PACKAGE_SECTION "database") set(CPACK_DEBIAN_ENABLE_COMPONENT_DEPENDS ON) - set(CPACK_DEBIAN_server_PACKAGE_DEPENDS "adduser, libc6 (>= 2.11), python (>= 2.6)") - set(CPACK_DEBIAN_clients_PACKAGE_DEPENDS "adduser, libc6 (>= 2.11)") + set(CPACK_DEBIAN_server_PACKAGE_DEPENDS "adduser, libc6 (>= 2.12), python (>= 2.6), foundationdb-clients (= ${FDB_VERSION})") + set(CPACK_DEBIAN_clients_PACKAGE_DEPENDS "adduser, libc6 (>= 2.12)") set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://www.foundationdb.org") set(CPACK_DEBIAN_clients_PACKAGE_CONTROL_EXTRA ${CMAKE_SOURCE_DIR}/packaging/deb/DEBIAN-foundationdb-clients/postinst) @@ -255,16 +295,3 @@ if((INSTALL_LAYOUT MATCHES "RPM") OR (INSTALL_LAYOUT MATCHES "DEB")) endif() endif() endif() - -################################################################################ -# Helper Macros -################################################################################ - -macro(install_symlink filepath sympath compondent) - install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink ${filepath} ${sympath})" COMPONENT ${component}) - install(CODE "message(\"-- Created symlink: ${sympath} -> ${filepath}\")") -endmacro() -macro(install_mkdir dirname component) - install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${dirname})" COMPONENT ${component}) - install(CODE "message(\"-- Created directory: ${dirname}\")") -endmacro() diff --git a/fdbbackup/CMakeLists.txt b/fdbbackup/CMakeLists.txt index c35aec3c3c..35bed6a2c9 100644 --- a/fdbbackup/CMakeLists.txt +++ b/fdbbackup/CMakeLists.txt @@ -5,19 +5,19 @@ add_flow_target(EXECUTABLE NAME fdbbackup SRCS ${FDBBACKUP_SRCS}) target_link_libraries(fdbbackup PRIVATE fdbclient) install(TARGETS fdbbackup DESTINATION ${FDB_BIN_DIR} COMPONENT clients) -install(PROGRAMS $ - DESTINATION ${FDB_LIB_DIR}/foundationdb/backup_agent - RENAME backup_agent +install_symlink( + FROM ${FDB_BIN_DIR}/fdbbackup + TO ${FDB_LIB_DIR}/foundationdb/backup_agent COMPONENT clients) -install(PROGRAMS $ - DESTINATION ${FDB_BIN_DIR} - RENAME fdbrestore +install_symlink( + FROM ${FDB_BIN_DIR}/fdbbackup + TO ${FDB_BIN_DIR}/fdbrestore COMPONENT clients) -install(PROGRAMS $ - DESTINATION ${FDB_BIN_DIR} - RENAME dr_agent +install_symlink( + FROM ${FDB_BIN_DIR}/fdbbackup + TO ${FDB_BIN_DIR}/dr_agent COMPONENT clients) -install(PROGRAMS $ - DESTINATION ${FDB_BIN_DIR} - RENAME fdbdr +install_symlink( + FROM ${FDB_BIN_DIR}/fdbbackup + TO ${FDB_BIN_DIR}/fdbdr COMPONENT clients)