First version of working rpm packages

This commit is contained in:
Markus Pilman 2018-05-05 12:08:39 -07:00 committed by Alex Miller
parent 8e5f62011a
commit c654b1bb61
9 changed files with 118 additions and 11 deletions

View File

@ -2,7 +2,7 @@ if(NOT INSTALL_LAYOUT)
set(DEFAULT_INSTALL_LAYOUT "STANDALONE")
endif()
set(INSTALL_LAYOUT "${DEFAULT_INSTALL_LAYOUT}"
CACHE STRING "Installation directory layout. Options are: TARGZ (as in tar.gz installer), WIN (as in zip installer), STANDALONE, RPM, DEB, OSX")
CACHE STRING "Installation directory layout. Options are: TARGZ (as in tar.gz installer), WIN, STANDALONE, RPM, DEB, OSX")
set(DIR_LAYOUT ${INSTALL_LAYOUT})
if(DIR_LAYOUT MATCHES "TARGZ")
@ -35,21 +35,28 @@ if(UNIX)
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 "WIN")
# TODO
else()
# for deb and rpm
if(INSTALL_LAYOUT MATCHES "RPM")
set(CPACK_GENERATOR "RPM")
else()
# DEB
set(CPACK_GENERATOR "DEB")
endif()
set(CMAKE_INSTALL_PREFIX "/")
set(CPACK_PACKAGING_INSTALL_PREFIX "/")
set(FDB_LIB_DIR "usr/lib${LIBSUFFIX}")
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")
endif()
endif()
include(InstallRequiredSystemLibraries)
################################################################################
# Version information
################################################################################
@ -63,6 +70,7 @@ list(GET FDB_VERSION_LIST 2 FDB_PATCH)
# General CPack configuration
################################################################################
include(InstallRequiredSystemLibraries)
set(CPACK_PACKAGE_NAME "foundationdb")
set(CPACK_PACKAGE_VENDOR "FoundationDB Community")
set(CPACK_PACKAGE_VERSION_MAJOR ${FDB_MAJOR})
@ -82,18 +90,45 @@ endif()
# configuration for rpm
if(INSTALL_LAYOUT MATCHES "RPM")
set(CPACK_RPM_server_USER_FILELIST "%config(noreplace) /etc/foundationdb/foundationdb.conf")
set(CPACK_RPM_server_USER_FILELIST
"%config(noreplace) /etc/foundationdb/foundationdb.conf"
"%attr(600, root, root) %config(noreplace) /etc/foundationdb/fdb.cluster")
set(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION
"/usr/sbin" "/usr/share/java" "/usr/lib64/python2.7"
"/usr/lib64/python2.7/site-packages")
set(CPACK_RPM_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/preinstall-client.sh)
#set(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/packaging/rpm/preinstall-server.sh)
#set(CPACK_RPM_server_POST_INSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/packaging/rpm/postinstall-server.sh)
#set(CPACK_RPM_server_PRE_UNINSTALL_SCRIPT_FILE ${CMAKE_SOURCE_DIR}/packaging/rpm/preuninstall-server.sh)
set(CPACK_RPM_clients_PRE_INSTALL_SCRIPT_FILE
${CMAKE_SOURCE_DIR}/packaging/rpm/scripts/preclients.sh)
set(CPACK_RPM_clients_POST_INSTALL_SCRIPT_FILE
${CMAKE_SOURCE_DIR}/packaging/rpm/scripts/postclients.sh)
set(CPACK_RPM_server_PRE_INSTALL_SCRIPT_FILE
${CMAKE_SOURCE_DIR}/packaging/rpm/scripts/preserver.sh)
set(CPACK_RPM_server_POST_INSTALL_SCRIPT_FILE
${CMAKE_SOURCE_DIR}/packaging/rpm/postserver.sh)
set(CPACK_RPM_server_PRE_UNINSTALL_SCRIPT_FILE
${CMAKE_SOURCE_DIR}/packaging/rpm/preunserver.sh)
elseif(INSTALL_LAYOUT MATCHES "OSX")
endif()
################################################################################
# Server configuration
################################################################################
string(RANDOM LENGTH 8 description1)
string(RANDOM LENGTH 8 description2)
set(CLUSTER_DESCRIPTION1 ${description1} CACHE STRING "Cluster description")
set(CLUSTER_DESCRIPTION2 ${description2} CACHE STRING "Cluster description")
configure_file(fdb.cluster.cmake ${CMAKE_CURRENT_BINARY_DIR}/fdb.cluster)
install(FILES ${CMAKE_SOURCE_DIR}/packaging/foundationdb.conf
DESTINATION ${FDB_CONFIG_DIR}
COMPONENT server)
install(FILES ${CMAKE_BINARY_DIR}/fdb.cluster
DESTINATION ${FDB_CONFIG_DIR}
COMPONENT server)
################################################################################
# Helper Macros
################################################################################

