public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] new eclass: tmpfiles.eclass for handling tmpfiles.d files
@ 2016-11-15 19:42 William Hubbs
  2016-11-15 19:59 ` Mike Gilbert
  2016-11-15 20:07 ` Michał Górny
  0 siblings, 2 replies; 5+ messages in thread
From: William Hubbs @ 2016-11-15 19:42 UTC (permalink / raw
  To: gentoo development


[-- Attachment #1.1: Type: text/plain, Size: 0 bytes --]



[-- Attachment #1.2: tmpfiles.eclass --]
[-- Type: text/plain, Size: 2012 bytes --]

# Copyright 1999-2016 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id$

# @ECLASS: tmpfiles.eclass
# @MAINTAINER:
# Gentoo systemd project <systemd@gentoo.org>
# William Hubbs <williamh@gentoo.org>
# @AUTHOR:
# Mike Gilbert <floppym@gentoo.org>
# William Hubbs <williamh@gentoo.org>
# @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 #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 163 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-11-15 20:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-15 19:42 [gentoo-dev] new eclass: tmpfiles.eclass for handling tmpfiles.d files William Hubbs
2016-11-15 19:59 ` Mike Gilbert
2016-11-15 20:07 ` Michał Górny
2016-11-15 20:26   ` William Hubbs
2016-11-15 20:59     ` Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox