[tracker-miners/wip/hadess/domain] data: Add option to set the D-Bus domain at build time




commit 64bf426e614c652659a2e7a27f8e89e6a58c5e18
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Aug 27 12:45:23 2020 +0200

    data: Add option to set the D-Bus domain at build time
    
    Make it easier to run the tracker miners inside a sandbox by installing
    the necessary files under a specific domain when the -Ddomain option is
    passed.
    
    Closes: #122

 data/meson.build                                      |  7 +++++++
 data/org.freedesktop.domain.rule.in                   | 19 +++++++++++++++++++
 meson.build                                           | 10 ++++++++++
 meson_options.txt                                     |  2 ++
 src/miners/fs/meson.build                             |  2 +-
 .../org.freedesktop.Tracker3.Miner.Files.service.in   |  4 ++--
 src/tracker-control/meson.build                       |  2 +-
 ...reedesktop.Tracker3.Miner.Files.Control.service.in |  2 +-
 src/tracker-extract/meson.build                       |  2 +-
 .../org.freedesktop.Tracker3.Miner.Extract.service.in |  8 ++++++--
 10 files changed, 50 insertions(+), 8 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 7f6672f49..4cc9d420e 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -48,3 +48,10 @@ install_data('default.rule',
     install_dir: join_paths(get_option('datadir'), tracker_versioned_name, 'domain-ontologies'))
 
 tracker_miners_uninstalled_domain_rule = meson.current_source_dir() / 'default.rule'
+
+if get_option('domain_prefix') != 'org.freedesktop'
+  configure_file(input: 'org.freedesktop.domain.rule.in',
+                 output: get_option('domain_prefix') + '.domain.rule',
+                 configuration: conf,
+                 install_dir: get_option('datadir') / 'tracker/domain-ontologies/')
+endif
diff --git a/data/org.freedesktop.domain.rule.in b/data/org.freedesktop.domain.rule.in
new file mode 100644
index 000000000..9a0d42894
--- /dev/null
+++ b/data/org.freedesktop.domain.rule.in
@@ -0,0 +1,19 @@
+# This defines a private Tracker domain for @DOMAIN@
+#
+# It's used to run the Tracker indexer inside a Flatpak sandbox.
+
+[DomainOntology]
+# Location for the Tracker database
+CacheLocation=$XDG_CACHE_HOME/@DOMAIN_PREFIX@/miner/files
+
+# Name of the ontology to use, must be one located in
+# $(sharedir)/tracker/ontologies
+OntologyName=nepomuk
+
+# DBus name for the owner (not optional). Tracker will use
+# the domain as the prefix of the DBus name for all the
+# services related to this domain ontology.
+Domain=@DOMAIN_PREFIX@
+
+# List of miners we expect to run in this domain.
+Miners=Miner.Files;Miner.Extract
diff --git a/meson.build b/meson.build
index f89d33513..e5defc066 100644
--- a/meson.build
+++ b/meson.build
@@ -345,6 +345,16 @@ conf.set('HAVE_LIBIPTCDATA', libiptcdata.found())
 conf.set('HAVE_LIBSECCOMP', libseccomp.found())
 conf.set('HAVE_UPOWER', battery_detection_library_name == 'upower')
 conf.set('HAVE_NETWORK_MANAGER', have_network_manager)
+conf.set('DOMAIN_PREFIX', get_option('domain_prefix'))
+if get_option('domain_prefix') != 'org.freedesktop'
+  rule_file = get_option('domain_prefix') + '.domain.rule'
+  domain_rule_path = get_option('datadir') / 'tracker3/domain-ontologies' / rule_file
+  conf.set('DOMAIN_ONTOLOGY_OPTIONS', '--domain-ontology ' + rule_file)
+  conf.set('MINER_FILES_INITIAL_SLEEP', '--initial-sleep 0')
+else
+  conf.set('DOMAIN_ONTOLOGY_OPTIONS', '')
+  conf.set('MINER_FILES_INITIAL_SLEEP', '')
+endif
 
 conf.set('HAVE_GETLINE', cc.has_function('getline', prefix : '#include <stdio.h>'))
 conf.set('HAVE_POSIX_FADVISE', cc.has_function('posix_fadvise', prefix : '#include <fcntl.h>'))
diff --git a/meson_options.txt b/meson_options.txt
index 5ad5868f5..ecb839b44 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -15,6 +15,8 @@ option('miner_rss', type: 'boolean', value: true,
        description: 'Enable the Tracker RSS miner')
 option('writeback', type: 'boolean', value: true,
        description: 'Enable Tracker writeback feature')
+option('domain_prefix', type: 'string', value: 'org.freedesktop',
+       description: 'Domain prefix to use, useful for sandboxing')
 
 option('network_manager', type: 'feature', value: 'auto',
        description: 'Connection detection through NetworkManager')
