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

Contents of /eclass/systemd.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations) (download)
Wed May 4 16:02:10 2011 UTC (3 years, 2 months ago) by mgorny
Branch: MAIN
Changes since 1.1: +1 -3 lines
Drop needless `inherit multilib'. Thanks to Henry Gebhardt for pointing this out.

1 mgorny 1.1 # Copyright 1999-2011 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 mgorny 1.2 # $Header: /var/cvsroot/gentoo-x86/eclass/systemd.eclass,v 1.1 2011/05/04 10:53:35 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     # @FUNCTION: systemd_enable_service
58     # @USAGE: target service
59     # @DESCRIPTION:
60     # Enable service in desired target, e.g. install a symlink for it.
61     # Uses dosym, thus it is fatal in EAPI 4 and non-fatal in earlier
62     # EAPIs.
63     systemd_enable_service() {
64     debug-print-function ${FUNCNAME} "${@}"
65    
66     [[ ${#} -eq 2 ]] || die "Synopsis: systemd_enable_service target service"
67    
68     local target=${1}
69     local service=${2}
70     local ud=$(systemd_get_unitdir)
71    
72     dodir "${ud}"/"${target}".wants && \
73     dosym ../"${service}" "${ud}"/"${target}".wants
74     }
75    
76     # @FUNCTION: systemd_with_unitdir
77     # @DESCRIPTION:
78     # Output '--with-systemdsystemunitdir' as expected by systemd-aware configure
79     # scripts. This function always succeeds. Its output may be quoted in order
80     # to preserve whitespace in paths. systemd_to_myeconfargs() is preferred over
81     # this function.
82     systemd_with_unitdir() {
83     debug-print-function ${FUNCNAME} "${@}"
84    
85     echo -n --with-systemdsystemunitdir="$(systemd_get_unitdir)"
86     }
87    
88     # @FUNCTION: systemd_to_myeconfargs
89     # @DESCRIPTION:
90     # Add '--with-systemdsystemunitdir' as expected by systemd-aware configure
91     # scripts to the myeconfargs variable used by autotools-utils eclass. Handles
92     # quoting automatically.
93     systemd_to_myeconfargs() {
94     debug-print-function ${FUNCNAME} "${@}"
95    
96     myeconfargs=(
97     "${myeconfargs[@]}"
98     --with-systemdsystemunitdir="$(systemd_get_unitdir)"
99     )
100     }

  ViewVC Help
Powered by ViewVC 1.1.20