From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: =?UTF-8?Q?R=C3=BCdiger?= Sonderfeld Newsgroups: gmane.emacs.bugs,gmane.emacs.devel Subject: bug#16507: [RFC] Add a systemd service file for dealing with emacs --daemon. Date: Wed, 03 Dec 2014 20:39:44 +0100 Message-ID: <5741989.eboZExnV48@descartes> References: <8738ki4ys4.fsf@geometryfactory.com> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Trace: ger.gmane.org 1417635683 13595 80.91.229.3 (3 Dec 2014 19:41:23 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Wed, 3 Dec 2014 19:41:23 +0000 (UTC) Cc: 16507@debbugs.gnu.org To: emacs-devel@gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Wed Dec 03 20:41:18 2014 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XwFnZ-0006yw-EL for geb-bug-gnu-emacs@m.gmane.org; Wed, 03 Dec 2014 20:41:17 +0100 Original-Received: from localhost ([::1]:43080 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwFnZ-000057-3D for geb-bug-gnu-emacs@m.gmane.org; Wed, 03 Dec 2014 14:41:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:48332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwFnQ-00004z-DH for bug-gnu-emacs@gnu.org; Wed, 03 Dec 2014 14:41:13 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XwFnL-0002rc-OL for bug-gnu-emacs@gnu.org; Wed, 03 Dec 2014 14:41:08 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:55773) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XwFnL-0002rY-Kh for bug-gnu-emacs@gnu.org; Wed, 03 Dec 2014 14:41:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1XwFnL-0005Jn-1X for bug-gnu-emacs@gnu.org; Wed, 03 Dec 2014 14:41:03 -0500 X-Loop: help-debbugs@gnu.org In-Reply-To: <8738ki4ys4.fsf@geometryfactory.com> Resent-From: =?UTF-8?Q?R=C3=BCdiger?= Sonderfeld Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Wed, 03 Dec 2014 19:41:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16507 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 16507-submit@debbugs.gnu.org id=B16507.141763560720357 (code B ref 16507); Wed, 03 Dec 2014 19:41:01 +0000 Original-Received: (at 16507) by debbugs.gnu.org; 3 Dec 2014 19:40:07 +0000 Original-Received: from localhost ([127.0.0.1]:52982 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XwFmM-0005Hc-K0 for submit@debbugs.gnu.org; Wed, 03 Dec 2014 14:40:06 -0500 Original-Received: from ptmx.org ([178.63.28.110]:58639) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1XwFmG-0005HG-OM for 16507@debbugs.gnu.org; Wed, 03 Dec 2014 14:40:01 -0500 Original-Received: from localhost (localhost [127.0.0.1]) by ptmx.org (Postfix) with ESMTP id 02CAC2D8D2; Wed, 3 Dec 2014 20:39:55 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at ptmx.org Original-Received: from ptmx.org ([127.0.0.1]) by localhost (ptmx.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id zFH32GI7x3Pl; Wed, 3 Dec 2014 20:39:50 +0100 (CET) Original-Received: from descartes.localnet (chello080109100138.16.15.univie.teleweb.at [80.109.100.138]) by ptmx.org (Postfix) with ESMTPSA id 5B3122D853; Wed, 3 Dec 2014 20:39:50 +0100 (CET) User-Agent: KMail/4.13.3 (Linux/3.13.0-40-generic; KDE/4.13.3; x86_64; ; ) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:96827 gmane.emacs.devel:178762 Archived-At: As discussed in Bug#16507, I've added a systemd service file to deal wi= th=20 emacs --daemon. This however requires some installation changes. That= 's why=20 I submit this patch for review before pushing it. A new configuration flag `--with-systemduserunitdir' is added to set th= e=20 installation directory for the user unit. If it is unset an attempt is= made=20 to locate the default directory by using pkg-config. (I guess this should also get an entry in etc/NEWS.) * configure.ac (with_systemduserunitdir): New option. * Makefile.in (systemdunitdir,SYSTEMD_UNITS): New variables. (install-etc): Install systemd unit file. (uninstall): Uninstall systemd unit file. * etc/emacs.service.in: New file. --- ChangeLog | 8 ++++++++ Makefile.in | 17 +++++++++++++++++ configure.ac | 19 +++++++++++++++++++ etc/ChangeLog | 5 +++++ etc/emacs.service.in | 14 ++++++++++++++ 5 files changed, 63 insertions(+) create mode 100644 etc/emacs.service.in diff --git a/ChangeLog b/ChangeLog index cd7698c..05ad878 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2014-12-03 R=C3=BCdiger Sonderfeld + +=09Add a systemd service file for dealing with emacs --daemon. +=09* configure.ac (with_systemduserunitdir): New option. +=09* Makefile.in (systemdunitdir,SYSTEMD_UNITS): New variables. +=09(install-etc): Install systemd unit file. +=09(uninstall): Uninstall systemd unit file. + 2014-12-01 Lars Magne Ingebrigtsen =20 =09* .gitignore: Ignore loaddefs directly under lisp, and in diff --git a/Makefile.in b/Makefile.in index ccb70a4..b1e6be5 100644 --- a/Makefile.in +++ b/Makefile.in @@ -241,6 +241,9 @@ etcdocdir=3D@etcdocdir@ # Where to install Emacs game score files. gamedir=3D@gamedir@ =20 +# Where to install systemd unit files. +systemdunitdir=3D@systemdunitdir@ + # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Utility= Programs for the Build =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D =20 # Allow the user to specify the install program. @@ -286,6 +289,9 @@ SUBDIR_MAKEFILES =3D `echo $(SUBDIR_MAKEFILES_IN:.i= n=3D) | sed=20 's|$(srcdir)/||g'` COPYDIR =3D ${srcdir}/etc ${srcdir}/lisp COPYDESTS =3D "$(DESTDIR)${etcdir}" "$(DESTDIR)${lispdir}" =20 +# systemd unit +SYSTEMD_UNITS =3D @SYSTEMD_UNITS@ + all: ${SUBDIR} info =20 .PHONY: all ${SUBDIR} blessmail epaths-force epaths-force-w32 etc-emac= sver @@ -716,6 +722,16 @@ install-etc: =09 || exit 1; \ =09 done ; \ =09done +=09if test "x$(SYSTEMD_UNITS)" =3D "xemacs.service" ; then \ +=09 tmp=3Detc/emacs.service; rm -f $${tmp}; \ +=09 sed \ + -e "s;@emacs_prog@;${bindir}/${EMACSFULL};" \ +=09 -e "s;@emacsclient_prog@;${bindir}/emacsclient${EXEEXT};" \ +=09 "$(srcdir)/etc/emacs.service.in" > $${tmp}; \ +=09 umask 022; $(MKDIR_P) "$(DESTDIR)$(systemdunitdir)"; \ +=09 $(INSTALL_DATA) $${tmp} "$(DESTDIR)$(systemdunitdir)/emacs.servic= e"; \ +=09 rm -f $${tmp}; \ +=09fi =20 ### Build Emacs and install it, stripping binaries while installing th= em. install-strip: @@ -771,6 +787,7 @@ uninstall: uninstall-$(NTDIR) uninstall-doc =09 file=3D"$(DESTDIR)${gamedir}/$${file}"; \ =09 [ -s "$${file}" ] || rm -f "$$file"; \ =09done +=09-rm -f "$(DESTDIR)$(systemdunitdir)/emacs.service" =20 ### Windows-specific uninstall target for removing programs produced ### in nt/, and its Posix do-nothing shadow. diff --git a/configure.ac b/configure.ac index 010abc8..e737f1b 100644 --- a/configure.ac +++ b/configure.ac @@ -374,6 +374,10 @@ otherwise for the first of `gfile' or `inotify' th= at is=20 usable.]) ], [with_file_notification=3D$with_features]) =20 +AC_ARG_WITH([systemduserunitdir], + AS_HELP_STRING([--with-systemduserunitdir=3DDIR], [Directory for syst= emd user=20 service files]), + [], [with_systemduserunitdir=3Ddefault]) + ## For the times when you want to build Emacs but don't have ## a suitable makeinfo, and can live without the manuals. dnl http://lists.gnu.org/archive/html/emacs-devel/2008-04/msg01844.htm= l @@ -2678,6 +2682,21 @@ AC_SUBST(NOTIFY_OBJ) AC_SUBST(GFILENOTIFY_CFLAGS) AC_SUBST(GFILENOTIFY_LIBS) =20 +if test "x$with_systemduserunitdir" !=3D xno; then + if test "x$with_systemduserunitdir" =3D xdefault; then + with_systemduserunitdir=3D`"$PKG_CONFIG" --variable=3Dsystemduseru= nitdir=20 systemd` + fi + AC_SUBST([systemdunitdir], [$with_systemduserunitdir]) +fi + +if test -n "$with_systemduserunitdir" -a "x$with_systemduserunitdir" != =3D xno ;=20 then + SYSTEMD_UNITS=3D"emacs.service" +else + SYSTEMD_UNITS=3D"" +fi + +AC_SUBST(SYSTEMD_UNITS) + dnl Do not put whitespace before the #include statements below. dnl Older compilers (eg sunos4 cc) choke on it. HAVE_XAW3D=3Dno diff --git a/etc/ChangeLog b/etc/ChangeLog index 4f672df..02c0895 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog @@ -1,3 +1,8 @@ +2014-12-03 R=C3=BCdiger Sonderfeld + +=09Add a systemd service file for dealing with emacs --daemon. +=09* emacs.service.in: New file. + 2014-12-02 Eli Zaretskii =20 =09* NEWS: Mention 'bidi-find-overridden-directionality'. diff --git a/etc/emacs.service.in b/etc/emacs.service.in new file mode 100644 index 0000000..0e59bc2 --- /dev/null +++ b/etc/emacs.service.in @@ -0,0 +1,14 @@ +# -*- conf-mode -*- +# Copyright (C) 2014 Free Software Foundation, Inc. +[Unit] +Description=3DEmacs: the extensible, customizable text editor - and mo= re. +Documentation=3Dinfo:Emacs man:emacs(1) https://gnu.org/software/emacs= / + +[Service] +Type=3Dforking +ExecStart=3D@emacs_prog@ --daemon +ExecStop=3D@emacsclient_prog@ --eval "(kill-emacs)" +Restart=3Don-failure + +[Install] +WantedBy=3Ddefault.target --=20 2.1.3