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

Contents of /eclass/systemd.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (hide annotations) (download)
Sat Jun 11 06:06:43 2011 UTC (3 years, 1 month ago) by mgorny
Branch: MAIN
Changes since 1.2: +15 -1 lines
Introduce systemd_dotmpfilesd() for installing tmpfiles.d files.

1 mgorny 1.1 # Copyright 1999-2011 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 mgorny 1.3 # $Header: /var/cvsroot/gentoo-x86/eclass/systemd.eclass,v 1.2 2011/05/04 16:02: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     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     # @DESCRIPTION:
92     # Output '--with-systemdsystemunitdir' as expected by systemd-aware configure
93     # scripts. This function always succeeds. Its output may be quoted in order
94     # to preserve whitespace in paths. systemd_to_myeconfargs() is preferred over
95     # this function.
96     systemd_with_unitdir() {
97     debug-print-function ${FUNCNAME} "${@}"
98    
99     echo -n --with-systemdsystemunitdir="$(systemd_get_unitdir)"
100     }
101    
102     # @FUNCTION: systemd_to_myeconfargs
103     # @DESCRIPTION:
104     # Add '--with-systemdsystemunitdir' as expected by systemd-aware configure
105     # scripts to the myeconfargs variable used by autotools-utils eclass. Handles
106     # quoting automatically.
107     systemd_to_myeconfargs() {
108     debug-print-function ${FUNCNAME} "${@}"
109    
110     myeconfargs=(
111     "${myeconfargs[@]}"
112     --with-systemdsystemunitdir="$(systemd_get_unitdir)"
113     )
114     }

  ViewVC Help
Powered by ViewVC 1.1.20