Gentoo Archives: gentoo-commits

From: "Ulrich Mueller (ulm)" <ulm@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] emacs r1336 - emacs-daemon
Date: Fri, 17 Jul 2009 12:58:53
Message-Id: E1MRn1Y-0007ln-9Z@stork.gentoo.org
Author: ulm
Date: 2009-07-17 12:58:51 +0000 (Fri, 17 Jul 2009)
New Revision: 1336

Modified:
   emacs-daemon/ChangeLog
   emacs-daemon/emacs.rc
Log:
Be compatible with baselayout-1.

Modified: emacs-daemon/ChangeLog
===================================================================
--- emacs-daemon/ChangeLog	2009-07-16 17:22:31 UTC (rev 1335)
+++ emacs-daemon/ChangeLog	2009-07-17 12:58:51 UTC (rev 1336)
@@ -1,3 +1,10 @@
+2009-07-17  Ulrich Mueller  <ulm@g.o>
+
+	* emacs.rc (USER): Initialise from SVCNAME instead of RC_SVCNAME,
+	in order to be compatible with baselayout-1. OpenRC defines both.
+	(start): Test for OpenRC. Compatibility code for start-stop-daemon
+	of baselayout-1.
+
 2009-03-18  Ulrich Mueller  <ulm@g.o>
 
 	* Version 0.14 released.

Modified: emacs-daemon/emacs.rc
===================================================================
--- emacs-daemon/emacs.rc	2009-07-16 17:22:31 UTC (rev 1335)
+++ emacs-daemon/emacs.rc	2009-07-17 12:58:51 UTC (rev 1336)
@@ -8,7 +8,7 @@
 : ${EMACS_SHELL=/bin/bash}
 : ${EMACS_START:=/usr/libexec/emacs/emacs-wrapper.sh}
 : ${EMACS_TIMEOUT:=30}
-USER=${RC_SVCNAME#*.}
+USER=${SVCNAME#*.}
 PIDFILE_DIR=/var/run/emacs/${USER}
 PIDFILE=${PIDFILE_DIR}/emacs.pid
 
@@ -20,7 +20,7 @@
 }
 
 checkconfig() {
-    if [ "${USER}" = "${RC_SVCNAME}" ]; then
+    if [ "${USER}" = "${SVCNAME}" ]; then
 	eerror "You have to create an init script for each user:"
 	eerror "ln -s emacs /etc/init.d/emacs.<user>"
 	return 1
@@ -50,15 +50,21 @@
 
     SHELL=${EMACS_SHELL:-$(awk -F: "\$1 == \"${USER}\" { print \$7 }" \
 	/etc/passwd)}
-    export SHELL
+    export SHELL EMACS EMACS_TIMEOUT
 
     ebegin "Starting Emacs daemon for user ${USER}"
-    # This was tested with start-stop-daemon from OpenRC; don't expect
-    # it to work with other implementations.
-    start-stop-daemon --start \
-	--user "${USER}" --chdir "${home}" --pidfile "${PIDFILE}" \
-	--env EMACS="${EMACS}" --env EMACS_TIMEOUT="${EMACS_TIMEOUT}" \
-	--exec "${EMACS_START}" -- ${EMACS_OPTS}
+    if [ -z "${RC_SVCNAME}" ]; then
+	# baselayout-1
+	start-stop-daemon --start \
+	    --user "${USER}" --exec "${EMACS}" --pidfile "${PIDFILE}" \
+	    --chuid "${USER}" --chdir "${home}" --env HOME="${home}" \
+	    --startas "${EMACS_START}" -- ${EMACS_OPTS}
+    else
+	# OpenRC
+	start-stop-daemon --start \
+	    --user "${USER}" --pidfile "${PIDFILE}" --chdir "${home}" \
+	    --exec "${EMACS_START}" -- ${EMACS_OPTS}
+    fi
     eend $?
 }