[gvfs] build: Make SystemdService entry conditional



commit 327f1eee192a742a92e57345d25eda85cce630e6
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Mon Nov 6 19:40:59 2017 +0100

    build: Make SystemdService entry conditional
    
    When systemd user units installation is disabled, SystemdService
    entry should also not be present on D-Bus service files.
    
    This patch adds a common D-Bus service file template allowing,
    an homogeneus D-Bus service file generation and also a
    SystemService entry conditioned to the systemd user units
    installation option.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=786149

 daemon/meson.build          |   27 ++++++++++++++++++---------
 dbus.service.in             |    4 ++++
 meson.build                 |    2 ++
 metadata/meson.build        |   27 ++++++++++++++++++---------
 monitor/afc/meson.build     |   29 +++++++++++++++++++----------
 monitor/gdu/meson.build     |   29 +++++++++++++++++++----------
 monitor/goa/meson.build     |   29 +++++++++++++++++++----------
 monitor/gphoto2/meson.build |   28 +++++++++++++++++++---------
 monitor/mtp/meson.build     |   29 +++++++++++++++++++----------
 monitor/udisks2/meson.build |   29 +++++++++++++++++++----------
 10 files changed, 156 insertions(+), 77 deletions(-)
---
diff --git a/daemon/meson.build b/daemon/meson.build
index a31f5f6..6dda4d6 100644
--- a/daemon/meson.build
+++ b/daemon/meson.build
@@ -1,15 +1,9 @@
 subdir('trashlib')
 
 # D-Bus and systemd service files
-service = gvfs_namespace + '.Daemon.service'
-
-daemon_service = configure_file(
-  input: service + '.in',
-  output: service,
-  install: true,
-  install_dir: dbus_service_dir,
-  configuration: service_conf
-)
+dbus_service = gvfs_namespace + '.Daemon'
+dbus_exec = 'gvfsd'
+dbus_systemd_service = ''
 
 if install_systemd_user_unit_dir
   service = 'gvfs-daemon.service'
@@ -21,8 +15,23 @@ if install_systemd_user_unit_dir
     install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
+
+  dbus_systemd_service = 'SystemdService=' + service
 endif
 
+dbus_service_conf = configuration_data()
+dbus_service_conf.set('service', dbus_service)
+dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
+dbus_service_conf.set('systemd_service', dbus_systemd_service)
+
+daemon_service = configure_file(
+  input: dbus_service_in,
+  output: dbus_service + '.service',
+  install: true,
+  install_dir: dbus_service_dir,
+  configuration: dbus_service_conf
+)
+
 gnome.mkenums(
   'org.gnome.system.gvfs.enums.xml',
   sources: 'gvfs-enums.h',
diff --git a/dbus.service.in b/dbus.service.in
new file mode 100644
index 0000000..9df76f5
--- /dev/null
+++ b/dbus.service.in
@@ -0,0 +1,4 @@
+[D-BUS Service]
+Name=@service@
+Exec=@exec@
+@systemd_service@
diff --git a/meson.build b/meson.build
index 07eff01..76bc132 100644
--- a/meson.build
+++ b/meson.build
@@ -277,6 +277,8 @@ if dbus_service_dir == ''
   dbus_service_dir = dbus_dep.get_pkgconfig_variable('session_bus_services_dir')
 endif
 
+dbus_service_in = files('dbus.service.in')
+
 gio_module_dir = get_option('with-gio-module-dir')
 if gio_module_dir == ''
   gio_module_dir = gio_dep.get_pkgconfig_variable('giomoduledir')
diff --git a/metadata/meson.build b/metadata/meson.build
index a4f939a..e1625b8 100644
--- a/metadata/meson.build
+++ b/metadata/meson.build
@@ -1,12 +1,6 @@
-service = gvfs_namespace + '.Metadata.service'
-
-metadata_service = configure_file(
-  input: service + '.in',
-  output: service,
-  install: true,
-  install_dir: dbus_service_dir,
-  configuration: service_conf
-)
+dbus_service = gvfs_namespace + '.Metadata'
+dbus_exec = 'gvfsd-metadata'
+dbus_systemd_service = ''
 
 if install_systemd_user_unit_dir
   service = 'gvfs-metadata.service'
@@ -18,8 +12,23 @@ if install_systemd_user_unit_dir
     install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
+
+  dbus_systemd_service = 'SystemdService=' + service
 endif
 
+dbus_service_conf = configuration_data()
+dbus_service_conf.set('service', dbus_service)
+dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
+dbus_service_conf.set('systemd_service', dbus_systemd_service)
+
+metadata_service = configure_file(
+  input: dbus_service_in,
+  output: dbus_service + '.service',
+  install: true,
+  install_dir: dbus_service_dir,
+  configuration: dbus_service_conf
+)
+
 metadata_dbus = gnome.gdbus_codegen(
   'metadata-dbus',
   'dbus-interface.xml',
diff --git a/monitor/afc/meson.build b/monitor/afc/meson.build
index 830f8cc..b4735fe 100644
--- a/monitor/afc/meson.build
+++ b/monitor/afc/meson.build
@@ -5,18 +5,12 @@ install_data(
   install_dir: gvfs_remote_volume_monitors_dir
 )
 
-service = gvfs_namespace + '.AfcVolumeMonitor.service'
-
-afc_service = configure_file(
-  input: service + '.in',
-  output: service,
-  install: true,
-  install_dir: dbus_service_dir,
-  configuration: service_conf
-)
+dbus_service = gvfs_namespace + '.AfcVolumeMonitor'
+dbus_exec = 'gvfs-afc-volume-monitor'
+dbus_systemd_service = ''
 
 if install_systemd_user_unit_dir
-  service = 'gvfs-afc-volume-monitor.service'
+  service = dbus_exec + '.service'
 
   configure_file(
     input: service + '.in',
@@ -25,8 +19,23 @@ if install_systemd_user_unit_dir
     install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
+
+  dbus_systemd_service = 'SystemdService=' + service
 endif
 
+dbus_service_conf = configuration_data()
+dbus_service_conf.set('service', dbus_service)
+dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
+dbus_service_conf.set('systemd_service', dbus_systemd_service)
+
+afc_service = configure_file(
+  input: dbus_service_in,
+  output: dbus_service + '.service',
+  install: true,
+  install_dir: dbus_service_dir,
+  configuration: dbus_service_conf
+)
+
 sources = files(
   'afcvolumemonitordaemon.c',
   'afcvolume.c',
diff --git a/monitor/gdu/meson.build b/monitor/gdu/meson.build
index 8ef2826..3117b1d 100644
--- a/monitor/gdu/meson.build
+++ b/monitor/gdu/meson.build
@@ -5,18 +5,12 @@ install_data(
   install_dir: gvfs_remote_volume_monitors_dir
 )
 
-service = gvfs_namespace + '.GduVolumeMonitor.service'
-
-gdu_service = configure_file(
-  input: service + '.in',
-  output: service,
-  install: true,
-  install_dir: dbus_service_dir,
-  configuration: service_conf
-)
+dbus_service = gvfs_namespace + '.GduVolumeMonitor'
+dbus_exec = 'gvfs-gdu-volume-monitor'
+dbus_systemd_service = ''
 
 if install_systemd_user_unit_dir
-  service = 'gvfs-gdu-volume-monitor.service'
+  service = dbus_exec + '.service'
 
   configure_file(
     input: service + '.in',
@@ -25,8 +19,23 @@ if install_systemd_user_unit_dir
     install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
+
+  dbus_systemd_service = 'SystemdService=' + service
 endif
 
+dbus_service_conf = configuration_data()
+dbus_service_conf.set('service', dbus_service)
+dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
+dbus_service_conf.set('systemd_service', dbus_systemd_service)
+
+gdu_service = configure_file(
+  input: dbus_service_in,
+  output: dbus_service + '.service',
+  install: true,
+  install_dir: dbus_service_dir,
+  configuration: dbus_service_conf
+)
+
 sources = files(
   'gdu-volume-monitor-daemon.c',
   'ggdudrive.c',
diff --git a/monitor/goa/meson.build b/monitor/goa/meson.build
index b45007c..da06308 100644
--- a/monitor/goa/meson.build
+++ b/monitor/goa/meson.build
@@ -3,18 +3,12 @@ install_data(
   install_dir: gvfs_remote_volume_monitors_dir
 )
 
-service = gvfs_namespace + '.GoaVolumeMonitor.service'
-
-configure_file(
-  input: service + '.in',
-  output: service,
-  install: true,
-  install_dir: dbus_service_dir,
-  configuration: service_conf
-)
+dbus_service = gvfs_namespace + '.GoaVolumeMonitor'
+dbus_exec = 'gvfs-goa-volume-monitor'
+dbus_systemd_service = ''
 
 if install_systemd_user_unit_dir
-  service = 'gvfs-goa-volume-monitor.service'
+  service = dbus_exec + '.service'
 
   configure_file(
     input: service + '.in',
@@ -23,8 +17,23 @@ if install_systemd_user_unit_dir
     install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
+
+  dbus_systemd_service = 'SystemdService=' + service
 endif
 
+dbus_service_conf = configuration_data()
+dbus_service_conf.set('service', dbus_service)
+dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
+dbus_service_conf.set('systemd_service', dbus_systemd_service)
+
+configure_file(
+  input: dbus_service_in,
+  output: dbus_service + '.service',
+  install: true,
+  install_dir: dbus_service_dir,
+  configuration: dbus_service_conf
+)
+
 sources = files(
   'goavolumemonitordaemon.c',
   'goavolume.c',
diff --git a/monitor/gphoto2/meson.build b/monitor/gphoto2/meson.build
index 7400071..e5527c3 100644
--- a/monitor/gphoto2/meson.build
+++ b/monitor/gphoto2/meson.build
@@ -5,18 +5,13 @@ install_data(
   install_dir: gvfs_remote_volume_monitors_dir
 )
 
-service = gvfs_namespace + '.GPhoto2VolumeMonitor.service'
 
-gphoto2_service = configure_file(
-  input: service + '.in',
-  output: service,
-  install: true,
-  install_dir: dbus_service_dir,
-  configuration: service_conf
-)
+dbus_service = gvfs_namespace + '.GPhoto2VolumeMonitor'
+dbus_exec = 'gvfs-gphoto2-volume-monitor'
+dbus_systemd_service = ''
 
 if install_systemd_user_unit_dir
-  service = 'gvfs-gphoto2-volume-monitor.service'
+  service = dbus_exec + '.service'
 
   configure_file(
     input: service + '.in',
@@ -25,8 +20,23 @@ if install_systemd_user_unit_dir
     install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
+
+  dbus_systemd_service = 'SystemdService=' + service
 endif
 
+dbus_service_conf = configuration_data()
+dbus_service_conf.set('service', dbus_service)
+dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
+dbus_service_conf.set('systemd_service', dbus_systemd_service)
+
+gphoto2_service = configure_file(
+  input: dbus_service_in,
+  output: dbus_service + '.service',
+  install: true,
+  install_dir: dbus_service_dir,
+  configuration: dbus_service_conf
+)
+
 sources = files(
   'gphoto2-volume-monitor-daemon.c',
   'ggphoto2volume.c',
diff --git a/monitor/mtp/meson.build b/monitor/mtp/meson.build
index a346876..d7879bc 100644
--- a/monitor/mtp/meson.build
+++ b/monitor/mtp/meson.build
@@ -3,18 +3,12 @@ install_data(
   install_dir: gvfs_remote_volume_monitors_dir
 )
 
-service = gvfs_namespace + '.MTPVolumeMonitor.service'
-
-configure_file(
-  input: service + '.in',
-  output: service,
-  install: true,
-  install_dir: dbus_service_dir,
-  configuration: service_conf
-)
+dbus_service = gvfs_namespace + '.MTPVolumeMonitor'
+dbus_exec = 'gvfs-mtp-volume-monitor'
+dbus_systemd_service = ''
 
 if install_systemd_user_unit_dir
-  service = 'gvfs-mtp-volume-monitor.service'
+  service = dbus_exec + '.service'
 
   configure_file(
     input: service + '.in',
@@ -23,8 +17,23 @@ if install_systemd_user_unit_dir
     install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
+
+  dbus_systemd_service = 'SystemdService=' + service
 endif
 
+dbus_service_conf = configuration_data()
+dbus_service_conf.set('service', dbus_service)
+dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
+dbus_service_conf.set('systemd_service', dbus_systemd_service)
+
+configure_file(
+  input: dbus_service_in,
+  output: dbus_service + '.service',
+  install: true,
+  install_dir: dbus_service_dir,
+  configuration: dbus_service_conf
+)
+
 sources = files(
   'mtp-volume-monitor-daemon.c',
   'gmtpvolume.c',
diff --git a/monitor/udisks2/meson.build b/monitor/udisks2/meson.build
index 50c928a..bd9a359 100644
--- a/monitor/udisks2/meson.build
+++ b/monitor/udisks2/meson.build
@@ -5,18 +5,12 @@ install_data(
   install_dir: gvfs_remote_volume_monitors_dir
 )
 
-service = gvfs_namespace + '.UDisks2VolumeMonitor.service'
-
-udisks2_service = configure_file(
-  input: service + '.in',
-  output: service,
-  install: true,
-  install_dir: dbus_service_dir,
-  configuration: service_conf
-)
+dbus_service = gvfs_namespace + '.UDisks2VolumeMonitor'
+dbus_exec = 'gvfs-udisks2-volume-monitor'
+dbus_systemd_service = ''
 
 if install_systemd_user_unit_dir
-  service = 'gvfs-udisks2-volume-monitor.service'
+  service = dbus_exec + '.service'
 
   configure_file(
     input: service + '.in',
@@ -25,8 +19,23 @@ if install_systemd_user_unit_dir
     install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
+
+  dbus_systemd_service = 'SystemdService=' + service
 endif
 
+dbus_service_conf = configuration_data()
+dbus_service_conf.set('service', dbus_service)
+dbus_service_conf.set('exec', join_paths(gvfs_libexecdir, dbus_exec))
+dbus_service_conf.set('systemd_service', dbus_systemd_service)
+
+udisks2_service = configure_file(
+  input: dbus_service_in,
+  output: dbus_service + '.service',
+  install: true,
+  install_dir: dbus_service_dir,
+  configuration: dbus_service_conf
+)
+
 sources = files(
   'udisks2volumemonitordaemon.c',
   'gvfsudisks2drive.c',


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