1 | # Copyright 1999-2012 Gentoo Foundation |
1 | # Copyright 1999-2012 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.14 2012/08/27 21:55:01 mgorny Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/systemd.eclass,v 1.18 2012/10/30 21:56:31 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 |
… | |
… | |
24 | # autotools-utils_src_configure |
24 | # autotools-utils_src_configure |
25 | # } |
25 | # } |
26 | # @CODE |
26 | # @CODE |
27 | |
27 | |
28 | case ${EAPI:-0} in |
28 | case ${EAPI:-0} in |
29 | 0|1|2|3|4) ;; |
29 | 0|1|2|3|4|5) ;; |
30 | *) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established." |
30 | *) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established." |
31 | esac |
31 | esac |
32 | |
32 | |
33 | # @FUNCTION: _systemd_get_unitdir |
33 | # @FUNCTION: _systemd_get_unitdir |
34 | # @INTERNAL |
34 | # @INTERNAL |
35 | # @DESCRIPTION: |
35 | # @DESCRIPTION: |
36 | # Get unprefixed unitdir. |
36 | # Get unprefixed unitdir. |
37 | _systemd_get_unitdir() { |
37 | _systemd_get_unitdir() { |
38 | echo -n /usr/lib/systemd/system |
38 | echo /usr/lib/systemd/system |
39 | } |
39 | } |
40 | |
40 | |
41 | # @FUNCTION: systemd_get_unitdir |
41 | # @FUNCTION: systemd_get_unitdir |
42 | # @DESCRIPTION: |
42 | # @DESCRIPTION: |
43 | # Output the path for the systemd unit directory (not including ${D}). |
43 | # Output the path for the systemd unit directory (not including ${D}). |
44 | # This function always succeeds, even if systemd is not installed. |
44 | # This function always succeeds, even if systemd is not installed. |
45 | systemd_get_unitdir() { |
45 | systemd_get_unitdir() { |
46 | has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= |
46 | has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= |
47 | debug-print-function ${FUNCNAME} "${@}" |
47 | debug-print-function ${FUNCNAME} "${@}" |
48 | |
48 | |
49 | echo -n "${EPREFIX}$(_systemd_get_unitdir)" |
49 | echo "${EPREFIX}$(_systemd_get_unitdir)" |
|
|
50 | } |
|
|
51 | |
|
|
52 | # @FUNCTION: systemd_get_utildir |
|
|
53 | # @DESCRIPTION: |
|
|
54 | # Output the path for the systemd utility directory (not including |
|
|
55 | # ${D}). This function always succeeds, even if systemd is not |
|
|
56 | # installed. |
|
|
57 | systemd_get_utildir() { |
|
|
58 | has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= |
|
|
59 | debug-print-function ${FUNCNAME} "${@}" |
|
|
60 | |
|
|
61 | echo "${EPREFIX}/usr/lib/systemd" |
50 | } |
62 | } |
51 | |
63 | |
52 | # @FUNCTION: systemd_dounit |
64 | # @FUNCTION: systemd_dounit |
53 | # @USAGE: unit1 [...] |
65 | # @USAGE: unit1 [...] |
54 | # @DESCRIPTION: |
66 | # @DESCRIPTION: |
… | |
… | |
147 | # remember to report a bug upstream as well. |
159 | # remember to report a bug upstream as well. |
148 | systemd_with_unitdir() { |
160 | systemd_with_unitdir() { |
149 | debug-print-function ${FUNCNAME} "${@}" |
161 | debug-print-function ${FUNCNAME} "${@}" |
150 | local optname=${1:-systemdsystemunitdir} |
162 | local optname=${1:-systemdsystemunitdir} |
151 | |
163 | |
152 | echo -n --with-${optname}="$(systemd_get_unitdir)" |
164 | echo --with-${optname}="$(systemd_get_unitdir)" |
|
|
165 | } |
|
|
166 | |
|
|
167 | # @FUNCTION: systemd_with_utildir |
|
|
168 | # @DESCRIPTION: |
|
|
169 | # Output '--with-systemdsystemutildir' as used by some packages to install |
|
|
170 | # systemd helpers. This function always succeeds. Its output may be quoted |
|
|
171 | # in order to preserve whitespace in paths. |
|
|
172 | systemd_with_utildir() { |
|
|
173 | debug-print-function ${FUNCNAME} "${@}" |
|
|
174 | |
|
|
175 | echo --with-systemdutildir="$(systemd_get_utildir)" |
153 | } |
176 | } |
154 | |
177 | |
155 | # @FUNCTION: systemd_to_myeconfargs |
178 | # @FUNCTION: systemd_to_myeconfargs |
156 | # @DESCRIPTION: |
179 | # @DESCRIPTION: |
157 | # Add '--with-systemdsystemunitdir' as expected by systemd-aware configure |
180 | # Add '--with-systemdsystemunitdir' as expected by systemd-aware configure |