[gvfs] build: Improve installation on system paths



commit 5e2dff62c1ec332f3f8d7c0c1438835dc66a56b0
Author: Iñigo Martínez <inigomartinez gmail com>
Date:   Tue Oct 31 12:35:34 2017 +0100

    build: Improve installation on system paths
    
    Instead of being hardcoded, D-Bus, systemd and GIO modules paths
    can be checked by using the information in their correspondant
    pkg-config files.
    
    This patch uses the information on pkg-config files by default,
    and also allows the user to provide this information to avoid
    overwriting system files.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=786149

 client/meson.build          |    5 +--
 daemon/meson.build          |    6 ++--
 meson.build                 |   45 ++++++++++++++++++++++++++++--------------
 meson_options.txt           |    6 +++-
 metadata/meson.build        |    6 ++--
 monitor/afc/meson.build     |    6 ++--
 monitor/gdu/meson.build     |    6 ++--
 monitor/goa/meson.build     |    6 ++--
 monitor/gphoto2/meson.build |    6 ++--
 monitor/mtp/meson.build     |    6 ++--
 monitor/udisks2/meson.build |    6 ++--
 11 files changed, 60 insertions(+), 44 deletions(-)
---
diff --git a/client/meson.build b/client/meson.build
index 74ad446..fd69f94 100644
--- a/client/meson.build
+++ b/client/meson.build
@@ -74,11 +74,10 @@ endif
 
 # FUSE daemon
 if enable_fuse
-  # FIXME: reusing USE_LIBSYSTEMD_LOGIN as systemd has no universal header or pkg-config file
-  if enable_libsystemd_login
+  if install_tmp_files_dir
     install_data(
       'gvfsd-fuse-tmpfiles.conf',
-      install_dir: join_paths(gvfs_libdir, 'tmpfiles.d')
+      install_dir: tmp_files_dir
     )
   endif
 
diff --git a/daemon/meson.build b/daemon/meson.build
index d483a0a..606d83f 100644
--- a/daemon/meson.build
+++ b/daemon/meson.build
@@ -7,18 +7,18 @@ daemon_service = configure_file(
   input: service + '.in',
   output: service,
   install: true,
-  install_dir: gvfs_dbus_service_dir,
+  install_dir: dbus_service_dir,
   configuration: service_conf
 )
 
