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

Contents of /eclass/systemd.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations) (download)
Wed May 4 10:53:35 2011 UTC (3 years, 4 months ago) by mgorny
Branch: MAIN
Introducing systemd.eclass - a helper eclass to handle systemd unit installation.

1 mgorny 1.1 # Copyright 1999-2011 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3     # $Header: $
4    
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     inherit multilib
29    
30     case ${EAPI:-0} in
31     0|1|2|3|4) ;;
32     *) die "${ECLASS}.eclass API in EAPI ${EAPI} not yet established."
33     esac
34    
35     # @FUNCTION: systemd_get_unitdir
36     # @DESCRIPTION:
37     # Output the path for the systemd unit directory (not including ${D}).
38     # This function always succeeds, even if systemd is not installed.
39     systemd_get_unitdir() {
40     debug-print-function ${FUNCNAME} "${@}"
41    
42     echo -n /lib/systemd/system
43     }
44    
45     # @FUNCTION: systemd_dounit
46     # @USAGE: unit1 [...]
47     # @DESCRIPTION:
48     # Install systemd unit(s). Uses doins, thus it is fatal in EAPI 4
49     # and non-fatal in earlier EAPIs.
50     systemd_dounit() {
51     debug-print-function ${FUNCNAME} "${@}"
52    
53     (
54     insinto "$(systemd_get_unitdir)"
55     doins "${@}"
56     )
57     }
58    
59     # @FUNCTION: systemd_enable_service
60     # @USAGE: target service
61     # @DESCRIPTION:
62     # Enable service in desired target, e.g. install a symlink for it.
63     # Uses dosym, thus it is fatal in EAPI 4 and non-fatal in earlier
64     # EAPIs.
65     systemd_enable_service() {
66     debug-print-function ${FUNCNAME} "${@}"
67    
68     [[ ${#} -eq 2 ]] || die "Synopsis: systemd_enable_service target service"
69    
70     local target=${1}
71     local service=${2}
72     local ud=$(systemd_get_unitdir)
73    
74     dodir "${ud}"/"${target}".wants && \
75     dosym ../"${service}" "${ud}"/"${target}".wants
76     }
77    
78     # @FUNCTION: systemd_with_unitdir
79     # @DESCRIPTION:
80     # Output '--with-systemdsystemunitdir' as expected by systemd-aware configure
81     # scripts. This function always succeeds. Its output may be quoted in order
82     # to preserve whitespace in paths. systemd_to_myeconfargs() is preferred over
83     # this function.
84     systemd_with_unitdir() {
85     debug-print-function ${FUNCNAME} "${@}"
86    
87     echo -n --with-systemdsystemunitdir="$(systemd_get_unitdir)"
88     }
89    
90     # @FUNCTION: systemd_to_myeconfargs
91     # @DESCRIPTION:
92     # Add '--with-systemdsystemunitdir' as expected by systemd-aware configure
93     # scripts to the myeconfargs variable used by autotools-utils eclass. Handles
94     # quoting automatically.
95     systemd_to_myeconfargs() {
96     debug-print-function ${FUNCNAME} "${@}"
97    
98     myeconfargs=(
99     "${myeconfargs[@]}"
100     --with-systemdsystemunitdir="$(systemd_get_unitdir)"
101     )
102     }

  ViewVC Help
Powered by ViewVC 1.1.20