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

Contents of /eclass/systemd.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (hide annotations) (download)
Thu Jun 16 16:39:18 2011 UTC (3 years ago) by mgorny
Branch: MAIN
Changes since 1.3: +9 -2 lines
Support passing an optional configure option name to systemd_with_unitdir.

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

  ViewVC Help
Powered by ViewVC 1.1.20