1 # Copyright 1999-2015 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
6 # William Hubbs <williamh@gentoo.org>
7 # @BLURB: helper functions to install s6 services
9 # This eclass provides helpers to install s6 services.
17 # s6_install_service myservice "${FILESDIR}"/run-s6 "${FILESDIR}"/finish-s6
19 # If you want a service to be logged, install the log service as
21 # s6_install_service myservice/log "${FILESDIR}"/log-run-s6 \
22 # "${FILESDIR}"/log-finish-s6
29 *) die "${ECLASS}.eclass: API in EAPI ${EAPI} not yet established" ;;
32 # @FUNCTION: _s6_get_servicedir
35 # Get unprefixed servicedir.
36 _s6_get_servicedir() {
40 # @FUNCTION: s6_get_servicedir
42 # Output the path for the s6 service directory (not including ${D}).
44 debug-print-function ${FUNCNAME} "${@}"
46 echo "${EPREFIX}$(_s6_get_servicedir)"
49 # @FUNCTION: s6_install_service
50 # @USAGE: servicename run finish
52 # Install an s6 service.
53 # servicename is the name of the service.
54 # run is the run script for the service.
55 # finish is the optional finish script for the service.
56 s6_install_service() {
57 debug-print-function ${FUNCNAME} "${@}"
64 die "${ECLASS}.eclass: you must specify the s6 service name"
66 die "${ECLASS}.eclass: you must specify the s6 service run script"
69 local servicepath="$(_s6_get_servicedir)/$name"
70 exeinto "$servicepath"
72 [[ $finish ]] && newexe "$finish" finish
76 # @FUNCTION: s6_service_down
79 # Install the "down" flag so this service will not be started by
81 # servicename is the name of the service.
83 debug-print-function ${FUNCNAME} "${@}"
88 die "${ECLASS}.eclass: you must specify the s6 service name"
91 touch "$T"/down || die
92 local servicepath="$(_s6_get_servicedir)/$name"
93 insinto "$servicepath"
98 # @FUNCTION: s6_service_nosetsid
101 # Install the "nosetsid" flag so this service will not be made a session
103 # servicename is the name of the service.
104 s6_service_nosetsid() {
105 debug-print-function ${FUNCNAME} "${@}"
110 die "${ECLASS}.eclass: you must specify the s6 service name"
113 touch "$T"/nosetsid || die
114 local servicepath="$(_s6_get_servicedir)/$name"
115 insinto "$servicepath"