# Copyright 1999-2016 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Id$
# @ECLASS: tmpfiles.eclass # @MAINTAINER: # Gentoo systemd project <[email protected]> # William Hubbs <[email protected]> # @AUTHOR: # Mike Gilbert <[email protected]> # William Hubbs <[email protected]> # @BLURB: Functions related to tmpfiles.d files # @DESCRIPTION: # This eclass provides functionality related to installing and # creating volatile and temporary files based on configuration files$and # locations defined at this URL: # # https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html # # the dotmpfiles.d and newtmpfiles.d functions are used to install # configuration files into /usr/lib, then in pkg_postinst, the # tmpfiles.d_create function can be called to process the newly # installed tmpfiles.d entries. # # @EXAMPLE: # Typical usage of this eclass: # # @CODE # EAPI=6 # inherit tmpfiles # # ... # # src_install() { # ... # dotmpfiles.d "${FILESDIR}"/file1.conf "${FILESDIR}"/file2.conf # newtmpfiles.d "${FILESDIR}"/file3 file3.conf # ... # } # # pkg_postinst() { # ... # tmpfiles.d_create file1.conf file2.conf file3.conf # ... # } # # @CODE if [[ -z ${TMPFILES_ECLASS} ]]; then TMPFILES_ECLASS=1 case "${EAPI}" in 6) ;; *) die "API is undefined for EAPI ${EAPI}" ;; esac RDEPEND="virtual/tmpfiles" # @FUNCTION: dotmpfiles.d # @USAGE: dotmpfiles.d <tmpfiles.d> ... # @DESCRIPTION: # Install tmpfiles.d files. dotmpfiles.d() { debug-print-function "${FUNCNAME}" "$@" local f for f; do if [[ ${f} != *.conf ]] die "tmpfiles.d files must end with .conf" fi done ( insinto /usr/lib/tmpfiles.d doins "$@" ) } # @FUNCTION: newtmpfiles.d # @USAGE: newtmpfiles.d <old-name> <new-name>.conf # @DESCRIPTION: # Install a tmpfiles.d file under a new name. newtmpfiles.d() { debug-print-function "${FUNCNAME}" "$@" if [[ $2 != *.conf ]]; then die "tmpfiles.d files must end with .conf" fi ( insinto /usr/lib/tmpfiles.d newins "$@" ) } # @FUNCTION: tmpfiles.d_create # @USAGE: tmpfiles.d_create <filename> <filename> ... # @DESCRIPTION: # Call a tmpfiles.d implementation to create new volatile and temporary # files and directories. tmpfiles.d_create() { debug-print-function "${FUNCNAME}" "$@" [[ ${EBUILD_PHASE} == postinst ]] || die "${FUNCNAME}: Only valid in pkg_postinst" [[ ${#} -gt 0 ]] || die "${FUNCNAME}: Must specify at least one filename" [[ ${ROOT} == / ]] || return 0 if type systemd-tmpfiles &> /dev/null; then systemd-tmpfiles --create "$@" elif type opentmptmpfiles &> /dev/null; then opentmpfiles --create "$@" fi } fi
signature.asc
Description: Digital signature
