Skip to content

Commit

Permalink
MDEV-15052: Allow sysusers and tmpfiles install for non-systemd users
Browse files Browse the repository at this point in the history
..as they have their own tools that parses those files, such as
opensysusers[1] that handles sysusers file and opentmpfiles[2] that
handles tmpfiles.d settings

Because of this. Move both sysusers and tmpfiles 'if' function
outside systemd function, allowing independent install

Signed-off-by: Rafli Akmal <thefallenrat@artixlinux.org>

[1] - https://github.com/artix-linux/opensysusers
[2] - https://github.com/OpenRC/opentmpfiles

Changes done by vicentiu@mariadb.org, from original author patch:

Installing sysusers and tmpfiles without checking for systemd existence
means that by default, cmake will ALWAYS install these files. Our
general policy is we do not install things which are not needed.
However, there is a valid use case when these files are useful, as is
described above.

To allow this, provide an extra switch that can be enabled during
configuring by doing -DINSTALL_SYSTEMD_{SYSUSERS|TMPFILES}=True

This will use the default path INSTALL_SYSTEMD_{SYSUSERS|TMPFILES}DIR
fetched from install_layout.cmake for rpm & deb based layouts
respectively, or they must be overriden if the install_layout is
standalone.

Example:

cmake . -DINSTALL_SYSTEMD_SYSUSERS=True -DINSTALL_SYSTEMD_SYSUSERSDIR=/etc/sysusers.d
  • Loading branch information
thefallenrat authored and cvicentiu committed Jan 24, 2020
1 parent b472bc2 commit 742c36d
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions support-files/CMakeLists.txt
Expand Up @@ -114,23 +114,6 @@ IF(UNIX)
${CMAKE_CURRENT_BINARY_DIR}/mariadb.service
DESTINATION ${inst_location}/systemd COMPONENT SupportFiles)

IF(INSTALL_SYSTEMD_SYSUSERSDIR)
CONFIGURE_FILE(sysusers.conf.in
${CMAKE_CURRENT_BINARY_DIR}/sysusers.conf @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/sysusers.conf
DESTINATION ${INSTALL_SYSTEMD_SYSUSERSDIR}
RENAME mariadb.conf COMPONENT Server)
ENDIF()

IF(INSTALL_SYSTEMD_TMPFILESDIR)
get_filename_component(MYSQL_UNIX_DIR ${MYSQL_UNIX_ADDR} DIRECTORY)
CONFIGURE_FILE(tmpfiles.conf.in
${CMAKE_CURRENT_BINARY_DIR}/tmpfiles.conf @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tmpfiles.conf
DESTINATION ${INSTALL_SYSTEMD_TMPFILESDIR}
RENAME mariadb.conf COMPONENT Server)
ENDIF()

# @ in directory name broken between CMake version 2.8.12.2 and 3.3
# http://public.kitware.com/Bug/view.php?id=14782
IF(NOT CMAKE_VERSION VERSION_LESS 3.3.0 OR NOT RPM)
Expand All @@ -157,6 +140,26 @@ IF(UNIX)
ENDIF()
ENDIF()

# Allow installing sysusers and tmpusers without requiring SYSTEMD on the
# system. This is useful for distributions running other init systems to
# parse these files and create appropriate users & tmpfiles.
IF((HAVE_SYSTEMD OR INSTALL_SYSTEMD_SYSUSERS) AND INSTALL_SYSTEMD_SYSUSERSDIR)
CONFIGURE_FILE(sysusers.conf.in
${CMAKE_CURRENT_BINARY_DIR}/sysusers.conf @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/sysusers.conf
DESTINATION ${INSTALL_SYSTEMD_SYSUSERSDIR}
RENAME mariadb.conf COMPONENT Server)
ENDIF()

IF((HAVE_SYSTEMD OR INSTALL_SYSTEMD_TMPUSERS) AND INSTALL_SYSTEMD_TMPFILESDIR)
get_filename_component(MYSQL_UNIX_DIR ${MYSQL_UNIX_ADDR} DIRECTORY)
CONFIGURE_FILE(tmpfiles.conf.in
${CMAKE_CURRENT_BINARY_DIR}/tmpfiles.conf @ONLY)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/tmpfiles.conf
DESTINATION ${INSTALL_SYSTEMD_TMPFILESDIR}
RENAME mariadb.conf COMPONENT Server)
ENDIF()

IF (INSTALL_SYSCONFDIR)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql-log-rotate DESTINATION ${INSTALL_SYSCONFDIR}/logrotate.d
RENAME mysql COMPONENT SupportFiles)
Expand Down

0 comments on commit 742c36d

Please sign in to comment.