diff --git a/src/miners/fs/meson.build b/src/miners/fs/meson.build
index bf73467aa..8de4c82a2 100644
--- a/src/miners/fs/meson.build
+++ b/src/miners/fs/meson.build
@@ -33,7 +33,7 @@ executable('tracker-miner-fs-@0@'.format(tracker_api_major),
 # It's also used by tracker-control to identify the miner.
 dbus_service_file = configure_file(
     input: 'org.freedesktop.Tracker3.Miner.Files.service.in',
-    output: 'org.freedesktop.Tracker3.Miner.Files.service',
+    output: get_option('domain_prefix') + '.Tracker3.Miner.Files.service',
     configuration: conf,
     install: true,
     install_dir: dbus_services_dir,
diff --git a/src/miners/fs/org.freedesktop.Tracker3.Miner.Files.service.in 
b/src/miners/fs/org.freedesktop.Tracker3.Miner.Files.service.in
index 867c246dd..9cfbf2576 100644
--- a/src/miners/fs/org.freedesktop.Tracker3.Miner.Files.service.in
+++ b/src/miners/fs/org.freedesktop.Tracker3.Miner.Files.service.in
@@ -1,6 +1,6 @@
 [D-BUS Service]
-Name=org.freedesktop.Tracker3.Miner.Files
-Exec=@libexecdir@/tracker-miner-fs-3
+Name=@DOMAIN_PREFIX@.Tracker3.Miner.Files
+Exec=@libexecdir@/tracker-miner-fs-3 @DOMAIN_ONTOLOGY_OPTIONS@ @MINER_FILES_INITIAL_SLEEP@
 SystemdService=tracker-miner-fs-3.service
 
 # Miner details needed for tracker-control
diff --git a/src/tracker-control/meson.build b/src/tracker-control/meson.build
index 7da2e869b..4a1d1937a 100644
--- a/src/tracker-control/meson.build
+++ b/src/tracker-control/meson.build
@@ -42,7 +42,7 @@ executable('tracker-miner-fs-control-@0@'.format(tracker_api_major),
 # This file allows starting the service with D-Bus autoactivation.
 dbus_service_file = configure_file(
     input: 'org.freedesktop.Tracker3.Miner.Files.Control.service.in',
-    output: 'org.freedesktop.Tracker3.Miner.Files.Control.service',
+    output: get_option('domain_prefix') + '.Tracker3.Miner.Files.Control.service',
     configuration: conf,
     install: true,
     install_dir: dbus_services_dir,
diff --git a/src/tracker-control/org.freedesktop.Tracker3.Miner.Files.Control.service.in 
b/src/tracker-control/org.freedesktop.Tracker3.Miner.Files.Control.service.in
index 8eae780d9..16c900f98 100644
--- a/src/tracker-control/org.freedesktop.Tracker3.Miner.Files.Control.service.in
+++ b/src/tracker-control/org.freedesktop.Tracker3.Miner.Files.Control.service.in
@@ -1,4 +1,4 @@
 [D-BUS Service]
-Name=org.freedesktop.Tracker3.Miner.Files.Control
+Name=@DOMAIN_PREFIX@.Tracker3.Miner.Files.Control
 Exec=@libexecdir@/tracker-miner-fs-control-3
 SystemdService=tracker-miner-fs-control-3.service
diff --git a/src/tracker-extract/meson.build b/src/tracker-extract/meson.build
index c6a5c6127..7c014cef2 100644
--- a/src/tracker-extract/meson.build
+++ b/src/tracker-extract/meson.build
@@ -168,7 +168,7 @@ executable('tracker-extract-@0@'.format(tracker_api_major),
 # It's also used by tracker-control to identify the miner.
 dbus_service_file = configure_file(
   input: 'org.freedesktop.Tracker3.Miner.Extract.service.in',
-  output: 'org.freedesktop.Tracker3.Miner.Extract.service',
+  output: get_option('domain_prefix') + '.Tracker3.Miner.Extract.service',
   configuration: conf,
   install: true,
   install_dir: dbus_services_dir)
diff --git a/src/tracker-extract/org.freedesktop.Tracker3.Miner.Extract.service.in 
b/src/tracker-extract/org.freedesktop.Tracker3.Miner.Extract.service.in
index 4fd5dc069..616dd7c4a 100644
--- a/src/tracker-extract/org.freedesktop.Tracker3.Miner.Extract.service.in
+++ b/src/tracker-extract/org.freedesktop.Tracker3.Miner.Extract.service.in
@@ -1,4 +1,8 @@
 [D-BUS Service]
-Name=org.freedesktop.Tracker3.Miner.Extract
-Exec=@libexecdir@/tracker-extract-3
+Name=@DOMAIN_PREFIX@.Tracker3.Miner.Extract
+Exec=@libexecdir@/tracker-extract-3 @DOMAIN_ONTOLOGY_OPTIONS@
 SystemdService=tracker-extract-3.service
+
+# Miner details needed for tracker-control
+Path=/org/freedesktop/Tracker3/Miner/Extract
+NameSuffix=Miner.Extract


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