Skip to content

Commit

Permalink
tmpfiles.eclass: Support using on non-Linux systems
Browse files Browse the repository at this point in the history
Fix the eclass code to remove the misguided Linux conditionals.
The whole purpose of the eclass was to avoid having to implement
fallback logic for systems not having service manager tmpfiles.d
support. Making it conditional to Linux implied that for non-Linux
systems (Prefix, FreeBSD) we would have to implement explicit fallback
to create the necessary directories.

While systemd (and therefore systemd-tmpfilesd) is indeed
Linux-specific, the opentmpfiles implementation should be pretty
portable and there is no reason to restrict it to Linux only, or to
prevent using it on non-Linux OpenRC (and non-OpenRC) systems.
  • Loading branch information
mgorny committed Jan 1, 2018
1 parent 6bba9e7 commit 4feccc9
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions eclass/tmpfiles.eclass
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 1999-2016 Gentoo Foundation
# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

# @ECLASS: tmpfiles.eclass
Expand All @@ -17,10 +17,16 @@
# https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html
#
# The dotmpfiles and newtmpfiles functions are used to install
# configuration files into /usr/lib/tmpfiles.d, then in pkg_postinst, the
# tmpfiles_process function can be called to process the newly
# configuration files into /usr/lib/tmpfiles.d, then in pkg_postinst,
# the tmpfiles_process function must be called to process the newly
# installed tmpfiles.d entries.
#
# The tmpfiles.d files can be used by service managers to recreate/clean
# up temporary directories on boot or periodically. Additionally,
# the pkg_postinst() call ensures that the directories are created
# on systems that do not support tmpfiles.d natively, without a need
# for explicit fallback.
#
# @EXAMPLE:
# Typical usage of this eclass:
#
Expand Down Expand Up @@ -53,7 +59,7 @@ case "${EAPI}" in
*) die "API is undefined for EAPI ${EAPI}" ;;
esac

RDEPEND="kernel_linux? ( virtual/tmpfiles )"
RDEPEND="virtual/tmpfiles"

# @FUNCTION: dotmpfiles
# @USAGE: dotmpfiles <tmpfiles.d_file> ...
Expand All @@ -62,7 +68,6 @@ RDEPEND="kernel_linux? ( virtual/tmpfiles )"
dotmpfiles() {
debug-print-function "${FUNCNAME}" "$@"

use kernel_linux || return 0
local f
for f; do
if [[ ${f} != *.conf ]]; then
Expand All @@ -83,7 +88,6 @@ dotmpfiles() {
newtmpfiles() {
debug-print-function "${FUNCNAME}" "$@"

use kernel_linux || return 0
if [[ $2 != *.conf ]]; then
die "tmpfiles.d files must end with .conf"
fi
Expand All @@ -102,7 +106,6 @@ newtmpfiles() {
tmpfiles_process() {
debug-print-function "${FUNCNAME}" "$@"

use kernel_linux || return 0
[[ ${EBUILD_PHASE} == postinst ]] || die "${FUNCNAME}: Only valid in pkg_postinst"
[[ ${#} -gt 0 ]] || die "${FUNCNAME}: Must specify at least one filename"

Expand Down

0 comments on commit 4feccc9

Please sign in to comment.