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

Contents of /eclass/systemd.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (show annotations) (download)
Thu Jul 28 13:47:50 2011 UTC (3 years, 2 months ago) by zmedico
Branch: MAIN
Changes since 1.6: +4 -2 lines
systemd_dounit: fix for prefix

1 # Copyright 1999-2011 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/systemd.eclass,v 1.6 2011/06/24 13:13:24 darkside Exp $
4
5 # @ECLASS: systemd.eclass
6 # @MAINTAINER:
7 # mgorny@gentoo.org
8 # @BLURB: helper functions to install systemd units
9 # @DESCRIPTION:
10 # This eclass provides a set of functions to install unit files for
11 # sys-apps/systemd within ebuilds.
12 # @EXAMPLE:
13 #
14 # @CODE
15 # inherit autotools-utils systemd
16 #
17 # src_configure() {
18 # local myeconfargs=(
19 # --enable-foo
20 # --disable-bar
21 # )
22 #
23 # systemd_to_myeconfargs
24 # autotools-utils_src_configure
25 # }
26 # @CODE
27
28 case ${EAPI:-0} in
29 0|1|2|3|4) ;;
30 *) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
31 esac
32
33 # @FUNCTION: systemd_get_unitdir
34 # @DESCRIPTION:
35 # Output the path for the systemd unit directory (not including ${D}).
36 # This function always succeeds, even if systemd is not installed.
37 systemd_get_unitdir() {
38 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
39 debug-print-function ${FUNCNAME} "${@}"
40
41 echo -n "${EPREFIX}"/lib/systemd/system
42 }
43
44 # @FUNCTION: systemd_dounit
45 # @USAGE: unit1 [...]
46 # @DESCRIPTION:
47 # Install systemd unit(s). Uses doins, thus it is fatal in EAPI 4
48 # and non-fatal in earlier EAPIs.
49 systemd_dounit() {
50 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
51 debug-print-function ${FUNCNAME} "${@}"
52
53 (
54 local ud=$(systemd_get_unitdir)
55 insinto "${ud#${EPREFIX}}"
56 doins "${@}"
57 )
58 }
59
60 # @FUNCTION: systemd_newunit
61 # @USAGE: oldname newname
62 # @DESCRIPTION:
63 # Install systemd unit with a new name. Uses newins, thus it is fatal
64 # in EAPI 4 and non-fatal in earlier EAPIs.
65 systemd_newunit() {
66 debug-print-function ${FUNCNAME} "${@}"
67
68 (
69 insinto "$(systemd_get_unitdir)"
70 newins "${@}"
71 )
72 }
73
74 # @FUNCTION: systemd_dotmpfilesd
75 # @USAGE: tmpfilesd1 [...]
76 # @DESCRIPTION:
77 # Install systemd tmpfiles.d files. Uses doins, thus it is fatal
78 # in EAPI 4 and non-fatal in earlier EAPIs.
79 systemd_dotmpfilesd() {
80 debug-print-function ${FUNCNAME} "${@}"
81
82 (
83 insinto /usr/lib/tmpfiles.d/
84 doins "${@}"
85 )
86 }
87
88 # @FUNCTION: systemd_enable_service
89 # @USAGE: target service
90 # @DESCRIPTION:
91 # Enable service in desired target, e.g. install a symlink for it.
92 # Uses dosym, thus it is fatal in EAPI 4 and non-fatal in earlier
93 # EAPIs.
94 systemd_enable_service() {
95 debug-print-function ${FUNCNAME} "${@}"
96
97 [[ ${#} -eq 2 ]] || die "Synopsis: systemd_enable_service target service"
98
99 local target=${1}
100 local service=${2}
101 local ud=$(systemd_get_unitdir)
102
103 dodir "${ud}"/"${target}".wants && \
104 dosym ../"${service}" "${ud}"/"${target}".wants
105 }
106
107 # @FUNCTION: systemd_with_unitdir
108 # @USAGE: [configure option]
109 # @DESCRIPTION:
110 # Output '--with-systemdsystemunitdir' as expected by systemd-aware configure
111 # scripts. This function always succeeds. Its output may be quoted in order
112 # to preserve whitespace in paths. systemd_to_myeconfargs() is preferred over
113 # this function.
114 #
115 # If upstream does use invalid configure option to handle installing systemd
116 # units (e.g. `--with-systemdunitdir'), you can pass the 'suffix' as an optional
117 # argument to this function (`$(systemd_with_unitdir systemdunitdir)'). Please
118 # remember to report a bug upstream as well.
119 systemd_with_unitdir() {
120 debug-print-function ${FUNCNAME} "${@}"
121 local optname=${1:-systemdsystemunitdir}
122
123 echo -n --with-${optname}="$(systemd_get_unitdir)"
124 }
125
126 # @FUNCTION: systemd_to_myeconfargs
127 # @DESCRIPTION:
128 # Add '--with-systemdsystemunitdir' as expected by systemd-aware configure
129 # scripts to the myeconfargs variable used by autotools-utils eclass. Handles
130 # quoting automatically.
131 systemd_to_myeconfargs() {
132 debug-print-function ${FUNCNAME} "${@}"
133
134 myeconfargs=(
135 "${myeconfargs[@]}"
136 --with-systemdsystemunitdir="$(systemd_get_unitdir)"
137 )
138 }

  ViewVC Help
Powered by ViewVC 1.1.20