[evince] Make the systemd user unit conditional



commit 3e76c45a539f1830a733ce6ed7e73e0052b20eb9
Author: Simon McVittie <simon mcvittie collabora co uk>
Date:   Wed Apr 6 17:47:29 2016 +0100

    Make the systemd user unit conditional
    
    I've implemented this by adding a --with[out]-systemduserunitdir
    configure option, because that seems to be what's conventional
    in projects where user units are configurable at all. If a user or
    distribution wants to disable these units, it's easier if they can
    pass --without-systemduserunitdir to everything, rather than checking
    whether it's spelled --disable-systemd-user-units in this particular
    project. Also, a binary enable/disable option wouldn't be noticeably
    less code.
    
    If the systemd user unit is disabled at configure time, the
    SystemdService line in the installed D-Bus service file is commented
    out. This addresses the corner-case situation where a user configures
    Evince --without-systemduserunitdir, but enables systemd activation
    for their session dbus-daemon (perhaps later). In that situation,
    we presumably want Evince to continue to use traditional activation,
    rather than trying to launch a nonexistent systemd unit.
    
    Signed-off-by: Simon McVittie <simon mcvittie collabora co uk>
    Bug: https://bugzilla.gnome.org/show_bug.cgi?id=755897
    Reviewed-by: Carlos Garcia Campos

 configure.ac                            |   11 +++++++++++
 data/Makefile.am                        |   20 ++++++++++++++++----
 data/org.gnome.evince.Daemon.service.in |    2 +-
 3 files changed, 28 insertions(+), 5 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 01e602f..8b1bc27 100644
--- a/configure.ac
+++ b/configure.ac
@@ -299,6 +299,17 @@ fi
 
 AM_CONDITIONAL([ENABLE_DBUS], [test "$enable_dbus" = "yes"])
 
+# It is correct for this to be in ${prefix}/lib, even on systems where that
+# does not match ${libdir}. This is what systemd uses on such platforms.
+AC_ARG_WITH([systemduserunitdir],
+       AS_HELP_STRING([--with-systemduserunitdir=PATH],
+       [Set directory for systemd user units, or 'no' to disable]
+       [[default=${prefix}/lib/systemd/user]]),
+       [systemd_userdir="$withval"],
+       [systemd_userdir='${prefix}/lib/systemd/user'])
+AC_SUBST([systemd_userdir])
+AM_CONDITIONAL([WITH_SYSTEMD_USER_UNITS], [test "x$systemd_userdir" != "xno"])
+
 # *******************************
 # GNOME Desktop (Thumbnail cache)
 # *******************************
diff --git a/data/Makefile.am b/data/Makefile.am
index 1cf5dfa..44fcf33 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -37,15 +37,27 @@ servicedir = $(datadir)/dbus-1/services
 service_in_files = org.gnome.evince.Daemon.service.in
 service_DATA = $(service_in_files:.service.in=.service)
 
-$(service_DATA): $(service_in_files) Makefile
-       $(AM_V_GEN) $(SED) -e "s|\ libexecdir\@|$(libexecdir)|" $< > $@
-
-systemd_userdir = $(prefix)/lib/systemd/user
 systemd_user_in_files = evince.service.in
+
+if WITH_SYSTEMD_USER_UNITS
 systemd_user_DATA = $(systemd_user_in_files:.service.in=.service)
 
 $(systemd_user_DATA): $(systemd_user_in_files) Makefile
        $(AM_V_GEN) $(SED) -e "s|\ libexecdir\@|$(libexecdir)|" $< > $@
+
+$(service_DATA): $(service_in_files) Makefile
+       $(AM_V_GEN) $(SED) \
+               -e "s|\ libexecdir\@|$(libexecdir)|" \
+               -e "s|@if_systemd_service@||" \
+               $< > $@
+else
+$(service_DATA): $(service_in_files) Makefile
+       $(AM_V_GEN) $(SED) \
+               -e "s|\ libexecdir\@|$(libexecdir)|" \
+               -e "s|@if_systemd_service@|#|" \
+               $< > $@
+endif
+
 endif
 
 #
diff --git a/data/org.gnome.evince.Daemon.service.in b/data/org.gnome.evince.Daemon.service.in
index 19578f3..4a39282 100644
--- a/data/org.gnome.evince.Daemon.service.in
+++ b/data/org.gnome.evince.Daemon.service.in
@@ -1,4 +1,4 @@
 [D-BUS Service]
 Name=org.gnome.evince.Daemon
 Exec= libexecdir@/evinced
-SystemdService=evince.service
+ if_systemd_service@SystemdService=evince.service


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]