# 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:
# Provides common functionality related to installation an processing
# of tmpfiles snippets.

if [[ -z $tmpfiles_eclass ]]; then
        tmpfiles_eclass=1

        case "${EAPI}" in
                5|6) ;;
                *) die "API is undefined for EAPI ${EAPI}" ;;
        esac

        DEPEND="virtual/tmpfiles"
        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_create
        # @USAGE: tmpfiles_create
        # @DESCRIPTION:
        # Call a tmpfiles implementation to process newly installed tmpfiles.d
        # snippets. Does nothing if no tmpfiles implementation is available.
        tmpfiles_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

Attachment: signature.asc
Description: Digital signature

Reply via email to