View File

@ -6,7 +6,7 @@ add_executable(fdbbackup "${FDBBACKUP_BUILD}")
actor_compile(fdbbackup "${FDBBACKUP_SRCS}")
target_link_libraries(fdbbackup PRIVATE fdbclient)
install(TARGETS fdbbackup DESTINATION ${FDB_BIN_DIR} COMPONENT server)
install(TARGETS fdbbackup DESTINATION ${FDB_BIN_DIR} COMPONENT clients)
install(PROGRAMS $<TARGET_FILE:fdbbackup>
DESTINATION ${FDB_LIB_DIR}/foundationdb/backup_agent
RENAME backup_agent

View File

@ -84,7 +84,7 @@ if (NOT APPLE)
set (FLOW_LIBS ${FLOW_LIBS} rt)
endif()
target_link_libraries(flow PRIVATE ${FLOW_LIBS})
target_link_libraries(flow PUBLIC boost_system Threads::Threads ${CMAKE_DL_LIBS})
target_link_libraries(flow PUBLIC boost_target Threads::Threads ${CMAKE_DL_LIBS})
if(APPLE)
find_library(IO_KIT IOKit)

View File

@ -0,0 +1 @@
${CLUSTER_DESCRIPTION1}:${CLUSTER_DESCRIPTION1}@127.0.0.1:4500

View File

@ -0,0 +1,3 @@
# older versions of this package failed to correctly clean up their .pyc files, which is "very bad"
rm -rf /usr/lib64/python2.6/fdb
exit 0

View File

@ -0,0 +1,29 @@
if [ $1 -eq 1 ]; then
if [ ! -f /etc/foundationdb/fdb.cluster ]; then
chown foundationdb:foundationdb /etc/foundationdb/fdb.cluster
chmod 0664 /etc/foundationdb/fdb.cluster
NEWDB=1
fi
if pidof systemd
then
/usr/bin/systemctl enable foundationdb >/dev/null 2>&1
/usr/bin/systemctl start foundationdb >/dev/null 2>&1
else
/sbin/chkconfig --add foundationdb >/dev/null 2>&1
/sbin/service foundationdb start >/dev/null 2>&1
fi
if [ "$NEWDB" != "" ]; then
/usr/bin/fdbcli -C /etc/foundationdb/fdb.cluster --exec "configure new single memory" --timeout 20 >/dev/null 2>&1
fi
else
if pidof systemd
then
/usr/bin/systemctl condrestart foundationdb >/dev/null 2>&1
else
/sbin/service foundationdb condrestart >/dev/null 2>&1
fi
fi
exit 0

View File

@ -0,0 +1,3 @@
getent group foundationdb >/dev/null || groupadd -r foundationdb >/dev/null
getent passwd foundationdb >/dev/null || useradd -c "FoundationDB" -g foundationdb -s /bin/false -r -d /var/lib/foundationdb foundationdb >/dev/null
exit 0

View File

@ -0,0 +1,24 @@
# This should be ensured by the foundationdb-clients package, but it can't hurt...
getent group foundationdb >/dev/null || groupadd -r foundationdb >/dev/null
getent passwd foundationdb >/dev/null || useradd -c "FoundationDB" -g foundationdb -s /bin/false -r -d /var/lib/foundationdb foundationdb >/dev/null
if [ $1 -gt 1 ]; then
# old versions could leave this behind
rm -f /usr/lib/foundationdb/argparse.pyc
fi
CURRENTVER=$(rpm -q --queryformat %%{VERSION} foundationdb-server) || :
if [ "$CURRENTVER" = "0.1.5" ] || [ "$CURRENTVER" = "0.1.4" ]; then
mv /etc/foundationdb/foundationdb.conf /etc/foundationdb/foundationdb.conf.rpmsave
fi
if [ $1 -eq 0 ]; then
if pidof systemd
then
/usr/bin/systemctl stop foundationdb >/dev/null 2>&1
/usr/bin/systemctl disable foundationdb >/dev/null 2>&1
else
/sbin/service foundationdb stop >/dev/null 2>&1
/sbin/chkconfig --del foundationdb >/dev/null 2>&1
fi
fi
exit 0

View File

@ -0,0 +1,12 @@
if [ $1 -eq 0 ]; then
if pidof systemd
then
/usr/bin/systemctl stop foundationdb >/dev/null 2>&1
/usr/bin/systemctl disable foundationdb >/dev/null 2>&1
else
/sbin/service foundationdb stop >/dev/null 2>&1
/sbin/chkconfig --del foundationdb >/dev/null 2>&1
fi
fi
exit 0