summaryrefslogtreecommitdiff
path: root/eclass
diff options
context:
space:
mode:
authorWilliam Hubbs <williamh@gentoo.org>2015-06-02 21:08:48 +0000
committerWilliam Hubbs <williamh@gentoo.org>2015-06-02 21:08:48 +0000
commit87a4a9f9d118564566e07e0ddc05e01d301245f7 (patch)
tree53f1b65481befee62c210774b31693e37e433297 /eclass
parentremove old version (diff)
downloadgentoo-2-87a4a9f9d118564566e07e0ddc05e01d301245f7.tar.gz
gentoo-2-87a4a9f9d118564566e07e0ddc05e01d301245f7.tar.bz2
gentoo-2-87a4a9f9d118564566e07e0ddc05e01d301245f7.zip
Add s6.eclass to handle s6 services
Diffstat (limited to 'eclass')
-rw-r--r--eclass/ChangeLog5
-rw-r--r--eclass/s6.eclass119
2 files changed, 123 insertions, 1 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog
index ba85691652fe..7b649991650c 100644
--- a/eclass/ChangeLog
+++ b/eclass/ChangeLog
@@ -1,6 +1,9 @@
# ChangeLog for eclass directory
# Copyright 1999-2015 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1634 2015/05/31 15:51:21 mrueg Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.1635 2015/06/02 21:08:48 williamh Exp $
+
+ 02 Jun 2015; William Hubbs <williamh@gentoo.org> +s6.eclass:
+ Add s6.eclass for handling s6 services
31 May 2015; Manuel Rüger <mrueg@gentoo.org> kde5.eclass:
Sync verbosely with kde overlay. Drop fetch restriction for unpublished
diff --git a/eclass/s6.eclass b/eclass/s6.eclass
new file mode 100644
index 000000000000..f44b4b5f28ff
--- /dev/null
+++ b/eclass/s6.eclass
@@ -0,0 +1,119 @@
+# Copyright 1999-2015 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/eclass/s6.eclass,v 1.1 2015/06/02 21:08:48 williamh Exp $
+
+# @ECLASS: s6.eclass
+# @MAINTAINER:
+# William Hubbs <williamh@gentoo.org>
+# @BLURB: helper functions to install s6 services
+# @DESCRIPTION:
+# This eclass provides helpers to install s6 services.
+# @EXAMPLE:
+#
+# @CODE
+# inherit s6
+#
+# src_install() {
+# ...
+# s6_install_service myservice "${FILESDIR}"/run-s6 "${FILESDIR}"/finish-s6
+ ...
+# If you want a service to be logged, install the log service as
+# shown here.
+# s6_install_service myservice/log "${FILESDIR}"/log-run-s6 \
+# "${FILESDIR}"/log-finish-s6
+# ...
+# }
+# @CODE
+
+case ${EAPI:-0} in
+ 5) ;;
+ *) die "${ECLASS}.eclass: API in EAPI ${EAPI} not yet established"
+esac
+
+# @FUNCTION: _s6_get_servicedir
+# @INTERNAL
+# @DESCRIPTION:
+# Get unprefixed servicedir.
+_s6_get_servicedir() {
+ echo /var/svc.d
+}
+
+# @FUNCTION: s6_get_servicedir
+# @DESCRIPTION:
+# Output the path for the s6 service directory (not including ${D}).
+s6_get_servicedir() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ echo "${EPREFIX}$(_s6_get_servicedir)"
+}
+
+# @FUNCTION: s6_install_service
+# @USAGE: servicename run finish
+# @DESCRIPTION:
+# Install an s6 service.
+# servicename is the name of the service.
+# run is the run script for the service.
+# finish is the optional finish script for the service.
+s6_install_service() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local name="$1"
+ local run="$2"
+ local finish="$3"
+
+ [[ $name ]] ||
+ die "${ECLASS}.eclass: you must specify the s6 service name"
+ [[ $run ]] ||
+ die "${ECLASS}.eclass: you must specify the s6 service run script"
+
+ (
+ local servicepath="$(_s6_get_servicedir)/$name"
+ exeinto "$servicepath"
+ newexe "$run" run
+ [[ $finish ]] && newexe "$finish" finish
+ )
+}
+
+# @FUNCTION: s6_service_down
+# @USAGE: servicename
+# @DESCRIPTION:
+# Install the "down" flag so this service will not be started by
+# default.
+# servicename is the name of the service.
+s6_service_down() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local name="$1"
+
+ [[ $name ]] ||
+ die "${ECLASS}.eclass: you must specify the s6 service name"
+
+ (
+ touch "$T"/down || die
+ local servicepath="$(_s6_get_servicedir)/$name"
+ insinto "$servicepath"
+ doins "$T"/down
+ )
+}
+
+# @FUNCTION: s6_service_nosetsid
+# @USAGE: servicename
+# @DESCRIPTION:
+# Install the "nosetsid" flag so this service will not be made a session
+# leader.
+# servicename is the name of the service.
+s6_service_nosetsid() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ local name="$1"
+
+ [[ $name ]] ||
+ die "${ECLASS}.eclass: you must specify the s6 service name"
+
+ (
+ touch "$T"/nosetsid || die
+ local servicepath="$(_s6_get_servicedir)/$name"
+ insinto "$servicepath"
+ doins "$T"/nosetsid
+ )
+}