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

Contents of /eclass/systemd.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.22 - (show annotations) (download)
Mon Mar 18 06:29:03 2013 UTC (18 months ago) by mgorny
Branch: MAIN
Changes since 1.21: +3 -3 lines
Update the maintainer to systemd@.

1 # Copyright 1999-2013 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.21 2012/12/31 13:09:09 mgorny Exp $
4
5 # @ECLASS: systemd.eclass
6 # @MAINTAINER:
7 # systemd@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|5) ;;
30 *) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
31 esac
32
33 # @FUNCTION: _systemd_get_unitdir
34 # @INTERNAL
35 # @DESCRIPTION:
36 # Get unprefixed unitdir.
37 _systemd_get_unitdir() {
38 echo /usr/lib/systemd/system
39 }
40
41 # @FUNCTION: systemd_get_unitdir
42 # @DESCRIPTION:
43 # Output the path for the systemd unit directory (not including ${D}).
44 # This function always succeeds, even if systemd is not installed.
45 systemd_get_unitdir() {
46 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
47 debug-print-function ${FUNCNAME} "${@}"
48
49 echo "${EPREFIX}$(_systemd_get_unitdir)"
50 }
51
52 # @FUNCTION: systemd_get_userunitdir
53 # @DESCRIPTION:
54 # Output the path for the systemd user unit directory (not including
55 # ${D}). This function always succeeds, even if systemd is not
56 # installed.
57 systemd_get_userunitdir() {
58 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
59 debug-print-function ${FUNCNAME} "${@}"
60
61 echo "${EPREFIX}/usr/lib/systemd/user"
62 }
63
64 # @FUNCTION: systemd_get_utildir
65 # @DESCRIPTION:
66 # Output the path for the systemd utility directory (not including
67 # ${D}). This function always succeeds, even if systemd is not
68 # installed.
69 systemd_get_utildir() {
70 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
71 debug-print-function ${FUNCNAME} "${@}"
72
73 echo "${EPREFIX}/usr/lib/systemd"
74 }
75
76 # @FUNCTION: systemd_dounit
77 # @USAGE: unit1 [...]
78 # @DESCRIPTION:
79 # Install systemd unit(s). Uses doins, thus it is fatal in EAPI 4
80 # and non-fatal in earlier EAPIs.
81 systemd_dounit() {
82 debug-print-function ${FUNCNAME} "${@}"
83
84 local INSDESTTREE
85 insinto "$(_systemd_get_unitdir)"
86 doins "${@}"
87 }
88
89 # @FUNCTION: systemd_newunit
90 # @USAGE: oldname newname
91 # @DESCRIPTION:
92 # Install systemd unit with a new name. Uses newins, thus it is fatal
93 # in EAPI 4 and non-fatal in earlier EAPIs.
94 systemd_newunit() {
95 debug-print-function ${FUNCNAME} "${@}"
96
97 local INSDESTTREE
98 insinto "$(_systemd_get_unitdir)"
99 newins "${@}"
100 }
101
102 # @FUNCTION: systemd_dotmpfilesd
103 # @USAGE: tmpfilesd1 [...]
104 # @DESCRIPTION:
105 # Install systemd tmpfiles.d files. Uses doins, thus it is fatal
106 # in EAPI 4 and non-fatal in earlier EAPIs.
107 systemd_dotmpfilesd() {
108 debug-print-function ${FUNCNAME} "${@}"
109
110 for f; do
111 [[ ${f} == *.conf ]] \
112 || die 'tmpfiles.d files need to have .conf suffix.'
113 done
114
115 local INSDESTTREE
116 insinto /usr/lib/tmpfiles.d/
117 doins "${@}"
118 }
119
120 # @FUNCTION: systemd_newtmpfilesd
121 # @USAGE: oldname newname.conf
122 # @DESCRIPTION:
123 # Install systemd tmpfiles.d file under a new name. Uses newins, thus it
124 # is fatal in EAPI 4 and non-fatal in earlier EAPIs.
125 systemd_newtmpfilesd() {
126 debug-print-function ${FUNCNAME} "${@}"
127
128 [[ ${2} == *.conf ]] \
129 || die 'tmpfiles.d files need to have .conf suffix.'
130
131 local INSDESTTREE
132 insinto /usr/lib/tmpfiles.d/
133 newins "${@}"
134 }
135
136 # @FUNCTION: systemd_enable_service
137 # @USAGE: target service
138 # @DESCRIPTION:
139 # Enable service in desired target, e.g. install a symlink for it.
140 # Uses dosym, thus it is fatal in EAPI 4 and non-fatal in earlier
141 # EAPIs.
142 systemd_enable_service() {
143 debug-print-function ${FUNCNAME} "${@}"
144
145 [[ ${#} -eq 2 ]] || die "Synopsis: systemd_enable_service target service"
146
147 local target=${1}
148 local service=${2}
149 local ud=$(_systemd_get_unitdir)
150 local destname=$(basename "${service}")
151
152 dodir "${ud}"/"${target}".wants && \
153 dosym ../"${service}" "${ud}"/"${target}".wants/"${destname}"
154 }
155
156 # @FUNCTION: systemd_with_unitdir
157 # @USAGE: [configure option]
158 # @DESCRIPTION:
159 # Output '--with-systemdsystemunitdir' as expected by systemd-aware configure
160 # scripts. This function always succeeds. Its output may be quoted in order
161 # to preserve whitespace in paths. systemd_to_myeconfargs() is preferred over
162 # this function.
163 #
164 # If upstream does use invalid configure option to handle installing systemd
165 # units (e.g. `--with-systemdunitdir'), you can pass the 'suffix' as an optional
166 # argument to this function (`$(systemd_with_unitdir systemdunitdir)'). Please
167 # remember to report a bug upstream as well.
168 systemd_with_unitdir() {
169 debug-print-function ${FUNCNAME} "${@}"
170 local optname=${1:-systemdsystemunitdir}
171
172 echo --with-${optname}="$(systemd_get_unitdir)"
173 }
174
175 # @FUNCTION: systemd_with_utildir
176 # @DESCRIPTION:
177 # Output '--with-systemdsystemutildir' as used by some packages to install
178 # systemd helpers. This function always succeeds. Its output may be quoted
179 # in order to preserve whitespace in paths.
180 systemd_with_utildir() {
181 debug-print-function ${FUNCNAME} "${@}"
182
183 echo --with-systemdutildir="$(systemd_get_utildir)"
184 }
185
186 # @FUNCTION: systemd_to_myeconfargs
187 # @DESCRIPTION:
188 # Add '--with-systemdsystemunitdir' as expected by systemd-aware configure
189 # scripts to the myeconfargs variable used by autotools-utils eclass. Handles
190 # quoting automatically.
191 systemd_to_myeconfargs() {
192 debug-print-function ${FUNCNAME} "${@}"
193
194 myeconfargs=(
195 "${myeconfargs[@]}"
196 --with-systemdsystemunitdir="$(systemd_get_unitdir)"
197 )
198 }
199
200 # @FUNCTION: systemd_update_catalog
201 # @DESCRIPTION:
202 # Update the journald catalog. This needs to be called after installing
203 # or removing catalog files.
204 #
205 # If systemd is not installed, no operation will be done. The catalog
206 # will be (re)built once systemd is installed.
207 #
208 # See: http://www.freedesktop.org/wiki/Software/systemd/catalog
209 systemd_update_catalog() {
210 debug-print-function ${FUNCNAME} "${@}"
211
212 # Make sure to work on the correct system.
213 local journalctl=${EPREFIX}/usr/bin/journalctl
214 if [[ -x ${journalctl} ]]; then
215 ebegin "Updating systemd journal catalogs"
216 journalctl --update-catalog
217 eend $?
218 else
219 debug-print "${FUNCNAME}: journalctl not found."
220 fi
221 }

  ViewVC Help
Powered by ViewVC 1.1.20