/[gentoo-x86]/eclass/systemd.eclass
Gentoo

Diff of /eclass/systemd.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.8 Revision 1.9
1# Copyright 1999-2011 Gentoo Foundation 1# Copyright 1999-2011 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/systemd.eclass,v 1.8 2011/08/29 01:28:10 vapier Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/systemd.eclass,v 1.9 2011/09/17 13:48:21 mgorny Exp $
4 4
5# @ECLASS: systemd.eclass 5# @ECLASS: systemd.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# mgorny@gentoo.org 7# mgorny@gentoo.org
8# @BLURB: helper functions to install systemd units 8# @BLURB: helper functions to install systemd units
28case ${EAPI:-0} in 28case ${EAPI:-0} in
29 0|1|2|3|4) ;; 29 0|1|2|3|4) ;;
30 *) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established." 30 *) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
31esac 31esac
32 32
33# @FUNCTION: _systemd_get_unitdir
34# @INTERNAL
35# @DESCRIPTION:
36# Get unprefixed unitdir.
37_systemd_get_unitdir() {
38 echo -n /lib/systemd/system
39}
40
33# @FUNCTION: systemd_get_unitdir 41# @FUNCTION: systemd_get_unitdir
34# @DESCRIPTION: 42# @DESCRIPTION:
35# Output the path for the systemd unit directory (not including ${D}). 43# Output the path for the systemd unit directory (not including ${D}).
36# This function always succeeds, even if systemd is not installed. 44# This function always succeeds, even if systemd is not installed.
37systemd_get_unitdir() { 45systemd_get_unitdir() {
38 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= 46 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
39 debug-print-function ${FUNCNAME} "${@}" 47 debug-print-function ${FUNCNAME} "${@}"
40 48
41 echo -n "${EPREFIX}"/lib/systemd/system 49 echo -n "${EPREFIX}$(_systemd_get_unitdir)"
42} 50}
43 51
44# @FUNCTION: systemd_dounit 52# @FUNCTION: systemd_dounit
45# @USAGE: unit1 [...] 53# @USAGE: unit1 [...]
46# @DESCRIPTION: 54# @DESCRIPTION:
47# Install systemd unit(s). Uses doins, thus it is fatal in EAPI 4 55# Install systemd unit(s). Uses doins, thus it is fatal in EAPI 4
48# and non-fatal in earlier EAPIs. 56# and non-fatal in earlier EAPIs.
49systemd_dounit() { 57systemd_dounit() {
50 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
51 debug-print-function ${FUNCNAME} "${@}" 58 debug-print-function ${FUNCNAME} "${@}"
52 59
53 ( 60 (
54 local ud=$(systemd_get_unitdir) 61 insinto "$(_systemd_get_unitdir)"
55 insinto "${ud#${EPREFIX}}"
56 doins "${@}" 62 doins "${@}"
57 ) 63 )
58} 64}
59 65
60# @FUNCTION: systemd_newunit 66# @FUNCTION: systemd_newunit
64# in EAPI 4 and non-fatal in earlier EAPIs. 70# in EAPI 4 and non-fatal in earlier EAPIs.
65systemd_newunit() { 71systemd_newunit() {
66 debug-print-function ${FUNCNAME} "${@}" 72 debug-print-function ${FUNCNAME} "${@}"
67 73
68 ( 74 (
69 insinto "$(systemd_get_unitdir)" 75 insinto "$(_systemd_get_unitdir)"
70 newins "${@}" 76 newins "${@}"
71 ) 77 )
72} 78}
73 79
74# @FUNCTION: systemd_dotmpfilesd 80# @FUNCTION: systemd_dotmpfilesd
96 102
97 [[ ${#} -eq 2 ]] || die "Synopsis: systemd_enable_service target service" 103 [[ ${#} -eq 2 ]] || die "Synopsis: systemd_enable_service target service"
98 104
99 local target=${1} 105 local target=${1}
100 local service=${2} 106 local service=${2}
101 local ud=$(systemd_get_unitdir) 107 local ud=$(_systemd_get_unitdir)
102 108
103 dodir "${ud}"/"${target}".wants && \ 109 dodir "${ud}"/"${target}".wants && \
104 dosym ../"${service}" "${ud}"/"${target}".wants 110 dosym ../"${service}" "${ud}"/"${target}".wants
105} 111}
106 112

Legend:
Removed from v.1.8  
changed lines
  Added in v.1.9

  ViewVC Help
Powered by ViewVC 1.1.20