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

Diff of /eclass/systemd.eclass

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

Revision 1.25 Revision 1.28
1# Copyright 1999-2013 Gentoo Foundation 1# Copyright 1999-2013 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.25 2013/04/13 22:49:21 floppym Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/systemd.eclass,v 1.28 2013/09/11 08:50:07 mgorny Exp $
4 4
5# @ECLASS: systemd.eclass 5# @ECLASS: systemd.eclass
6# @MAINTAINER: 6# @MAINTAINER:
7# systemd@gentoo.org 7# systemd@gentoo.org
8# @BLURB: helper functions to install systemd units 8# @BLURB: helper functions to install systemd units
10# This eclass provides a set of functions to install unit files for 10# This eclass provides a set of functions to install unit files for
11# sys-apps/systemd within ebuilds. 11# sys-apps/systemd within ebuilds.
12# @EXAMPLE: 12# @EXAMPLE:
13# 13#
14# @CODE 14# @CODE
15# inherit autotools-utils systemd 15# inherit systemd
16# 16#
17# src_configure() { 17# src_configure() {
18# local myeconfargs=( 18# local myeconfargs=(
19# --enable-foo 19# --enable-foo
20# --disable-bar 20# --disable-bar
21# "$(systemd_with_unitdir)"
21# ) 22# )
22# 23#
23# systemd_to_myeconfargs 24# econf "${myeconfargs[@]}"
24# autotools-utils_src_configure
25# } 25# }
26# @CODE 26# @CODE
27 27
28inherit toolchain-funcs 28inherit eutils toolchain-funcs
29 29
30case ${EAPI:-0} in 30case ${EAPI:-0} in
31 0|1|2|3|4|5) ;; 31 0|1|2|3|4|5) ;;
32 *) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established." 32 *) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
33esac 33esac
111# Install systemd unit(s). Uses doins, thus it is fatal in EAPI 4 111# Install systemd unit(s). Uses doins, thus it is fatal in EAPI 4
112# and non-fatal in earlier EAPIs. 112# and non-fatal in earlier EAPIs.
113systemd_dounit() { 113systemd_dounit() {
114 debug-print-function ${FUNCNAME} "${@}" 114 debug-print-function ${FUNCNAME} "${@}"
115 115
116 local INSDESTTREE 116 (
117 insinto "$(_systemd_get_unitdir)" 117 insinto "$(_systemd_get_unitdir)"
118 doins "${@}" 118 doins "${@}"
119 )
119} 120}
120 121
121# @FUNCTION: systemd_newunit 122# @FUNCTION: systemd_newunit
122# @USAGE: oldname newname 123# @USAGE: oldname newname
123# @DESCRIPTION: 124# @DESCRIPTION:
124# Install systemd unit with a new name. Uses newins, thus it is fatal 125# Install systemd unit with a new name. Uses newins, thus it is fatal
125# in EAPI 4 and non-fatal in earlier EAPIs. 126# in EAPI 4 and non-fatal in earlier EAPIs.
126systemd_newunit() { 127systemd_newunit() {
127 debug-print-function ${FUNCNAME} "${@}" 128 debug-print-function ${FUNCNAME} "${@}"
128 129
129 local INSDESTTREE 130 (
130 insinto "$(_systemd_get_unitdir)" 131 insinto "$(_systemd_get_unitdir)"
131 newins "${@}" 132 newins "${@}"
133 )
132} 134}
133 135
134# @FUNCTION: systemd_dotmpfilesd 136# @FUNCTION: systemd_dotmpfilesd
135# @USAGE: tmpfilesd1 [...] 137# @USAGE: tmpfilesd1 [...]
136# @DESCRIPTION: 138# @DESCRIPTION:
142 for f; do 144 for f; do
143 [[ ${f} == *.conf ]] \ 145 [[ ${f} == *.conf ]] \
144 || die 'tmpfiles.d files need to have .conf suffix.' 146 || die 'tmpfiles.d files need to have .conf suffix.'
145 done 147 done
146 148
147 local INSDESTTREE 149 (
148 insinto /usr/lib/tmpfiles.d/ 150 insinto /usr/lib/tmpfiles.d/
149 doins "${@}" 151 doins "${@}"
152 )
150} 153}
151 154
152# @FUNCTION: systemd_newtmpfilesd 155# @FUNCTION: systemd_newtmpfilesd
153# @USAGE: oldname newname.conf 156# @USAGE: oldname newname.conf
154# @DESCRIPTION: 157# @DESCRIPTION:
158 debug-print-function ${FUNCNAME} "${@}" 161 debug-print-function ${FUNCNAME} "${@}"
159 162
160 [[ ${2} == *.conf ]] \ 163 [[ ${2} == *.conf ]] \
161 || die 'tmpfiles.d files need to have .conf suffix.' 164 || die 'tmpfiles.d files need to have .conf suffix.'
162 165
163 local INSDESTTREE 166 (
164 insinto /usr/lib/tmpfiles.d/ 167 insinto /usr/lib/tmpfiles.d/
165 newins "${@}" 168 newins "${@}"
169 )
166} 170}
167 171
168# @FUNCTION: systemd_enable_service 172# @FUNCTION: systemd_enable_service
169# @USAGE: target service 173# @USAGE: target service
170# @DESCRIPTION: 174# @DESCRIPTION:
221# scripts to the myeconfargs variable used by autotools-utils eclass. Handles 225# scripts to the myeconfargs variable used by autotools-utils eclass. Handles
222# quoting automatically. 226# quoting automatically.
223systemd_to_myeconfargs() { 227systemd_to_myeconfargs() {
224 debug-print-function ${FUNCNAME} "${@}" 228 debug-print-function ${FUNCNAME} "${@}"
225 229
230 eqawarn 'systemd_to_myeconfargs() is deprecated and will be removed on 2013-10-11.'
231 eqawarn 'Please use $(systemd_with_unitdir) instead.'
232
226 myeconfargs=( 233 myeconfargs=(
227 "${myeconfargs[@]}" 234 "${myeconfargs[@]}"
228 --with-systemdsystemunitdir="$(systemd_get_unitdir)" 235 --with-systemdsystemunitdir="$(systemd_get_unitdir)"
229 ) 236 )
230} 237}
250 eend $? 257 eend $?
251 else 258 else
252 debug-print "${FUNCNAME}: journalctl not found." 259 debug-print "${FUNCNAME}: journalctl not found."
253 fi 260 fi
254} 261}
262
263# @FUNCTION: systemd_is_booted
264# @DESCRIPTION:
265# Check whether the system was booted using systemd.
266#
267# This should be used purely for informational purposes, e.g. warning
268# user that he needs to use systemd. Installed files or application
269# behavior *must not* rely on this. Please remember to check MERGE_TYPE
270# to not trigger the check on binary package build hosts!
271#
272# Returns 0 if systemd is used to boot the system, 1 otherwise.
273#
274# See: man sd_booted
275systemd_is_booted() {
276 debug-print-function ${FUNCNAME} "${@}"
277
278 [[ -d /run/systemd/system ]]
279 local ret=${?}
280
281 debug-print "${FUNCNAME}: [[ -d /run/systemd/system ]] -> ${ret}"
282 return ${ret}
283}

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.28

  ViewVC Help
Powered by ViewVC 1.1.20