link dbus and systemd services, allows systemd activation.
authorGustavo Sverzut Barbieri <gustavo.barbieri@intel.com>
Mon, 10 Mar 2014 02:55:42 +0000 (23:55 -0300)
committerGustavo Sverzut Barbieri <gustavo.barbieri@intel.com>
Mon, 10 Mar 2014 03:09:12 +0000 (00:09 -0300)
If the dbus service contains SystemdService entry and the dbus-daemon
is started with --systemd-activation, then requests for services on
the user session bus will be handled by systemd, creating cgroups and
being handled as native systemd services of Type=dbus.

Makefile.am
configure.ac
dbus-services/org.enlightenment.Efreet.service.in
dbus-services/org.enlightenment.Ethumb.service.in
m4/pkg_var.m4 [new file with mode: 0644]
systemd-services/.gitignore [new file with mode: 0644]
systemd-services/efreet.service.in [new file with mode: 0644]
systemd-services/ethumb.service.in [new file with mode: 0644]

index 380b930..a2b70b5 100644 (file)
@@ -32,6 +32,7 @@ m4/ltsugar.m4 \
 m4/ltversion.m4
 
 EXTRA_DIST =  \
+m4/pkg_var.m4 \
 m4/ac_path_generic.m4 \
 m4/ecore_check_c_extension.m4 \
 m4/ecore_check_module.m4 \
@@ -309,6 +310,13 @@ service_DATA = \
 dbus-services/org.enlightenment.Efreet.service \
 dbus-services/org.enlightenment.Ethumb.service
 
+if HAVE_SYSTEMD_USER_SESSION
+systemdunitsdir = @USER_SESSION_DIR@
+systemdunits_DATA = \
+systemd-services/efreet.service \
+systemd-services/ethumb.service
+endif
+EXTRA_DIST += $(systemdunits_DATA)
 
 
 .PHONY: doc benchmark examples install-examples
index 754ad09..d30d722 100644 (file)
@@ -587,6 +587,35 @@ AC_ARG_ENABLE([systemd],
     want_systemd="no"
    ])
 
+systemd_dbus_prefix="# "
+if test "${want_systemd}" = "yes"; then
+   systemd_dbus_prefix=""
+fi
+AC_SUBST(systemd_dbus_prefix)
+
+AC_ARG_WITH([systemdunitdir],
+         AC_HELP_STRING([--with-systemdunitdir=DIR],
+                [path to systemd user services directory]),
+         [USER_SESSION_DIR=${withval}])
+if test "$want_systemd" == "no"; then
+  have_systemd_user_session="no"
+elif test -n "${USER_SESSION_DIR}"; then
+  have_systemd_user_session="yes"
+  AC_MSG_NOTICE([Using systemd user services directory as ${USER_SESSION_DIR}])
+else
+  # Detect systemd user session directory properly
+  EFL_PKG_CHECK_VAR([USER_SESSION_DIR], [systemd >= 192], [systemduserunitdir],
+       [have_systemd_user_session="yes"], [have_systemd_user_session="no"])
+
+  if test "$want_systemd" = "yes" -a "$have_systemd_user_session" = "no"; then
+     AC_MSG_ERROR([systemd support wanted, but systemd was not found.])
+  fi
+fi
+
+AM_CONDITIONAL([HAVE_SYSTEMD_USER_SESSION], [test "x${have_systemd_user_session}" = "xyes"])
+AC_SUBST([USER_SESSION_DIR])
+
+
 if test "x${have_systemd_pkg}" = "xauto" -o "x${have_systemd_pkg}" = "xyes"; then
    PKG_CHECK_MODULES([SYSTEMD], [libsystemd-daemon >= 192 libsystemd-journal >= 192],
    [have_systemd_pkg="yes"],
@@ -4105,6 +4134,8 @@ pc/ethumb.pc
 pc/ethumb_client.pc
 dbus-services/org.enlightenment.Efreet.service
 dbus-services/org.enlightenment.Ethumb.service
+systemd-services/efreet.service
+systemd-services/ethumb.service
 $po_makefile_in
 cmakeconfig/EinaConfig.cmake
 cmakeconfig/EinaConfigVersion.cmake:cmakeconfig/EFLConfigVersion.cmake.in
@@ -4250,6 +4281,10 @@ fi
 echo "  "
 echo "Installation....: make install (as root if needed, with 'su' or 'sudo')"
 echo "  prefix........: $prefix"
+echo "  dbus units....: $dbusservicedir"
+if test "${have_systemd_user_session}" = "yes"; then
+echo "  systemd units.: $USER_SESSION_DIR"
+fi
 echo
 
 if test "x${have_systemd_pkg}" = "xyes" -a "x${want_systemd}" = "xno"; then
index 94eedc8..5eb5d53 100644 (file)
@@ -1,3 +1,4 @@
 [D-BUS Service]
 Name=org.enlightenment.Efreet
 Exec=@prefix@/bin/efreetd
+@systemd_dbus_prefix@SystemdService=efreet.service
index ece2e03..484427f 100644 (file)
@@ -1,3 +1,4 @@
 [D-BUS Service]
 Name=org.enlightenment.Ethumb
 Exec=@prefix@/bin/ethumbd
+@systemd_dbus_prefix@SystemdService=ethumb.service
diff --git a/m4/pkg_var.m4 b/m4/pkg_var.m4
new file mode 100644 (file)
index 0000000..3d0a309
--- /dev/null
@@ -0,0 +1,14 @@
+# PKG_CHECK_VAR(VARIABLE, MODULE, CONFIG-VARIABLE,
+# [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
+# -------------------------------------------
+# Retrieves the value of the pkg-config variable for the given module.
+AC_DEFUN([EFL_PKG_CHECK_VAR],
+[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
+AC_ARG_VAR([$1], [value of $3 for $2, overriding pkg-config])dnl
+
+_PKG_CONFIG([$1], [variable="][$3]["], [$2])
+AS_VAR_COPY([$1], [pkg_cv_][$1])
+
+AS_VAR_IF([$1], [""], [$5], [$4])dnl
+])# PKG_CHECK_VAR
+
diff --git a/systemd-services/.gitignore b/systemd-services/.gitignore
new file mode 100644 (file)
index 0000000..97355b6
--- /dev/null
@@ -0,0 +1,2 @@
+/efreet.service
+/ethumb.service
diff --git a/systemd-services/efreet.service.in b/systemd-services/efreet.service.in
new file mode 100644 (file)
index 0000000..ee1becb
--- /dev/null
@@ -0,0 +1,7 @@
+[Unit]
+Description=Efreet Enlightenment FreeDesktop.Org Daemon
+
+[Service]
+Type=dbus
+BusName=org.enlightenment.Efreet
+ExecStart=@prefix@/bin/efreetd
diff --git a/systemd-services/ethumb.service.in b/systemd-services/ethumb.service.in
new file mode 100644 (file)
index 0000000..93bbff8
--- /dev/null
@@ -0,0 +1,7 @@
+[Unit]
+Description=Enlightenment Thumbnailer
+
+[Service]
+Type=dbus
+BusName=org.enlightenment.Ethumb
+ExecStart=@prefix@/bin/ethumbd