-if have_systemd_user_unit
+if install_systemd_user_unit_dir
   service = 'gvfs-daemon.service'
 
   configure_file(
     input: service + '.in',
     output: service,
     install: true,
-    install_dir: systemd_user_dir,
+    install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
 endif
diff --git a/meson.build b/meson.build
index e713b90..1782838 100644
--- a/meson.build
+++ b/meson.build
@@ -27,10 +27,8 @@ gvfs_pkglibdir = join_paths(gvfs_libdir, gvfs_name)
 
 gvfs_rpath = gvfs_pkglibdir
 
-gvfs_dbus_service_dir = join_paths(gvfs_datadir, 'dbus-1', 'services')
 gvfs_remote_volume_monitors_dir = join_paths(gvfs_pkgdatadir, 'remote-volume-monitors')
 
-gio_module_dir = join_paths(gvfs_libdir, 'gio', 'modules')
 gvfs_mountdir = join_paths(gvfs_pkgdatadir, 'mounts')
 gvfs_schema_dir = join_paths(gvfs_datadir, 'glib-2.0', 'schemas')
 
@@ -236,8 +234,10 @@ add_project_arguments(common_flags, language: 'c')
 ldflag = '-Wl,--version-script'
 have_version_script = host_machine.system().contains('linux') and cc.has_argument(ldflag)
 
+gio_dep = dependency('gio-2.0')
+
 glib_deps = [
-  dependency('gio-2.0'),
+  gio_dep,
   dependency('gio-unix-2.0'),
   dependency('glib-2.0', version: '>= 2.51.0'),
   dependency('gmodule-no-export-2.0'),
@@ -267,18 +267,36 @@ config_h.set('HAVE_GCRYPT', have_gcrypt)
 # *** Check for dbus service dir ***
 dbus_service_dir = get_option('with-dbus-service-dir')
 if dbus_service_dir == ''
-  dbus_service_dir = join_paths(gvfs_datadir, 'dbus-1', 'services')
+  dbus_dep = dependency('dbus-1', required: false)
+  assert(dbus_dep.found(), 'dbus-1 required but not found, please provide a valid D-Bus service dir')
+  dbus_service_dir = dbus_dep.get_pkgconfig_variable('session_bus_services_dir')
+endif
+
+gio_module_dir = get_option('with-gio-module-dir')
+if gio_module_dir == ''
+  gio_module_dir = gio_dep.get_pkgconfig_variable('giomoduledir')
 endif
 
-# *** Check for systemd user units ***
-systemd_user_dir = get_option('with-systemduserunitdir')
-have_systemd_user_unit = (systemd_user_dir != 'no')
+# *** Check for systemd options ***
+systemd_user_unit_dir = get_option('with-systemduserunitdir')
+install_systemd_user_unit_dir = (systemd_user_unit_dir != 'no')
 
-if have_systemd_user_unit
-  systemd_dep = dependency('systemd', version: '>= 206')
+tmp_files_dir = get_option('with-tmpfilesdir')
+install_tmp_files_dir = (tmp_files_dir != 'no')
 
-  if systemd_user_dir == ''
-    systemd_user_dir = join_paths(gvfs_libdir, 'systemd', 'user')
+if install_systemd_user_unit_dir or install_tmp_files_dir
+  if systemd_user_unit_dir == '' or tmp_files_dir == ''
+    systemd_dep = dependency('systemd', version: '>= 206', required: false)
+
+    if install_systemd_user_unit_dir and systemd_user_unit_dir == ''
+      assert(systemd_dep.found(), 'systemd required but not found, please provide a valid systemd user unit 
dir or disable it')
+      systemd_user_unit_dir = systemd_dep.get_pkgconfig_variable('systemduserunitdir')
+    endif
+
+    if install_tmp_files_dir and tmp_files_dir == ''
+      assert(systemd_dep.found(), 'systemd not found, if you use opentmpfiles please provide a valid systemd 
user unit dir or disable it')
+      tmp_files_dir = systemd_dep.get_pkgconfig_variable('tmpfilesdir')
+    endif
   endif
 endif
 
@@ -346,10 +364,7 @@ endif
 # *** Check for libsystemd-login ***
 enable_libsystemd_login = get_option('enable-libsystemd-login')
 if enable_libsystemd_login
-  libsystemd_login_dep = dependency('libsystemd', required: false)
-  if not libsystemd_login_dep.found()
-    libsystemd_login_dep = dependency('libsystemd-login', version: '>= 44')
-  endif
+  libsystemd_login_dep = dependency('libsystemd')
 endif
 config_h.set('HAVE_LIBSYSTEMD_LOGIN', enable_libsystemd_login)
 
diff --git a/meson_options.txt b/meson_options.txt
index 540535a..38b62df 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -1,5 +1,7 @@
-option('with-dbus-service-dir', type: 'string', value: '', description: 'choose directory for dbus service 
files [default=PREFIX/share/dbus-1/services]')
-option('with-systemduserunitdir', type: 'string', value: '', description: 'choose directory for systemd user 
units, or \'no\' to disable [default=PREFIX/lib/systemd/user]')
+option('with-dbus-service-dir', type: 'string', value: '', description: 'custom directory for dbus service 
files')
+option('with-gio-module-dir', type: 'string', value: '', description: 'custom directory for gio modules')
+option('with-systemduserunitdir', type: 'string', value: '', description: 'custom directory for systemd user 
units, or \'no\' to disable')
+option('with-tmpfilesdir', type: 'string', value: '', description: 'custom directory for tmpfiles.d config 
files, or \'no\' to disable')
 
 option('enable-admin', type: 'boolean', value: true, description: 'build with admin backend')
 option('enable-afc', type: 'boolean', value: true, description: 'build with afc backend and volume monitor')
diff --git a/metadata/meson.build b/metadata/meson.build
index 303280f..cdcb715 100644
--- a/metadata/meson.build
+++ b/metadata/meson.build
@@ -4,18 +4,18 @@ metadata_service = configure_file(
   input: service + '.in',
   output: service,
   install: true,
-  install_dir: gvfs_dbus_service_dir,
+  install_dir: dbus_service_dir,
   configuration: service_conf
 )
 
-if have_systemd_user_unit
+if install_systemd_user_unit_dir
   service = 'gvfs-metadata.service'
 
   configure_file(
     input: service + '.in',
     output: service,
     install: true,
-    install_dir: systemd_user_dir,
+    install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
 endif
diff --git a/monitor/afc/meson.build b/monitor/afc/meson.build
index 776341f..830f8cc 100644
--- a/monitor/afc/meson.build
+++ b/monitor/afc/meson.build
@@ -11,18 +11,18 @@ afc_service = configure_file(
   input: service + '.in',
   output: service,
   install: true,
-  install_dir: gvfs_dbus_service_dir,
+  install_dir: dbus_service_dir,
   configuration: service_conf
 )
 
-if have_systemd_user_unit
+if install_systemd_user_unit_dir
   service = 'gvfs-afc-volume-monitor.service'
 
   configure_file(
     input: service + '.in',
     output: service,
     install: true,
-    install_dir: systemd_user_dir,
+    install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
 endif
diff --git a/monitor/gdu/meson.build b/monitor/gdu/meson.build
index 653faeb..ba86563 100644
--- a/monitor/gdu/meson.build
+++ b/monitor/gdu/meson.build
@@ -11,18 +11,18 @@ gdu_service = configure_file(
   input: service + '.in',
   output: service,
   install: true,
-  install_dir: gvfs_dbus_service_dir,
+  install_dir: dbus_service_dir,
   configuration: service_conf
 )
 
-if have_systemd_user_unit
+if install_systemd_user_unit_dir
   service = 'gvfs-gdu-volume-monitor.service'
 
   configure_file(
     input: service + '.in',
     output: service,
     install: true,
-    install_dir: systemd_user_dir,
+    install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
 endif
diff --git a/monitor/goa/meson.build b/monitor/goa/meson.build
index 111d8d4..b45007c 100644
--- a/monitor/goa/meson.build
+++ b/monitor/goa/meson.build
@@ -9,18 +9,18 @@ configure_file(
   input: service + '.in',
   output: service,
   install: true,
-  install_dir: gvfs_dbus_service_dir,
+  install_dir: dbus_service_dir,
   configuration: service_conf
 )
 
-if have_systemd_user_unit
+if install_systemd_user_unit_dir
   service = 'gvfs-goa-volume-monitor.service'
 
   configure_file(
     input: service + '.in',
     output: service,
     install: true,
-    install_dir: systemd_user_dir,
+    install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
 endif
diff --git a/monitor/gphoto2/meson.build b/monitor/gphoto2/meson.build
index 2cb3128..7400071 100644
--- a/monitor/gphoto2/meson.build
+++ b/monitor/gphoto2/meson.build
@@ -11,18 +11,18 @@ gphoto2_service = configure_file(
   input: service + '.in',
   output: service,
   install: true,
-  install_dir: gvfs_dbus_service_dir,
+  install_dir: dbus_service_dir,
   configuration: service_conf
 )
 
-if have_systemd_user_unit
+if install_systemd_user_unit_dir
   service = 'gvfs-gphoto2-volume-monitor.service'
 
   configure_file(
     input: service + '.in',
     output: service,
     install: true,
-    install_dir: systemd_user_dir,
+    install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
 endif
diff --git a/monitor/mtp/meson.build b/monitor/mtp/meson.build
index 21eb427..a346876 100644
--- a/monitor/mtp/meson.build
+++ b/monitor/mtp/meson.build
@@ -9,18 +9,18 @@ configure_file(
   input: service + '.in',
   output: service,
   install: true,
-  install_dir: gvfs_dbus_service_dir,
+  install_dir: dbus_service_dir,
   configuration: service_conf
 )
 
-if have_systemd_user_unit
+if install_systemd_user_unit_dir
   service = 'gvfs-mtp-volume-monitor.service'
 
   configure_file(
     input: service + '.in',
     output: service,
     install: true,
-    install_dir: systemd_user_dir,
+    install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
 endif
diff --git a/monitor/udisks2/meson.build b/monitor/udisks2/meson.build
index 44e4923..995b300 100644
--- a/monitor/udisks2/meson.build
+++ b/monitor/udisks2/meson.build
@@ -11,18 +11,18 @@ udisks2_service = configure_file(
   input: service + '.in',
   output: service,
   install: true,
-  install_dir: gvfs_dbus_service_dir,
+  install_dir: dbus_service_dir,
   configuration: service_conf
 )
 
-if have_systemd_user_unit
+if install_systemd_user_unit_dir
   service = 'gvfs-udisks2-volume-monitor.service'
 
   configure_file(
     input: service + '.in',
     output: service,
     install: true,
-    install_dir: systemd_user_dir,
+    install_dir: systemd_user_unit_dir,
     configuration: service_conf
   )
 endif


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