Skip to content
Snippets Groups Projects
Commit 264379f1 authored by Roman Tsisyk's avatar Roman Tsisyk
Browse files

Refactor sysvinit/systemd configuration and fix tarantool-common package

Needed for Fedora buildbot
parent 106e2d74
No related branches found
No related tags found
No related merge requests found
......@@ -356,7 +356,7 @@ add_dependencies(build_bundled_libs misc)
include(BuildSophia)
sophia_build()
option(ENABLE_RPM "Enable install of a RPM specific files" OFF)
option(WITH_SYSVINIT "Enable install of sysvinit scripts" OFF)
# cpack config. called package.cmake to avoid
# conflicts with the global CPack.cmake (On MacOS X
......
# Scripts for a tarantoolctl packaging
set(SYSV_INITD_PATH ${CMAKE_INSTALL_LIBDIR}/tarantool/tarantool.init)
#
# tarantoolctl
#
# Default path to data in default/tarantool
if (NOT TARANTOOL_DATADIR)
set(TARANTOOL_DATADIR "/var/lib/tarantool")
endif()
message (STATUS "TARANTOOL_DATADIR: ${TARANTOOL_DATADIR}")
set(TARANTOOL_DATADIR "${CMAKE_INSTALL_LOCALSTATEDIR}/lib/tarantool")
message (STATUS "tarantoolctl datadir: ${TARANTOOL_DATADIR}")
set(TARANTOOL_LOGDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/log/tarantool")
message (STATUS "tarantoolctl logdir: ${TARANTOOL_LOGDIR}")
set(TARANTOOL_RUNDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/run/tarantool")
message (STATUS "tarantoolctl rundir: ${TARANTOOL_RUNDIR}")
configure_file("tarantool.service.in" "tarantool.service")
# config file for tarantoolctl
if (NOT IS_DIRECTORY "${CMAKE_INSTALL_SYSCONFDIR}/sysconfig")
# Debian/Ubuntu/etc.
set(SYSCONFIG_DEFAULT "default")
else()
# RedHat/Fedora/etc.
set(SYSCONFIG_DEFAULT "sysconfig")
endif()
configure_file(default/tarantool.in default/tarantool)
if (ENABLE_RPM)
# chmod +x 655
if (WITH_SYSTEMD)
message (STATUS "Building RPM with SYSTEMD")
install (FILES ${PROJECT_BINARY_DIR}/extra/dist/tarantool.service DESTINATION ${SYSTEMD_SERVICES_INSTALL_DIR}
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
install (FILES tarantool.init DESTINATION ${CMAKE_INSTALL_LIBDIR}/tarantool/
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
else (WITH_SYSTEMD)
message (STATUS "Building RPM without SYSTEMD")
install (FILES tarantool.init DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/init.d/
RENAME tarantool
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
endif(WITH_SYSTEMD)
install (FILES ${PROJECT_BINARY_DIR}/extra/dist/default/tarantool DESTINATION
${CMAKE_INSTALL_SYSCONFDIR}/sysconfig/
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ)
else (ENABLE_RPM)
install (FILES ${PROJECT_BINARY_DIR}/extra/dist/default/tarantool DESTINATION
${CMAKE_INSTALL_SYSCONFDIR}/default/
install (FILES ${PROJECT_BINARY_DIR}/extra/dist/default/tarantool DESTINATION
${CMAKE_INSTALL_SYSCONFDIR}/${SYSCONFIG_DEFAULT}/
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ)
endif(ENABLE_RPM)
# tarantoolctl itself
install (FILES tarantoolctl DESTINATION ${CMAKE_INSTALL_BINDIR}
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
......@@ -54,6 +34,7 @@ install (FILES tarantoolctl DESTINATION ${CMAKE_INSTALL_BINDIR}
WORLD_READ WORLD_EXECUTE
)
# an example instance script for tarantoolctl
install (FILES example.lua DESTINATION
${CMAKE_INSTALL_SYSCONFDIR}/tarantool/instances.available
PERMISSIONS
......@@ -62,7 +43,46 @@ install (FILES example.lua DESTINATION
WORLD_READ WORLD_READ
)
# man page for tarantoolctl
pod2man (
tarantoolctl "tarantoolctl" 1
"tarantoolctl instances control"
)
#
# Init scripts
#
if (WITH_SYSTEMD)
message (STATUS "Installing systemd scripts")
# NOTE: always install tarantool.init to ${CMAKE_INSTALL_PREFIX}/lib
# instead of ${CMAKE_INSTALL_LIBDIR} because LIBDIR depends on the target
# architecture, but tarantool-common is noarch package.
set(SYSV_INITD_DIR ${CMAKE_INSTALL_PREFIX}/lib/tarantool/)
configure_file("tarantool.service.in" "tarantool.service")
install (FILES ${PROJECT_BINARY_DIR}/extra/dist/tarantool.service DESTINATION ${SYSTEMD_SERVICES_INSTALL_DIR}
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
install (FILES tarantool.init DESTINATION ${SYSV_INITD_DIR}
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
elseif (WITH_SYSVINIT)
message (STATUS "Installing sysvinit scripts")
install (FILES tarantool.init DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/init.d/
RENAME tarantool
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
install (FILES ${PROJECT_BINARY_DIR}/extra/dist/default/tarantool DESTINATION
${CMAKE_INSTALL_SYSCONFDIR}/sysconfig/
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ)
endif(ENABLE_SYSVINIT)
-- Options for Tarantool
default_cfg = {
pid_file = "/var/run/tarantool", -- will become pid_file .. instance .. '.pid'
wal_dir = "@TARANTOOL_DATADIR@", -- will become wal_dir/instance/
snap_dir = "@TARANTOOL_DATADIR@", -- snap_dir/instance/
sophia_dir = "@TARANTOOL_DATADIR@", -- will become sophia_dir/sophia/instance/
logger = "/var/log/tarantool", -- logger/instance .. '.log'
pid_file = "@TARANTOOL_RUNDIR@", -- /var/run/tarantool/${INSTANCE}.pid
wal_dir = "@TARANTOOL_DATADIR@", -- /var/lib/tarantool/${INSTANCE}/
snap_dir = "@TARANTOOL_DATADIR@", -- /var/lib/tarantool/${INSTANCE}
sophia_dir = "@TARANTOOL_DATADIR@", -- /var/lib/tarantool/${INSTANCE}
logger = "@TARANTOOL_LOGDIR@", -- /var/log/tarantool/${INSTANCE}.log
username = "tarantool",
}
......
......@@ -30,7 +30,7 @@ User=tarantool
Group=tarantool
OOMScoreAdjust=-1000
ExecStart=@SYSV_INITD_PATH@ start
ExecStop=@SYSV_INITD_PATH@ stop
ExecStart=@SYSV_INITD_DIR@/tarantool.init start
ExecStop=@SYSV_INITD_DIR@/tarantool.init stop
TimeoutSec=300
......@@ -130,18 +130,14 @@ This package provides common files
local function cmake_key_value(key, value)
return " -D"..key.."="..value
end
local function dev_with (obj, flag)
local status = "OFF"
if tonumber(rpm.expand("%{with "..obj.."}")) ~= 0 then
status = "ON"
local function def_init()
if tonumber(rpm.expand("%{with systemd}")) ~= 0 then
return cmake_key_value("WITH_SYSTEMD", "ON") ..
cmake_key_value("SYSTEMD_SERVICES_INSTALL_DIR",
'%{_unitdir}')
else
return ' %{!?scl:-DWITH_SYSVINIT=ON}'
end
return cmake_key_value(flag, status)
end
local function dev_with_kv (obj, key, value)
if tonumber(rpm.expand("%{with "..obj.."}")) ~= 0 then
return cmake_key_value(key, value)
end
return ""
end
local cmd = 'cmake'
if is_rhel_old() then
......@@ -161,11 +157,8 @@ This package provides common files
.. cmake_key_value('CMAKE_INSTALL_INFODIR', '%{_infodir}')
.. cmake_key_value('CMAKE_INSTALL_MANDIR', '%{_mandir}')
.. cmake_key_value('CMAKE_INSTALL_LOCALSTATEDIR', '%{_localstatedir}')
.. ' %{!?scl:-DCMAKE_INSTALL_SYSCONFDIR=%{_sysconfdir}}'
.. ' %{!?scl:-DENABLE_RPM=ON}'
.. ' %{?scl:-DENABLE_RPM_SCL=ON}'
.. dev_with('systemd', 'WITH_SYSTEMD')
.. dev_with_kv('systemd', 'SYSTEMD_SERVICES_INSTALL_DIR', '%{_unitdir}')
.. def_init()
.. ' %{!?scl:-DCMAKE_INSTALL_SYSCONFDIR=%{_sysconfdir}}')
print(wrap_with_toolset(cmd))}
%{lua:print(wrap_with_toolset('make %{?_smp_mflags}\n'))}
......@@ -245,9 +238,9 @@ chkconfig --del tarantool
%dir "%{_sysconfdir}/tarantool/instances.available"
"%{_sysconfdir}/tarantool/instances.available/example.lua"
%if %{with systemd}
%dir "%{_libdir}/tarantool/"
%dir "%{_prefix}/lib/tarantool/"
"%{_unitdir}/tarantool.service"
"%{_libdir}/tarantool/tarantool.init"
"%{_prefix}/lib/tarantool/tarantool.init"
%else
"%{_sysconfdir}/init.d/tarantool"
%endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment