Gentoo Archives: gentoo-commits

From: "William Hubbs (williamh)" <williamh@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in eclass: ChangeLog s6.eclass
Date: Tue, 02 Jun 2015 21:08:53
Message-Id: 20150602210848.55537A1C@oystercatcher.gentoo.org
1 williamh 15/06/02 21:08:48
2
3 Modified: ChangeLog
4 Added: s6.eclass
5 Log:
6 Add s6.eclass to handle s6 services
7
8 Revision Changes Path
9 1.1635 eclass/ChangeLog
10
11 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1635&view=markup
12 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?rev=1.1635&content-type=text/plain
13 diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/ChangeLog?r1=1.1634&r2=1.1635
14
15 Index: ChangeLog
16 ===================================================================
17 RCS file: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v
18 retrieving revision 1.1634
19 retrieving revision 1.1635
20 diff -u -r1.1634 -r1.1635
21 --- ChangeLog 31 May 2015 15:51:21 -0000 1.1634
22 +++ ChangeLog 2 Jun 2015 21:08:48 -0000 1.1635
23 @@ -1,6 +1,9 @@
24 # ChangeLog for eclass directory
25 # Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2
26 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1634 2015/05/31 15:51:21 mrueg Exp $
27 +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1635 2015/06/02 21:08:48 williamh Exp $
28 +
29 + 02 Jun 2015; William Hubbs <williamh@g.o> +s6.eclass:
30 + Add s6.eclass for handling s6 services
31
32 31 May 2015; Manuel RĂ¼ger <mrueg@g.o> kde5.eclass:
33 Sync verbosely with kde overlay. Drop fetch restriction for unpublished
34
35
36
37 1.1 eclass/s6.eclass
38
39 file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/s6.eclass?rev=1.1&view=markup
40 plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/s6.eclass?rev=1.1&content-type=text/plain
41
42 Index: s6.eclass
43 ===================================================================
44 # Copyright 1999-2015 Gentoo Foundation
45 # Distributed under the terms of the GNU General Public License v2
46 # $Header: /var/cvsroot/gentoo-x86/eclass/s6.eclass,v 1.1 2015/06/02 21:08:48 williamh Exp $
47
48 # @ECLASS: s6.eclass
49 # @MAINTAINER:
50 # William Hubbs <williamh@g.o>
51 # @BLURB: helper functions to install s6 services
52 # @DESCRIPTION:
53 # This eclass provides helpers to install s6 services.
54 # @EXAMPLE:
55 #
56 # @CODE
57 # inherit s6
58 #
59 # src_install() {
60 # ...
61 # s6_install_service myservice "${FILESDIR}"/run-s6 "${FILESDIR}"/finish-s6
62 ...
63 # If you want a service to be logged, install the log service as
64 # shown here.
65 # s6_install_service myservice/log "${FILESDIR}"/log-run-s6 \
66 # "${FILESDIR}"/log-finish-s6
67 # ...
68 # }
69 # @CODE
70
71 case ${EAPI:-0} in
72 5) ;;
73 *) die "${ECLASS}.eclass: API in EAPI ${EAPI} not yet established"
74 esac
75
76 # @FUNCTION: _s6_get_servicedir
77 # @INTERNAL
78 # @DESCRIPTION:
79 # Get unprefixed servicedir.
80 _s6_get_servicedir() {
81 echo /var/svc.d
82 }
83
84 # @FUNCTION: s6_get_servicedir
85 # @DESCRIPTION:
86 # Output the path for the s6 service directory (not including ${D}).
87 s6_get_servicedir() {
88 debug-print-function ${FUNCNAME} "${@}"
89
90 echo "${EPREFIX}$(_s6_get_servicedir)"
91 }
92
93 # @FUNCTION: s6_install_service
94 # @USAGE: servicename run finish
95 # @DESCRIPTION:
96 # Install an s6 service.
97 # servicename is the name of the service.
98 # run is the run script for the service.
99 # finish is the optional finish script for the service.
100 s6_install_service() {
101 debug-print-function ${FUNCNAME} "${@}"
102
103 local name="$1"
104 local run="$2"
105 local finish="$3"
106
107 [[ $name ]] ||
108 die "${ECLASS}.eclass: you must specify the s6 service name"
109 [[ $run ]] ||
110 die "${ECLASS}.eclass: you must specify the s6 service run script"
111
112 (
113 local servicepath="$(_s6_get_servicedir)/$name"
114 exeinto "$servicepath"
115 newexe "$run" run
116 [[ $finish ]] && newexe "$finish" finish
117 )
118 }
119
120 # @FUNCTION: s6_service_down
121 # @USAGE: servicename
122 # @DESCRIPTION:
123 # Install the "down" flag so this service will not be started by
124 # default.
125 # servicename is the name of the service.
126 s6_service_down() {
127 debug-print-function ${FUNCNAME} "${@}"
128
129 local name="$1"
130
131 [[ $name ]] ||
132 die "${ECLASS}.eclass: you must specify the s6 service name"
133
134 (
135 touch "$T"/down || die
136 local servicepath="$(_s6_get_servicedir)/$name"
137 insinto "$servicepath"
138 doins "$T"/down
139 )
140 }
141
142 # @FUNCTION: s6_service_nosetsid
143 # @USAGE: servicename
144 # @DESCRIPTION:
145 # Install the "nosetsid" flag so this service will not be made a session
146 # leader.
147 # servicename is the name of the service.
148 s6_service_nosetsid() {
149 debug-print-function ${FUNCNAME} "${@}"
150
151 local name="$1"
152
153 [[ $name ]] ||
154 die "${ECLASS}.eclass: you must specify the s6 service name"
155
156 (
157 touch "$T"/nosetsid || die
158 local servicepath="$(_s6_get_servicedir)/$name"
159 insinto "$servicepath"
160 doins "$T"/nosetsid
161 )
162 }