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 # @SUPPORTED_EAPIS: 5 6
8 # @BLURB: helper functions to install s6 services
10 # This eclass provides helpers to install s6 services.
18 # s6_install_service myservice "${FILESDIR}"/run-s6 "${FILESDIR}"/finish-s6
20 # If you want a service to be logged, install the log service as
22 # s6_install_service myservice/log "${FILESDIR}"/log-run-s6 \
23 # "${FILESDIR}"/log-finish-s6
30 *) die "${ECLASS}.eclass: API in EAPI ${EAPI} not yet established" ;;
33 # @FUNCTION: _s6_get_servicedir
36 # Get unprefixed servicedir.
37 _s6_get_servicedir() {
41 # @FUNCTION: s6_get_servicedir
43 # Output the path for the s6 service directory (not including ${D}).
45 debug-print-function ${FUNCNAME} "${@}"
47 echo "${EPREFIX}$(_s6_get_servicedir)"
50 # @FUNCTION: s6_install_service
51 # @USAGE: <servicename> <run> [finish]
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} "${@}"
65 die "${ECLASS}.eclass: you must specify the s6 service name"
67 die "${ECLASS}.eclass: you must specify the s6 service run script"
70 local servicepath="$(_s6_get_servicedir)/$name"
71 exeinto "$servicepath"
73 [[ $finish ]] && newexe "$finish" finish
77 # @FUNCTION: s6_service_down
78 # @USAGE: <servicename>
80 # Install the "down" flag so this service will not be started by
82 # servicename is the name of the service.
84 debug-print-function ${FUNCNAME} "${@}"
89 die "${ECLASS}.eclass: you must specify the s6 service name"
92 touch "$T"/down || die
93 local servicepath="$(_s6_get_servicedir)/$name"
94 insinto "$servicepath"
99 # @FUNCTION: s6_service_nosetsid
100 # @USAGE: <servicename>
102 # Install the "nosetsid" flag so this service will not be made a session
104 # servicename is the name of the service.
105 s6_service_nosetsid() {
106 debug-print-function ${FUNCNAME} "${@}"
111 die "${ECLASS}.eclass: you must specify the s6 service name"
114 touch "$T"/nosetsid || die
115 local servicepath="$(_s6_get_servicedir)/$name"
116 insinto "$servicepath"