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

Contents of /eclass/s6.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (show annotations) (download)
Wed Jun 3 17:37:46 2015 UTC (3 years, 10 months ago) by grknight
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +3 -3 lines
Fix missing comment character and case syntax error

1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/eclass/s6.eclass,v 1.1 2015/06/02 21:08:48 williamh Exp $
4
5 # @ECLASS: s6.eclass
6 # @MAINTAINER:
7 # William Hubbs <williamh@gentoo.org>
8 # @BLURB: helper functions to install s6 services
9 # @DESCRIPTION:
10 # This eclass provides helpers to install s6 services.
11 # @EXAMPLE:
12 #
13 # @CODE
14 # inherit s6
15 #
16 # src_install() {
17 # ...
18 # s6_install_service myservice "${FILESDIR}"/run-s6 "${FILESDIR}"/finish-s6
19 # ...
20 # If you want a service to be logged, install the log service as
21 # shown here.
22 # s6_install_service myservice/log "${FILESDIR}"/log-run-s6 \
23 # "${FILESDIR}"/log-finish-s6
24 # ...
25 # }
26 # @CODE
27
28 case ${EAPI:-0} in
29 5) ;;
30 *) die "${ECLASS}.eclass: API in EAPI ${EAPI} not yet established" ;;
31 esac
32
33 # @FUNCTION: _s6_get_servicedir
34 # @INTERNAL
35 # @DESCRIPTION:
36 # Get unprefixed servicedir.
37 _s6_get_servicedir() {
38 echo /var/svc.d
39 }
40
41 # @FUNCTION: s6_get_servicedir
42 # @DESCRIPTION:
43 # Output the path for the s6 service directory (not including ${D}).
44 s6_get_servicedir() {
45 debug-print-function ${FUNCNAME} "${@}"
46
47 echo "${EPREFIX}$(_s6_get_servicedir)"
48 }
49
50 # @FUNCTION: s6_install_service
51 # @USAGE: servicename run finish
52 # @DESCRIPTION:
53 # Install an s6 service.
54 # servicename is the name of the service.
55 # run is the run script for the service.
56 # finish is the optional finish script for the service.
57 s6_install_service() {
58 debug-print-function ${FUNCNAME} "${@}"
59
60 local name="$1"
61 local run="$2"
62 local finish="$3"
63
64 [[ $name ]] ||
65 die "${ECLASS}.eclass: you must specify the s6 service name"
66 [[ $run ]] ||
67 die "${ECLASS}.eclass: you must specify the s6 service run script"
68
69 (
70 local servicepath="$(_s6_get_servicedir)/$name"
71 exeinto "$servicepath"
72 newexe "$run" run
73 [[ $finish ]] && newexe "$finish" finish
74 )
75 }
76
77 # @FUNCTION: s6_service_down
78 # @USAGE: servicename
79 # @DESCRIPTION:
80 # Install the "down" flag so this service will not be started by
81 # default.
82 # servicename is the name of the service.
83 s6_service_down() {
84 debug-print-function ${FUNCNAME} "${@}"
85
86 local name="$1"
87
88 [[ $name ]] ||
89 die "${ECLASS}.eclass: you must specify the s6 service name"
90
91 (
92 touch "$T"/down || die
93 local servicepath="$(_s6_get_servicedir)/$name"
94 insinto "$servicepath"
95 doins "$T"/down
96 )
97 }
98
99 # @FUNCTION: s6_service_nosetsid
100 # @USAGE: servicename
101 # @DESCRIPTION:
102 # Install the "nosetsid" flag so this service will not be made a session
103 # leader.
104 # servicename is the name of the service.
105 s6_service_nosetsid() {
106 debug-print-function ${FUNCNAME} "${@}"
107
108 local name="$1"
109
110 [[ $name ]] ||
111 die "${ECLASS}.eclass: you must specify the s6 service name"
112
113 (
114 touch "$T"/nosetsid || die
115 local servicepath="$(_s6_get_servicedir)/$name"
116 insinto "$servicepath"
117 doins "$T"/nosetsid
118 )
119 }

  ViewVC Help
Powered by ViewVC 1.1.20