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

Contents of /eclass/systemd.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (hide annotations) (download)
Fri Jun 24 13:13:24 2011 UTC (3 years, 2 months ago) by darkside
Branch: MAIN
Changes since 1.5: +3 -2 lines
return an EPREFIX'd path in systemd_get_unitdir(), approved by maintainer

1 mgorny 1.1 # Copyright 1999-2011 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 darkside 1.6 # $Header: /var/cvsroot/gentoo-x86/eclass/systemd.eclass,v 1.5 2011/06/19 16:05:10 mgorny Exp $
4 mgorny 1.1
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 darkside 1.6 has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
39 mgorny 1.1 debug-print-function ${FUNCNAME} "${@}"
40    
41 darkside 1.6 echo -n "${EPREFIX}"/lib/systemd/system
42 mgorny 1.1 }
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     debug-print-function ${FUNCNAME} "${@}"
51    
52     (
53     insinto "$(systemd_get_unitdir)"
54     doins "${@}"
55     )
56     }
57    
58 mgorny 1.5 # @FUNCTION: systemd_newunit
59     # @USAGE: oldname newname
60     # @DESCRIPTION:
61     # Install systemd unit with a new name. Uses newins, thus it is fatal
62     # in EAPI 4 and non-fatal in earlier EAPIs.
63     systemd_newunit() {
64     debug-print-function ${FUNCNAME} "${@}"
65    
66     (
67     insinto "$(systemd_get_unitdir)"
68     newins "${@}"
69     )
70     }
71    
72 mgorny 1.3 # @FUNCTION: systemd_dotmpfilesd
73     # @USAGE: tmpfilesd1 [...]
74     # @DESCRIPTION:
75     # Install systemd tmpfiles.d files. Uses doins, thus it is fatal
76     # in EAPI 4 and non-fatal in earlier EAPIs.
77     systemd_dotmpfilesd() {
78     debug-print-function ${FUNCNAME} "${@}"
79    
80     (
81     insinto /usr/lib/tmpfiles.d/
82     doins "${@}"
83     )
84     }
85    
86 mgorny 1.1 # @FUNCTION: systemd_enable_service
87     # @USAGE: target service
88     # @DESCRIPTION:
89     # Enable service in desired target, e.g. install a symlink for it.
90     # Uses dosym, thus it is fatal in EAPI 4 and non-fatal in earlier
91     # EAPIs.
92     systemd_enable_service() {
93     debug-print-function ${FUNCNAME} "${@}"
94    
95     [[ ${#} -eq 2 ]] || die "Synopsis: systemd_enable_service target service"
96    
97     local target=${1}
98     local service=${2}
99     local ud=$(systemd_get_unitdir)
100    
101     dodir "${ud}"/"${target}".wants && \
102     dosym ../"${service}" "${ud}"/"${target}".wants
103     }
104    
105     # @FUNCTION: systemd_with_unitdir
106 mgorny 1.4 # @USAGE: [configure option]
107 mgorny 1.1 # @DESCRIPTION:
108     # Output '--with-systemdsystemunitdir' as expected by systemd-aware configure
109     # scripts. This function always succeeds. Its output may be quoted in order
110     # to preserve whitespace in paths. systemd_to_myeconfargs() is preferred over
111     # this function.
112 mgorny 1.4 #
113     # If upstream does use invalid configure option to handle installing systemd
114     # units (e.g. `--with-systemdunitdir'), you can pass the 'suffix' as an optional
115     # argument to this function (`$(systemd_with_unitdir systemdunitdir)'). Please
116     # remember to report a bug upstream as well.
117 mgorny 1.1 systemd_with_unitdir() {
118     debug-print-function ${FUNCNAME} "${@}"
119 mgorny 1.4 local optname=${1:-systemdsystemunitdir}
120 mgorny 1.1
121 mgorny 1.4 echo -n --with-${optname}="$(systemd_get_unitdir)"
122 mgorny 1.1 }
123    
124     # @FUNCTION: systemd_to_myeconfargs
125     # @DESCRIPTION:
126     # Add '--with-systemdsystemunitdir' as expected by systemd-aware configure
127     # scripts to the myeconfargs variable used by autotools-utils eclass. Handles
128     # quoting automatically.
129     systemd_to_myeconfargs() {
130     debug-print-function ${FUNCNAME} "${@}"
131    
132     myeconfargs=(
133     "${myeconfargs[@]}"
134     --with-systemdsystemunitdir="$(systemd_get_unitdir)"
135     )
136     }

  ViewVC Help
Powered by ViewVC 1.1.20