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




commit c952ec3f447433418644767fb41fc514ab69725f
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/domain/DOMAIN.Tracker3.Miner.Extract.service.in |  7 +++++++
 data/domain/DOMAIN.Tracker3.Miner.Files.service.in   |  7 +++++++
 data/domain/DOMAIN.domain.rule.in                    | 19 +++++++++++++++++++
 data/domain/meson.build                              | 16 ++++++++++++++++
 data/meson.build                                     |  2 ++
 meson.build                                          |  1 +
 meson_options.txt                                    |  2 ++
 7 files changed, 54 insertions(+)
---
diff --git a/data/domain/DOMAIN.Tracker3.Miner.Extract.service.in 
b/data/domain/DOMAIN.Tracker3.Miner.Extract.service.in
new file mode 100644
index 000000000..603f07acb
--- /dev/null
+++ b/data/domain/DOMAIN.Tracker3.Miner.Extract.service.in
@@ -0,0 +1,7 @@
+[D-BUS Service]
+Name=@DOMAIN@.Tracker3.Miner.Extract
+Exec=@libexecdir@/tracker-extract-3 --domain-ontology @datadir@/tracker3/domain-ontologies/@DOMAIN  domain 
rule
+
+# Miner details needed for tracker-control
+Path=/org/freedesktop/Tracker3/Miner/Extract
+NameSuffix=Miner.Extract
diff --git a/data/domain/DOMAIN.Tracker3.Miner.Files.service.in 
b/data/domain/DOMAIN.Tracker3.Miner.Files.service.in
new file mode 100644
index 000000000..0b8463eb8
--- /dev/null
+++ b/data/domain/DOMAIN.Tracker3.Miner.Files.service.in
@@ -0,0 +1,7 @@
+[D-BUS Service]
+Name=@DOMAIN@.Tracker3.Miner.Files
+Exec=@libexecdir@/tracker-miner-fs-3 --domain-ontology @datadir@/tracker3/domain-ontologies/@DOMAIN  domain 
rule --initial-sleep 0
+
+# Miner details needed for tracker-control
+Path=/org/freedesktop/Tracker3/Miner/Files
+NameSuffix=Miner.Files
diff --git a/data/domain/DOMAIN.domain.rule.in b/data/domain/DOMAIN.domain.rule.in
new file mode 100644
index 000000000..45d8a5bbc
--- /dev/null
+++ b/data/domain/DOMAIN.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@/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@
+
+# List of miners we expect to run in this domain.
+Miners=Miner.Files;Miner.Extract
diff --git a/data/domain/meson.build b/data/domain/meson.build
new file mode 100644
index 000000000..eca9be7ab
--- /dev/null
+++ b/data/domain/meson.build
@@ -0,0 +1,16 @@
+if get_option('domain') != ''
+  domain = get_option('domain')
+
+  configure_file(input: 'DOMAIN.domain.rule.in',
+                 output: domain + 'domain.rule',
+                 configuration: conf,
+                 install_dir: get_option('datadir') / 'tracker/domain-ontologies/')
+  configure_file(input: 'DOMAIN.Tracker3.Miner.Extract.service.in',
+                 output: domain + '.Tracker3.Miner.Extract.service',
+                 configuration: conf,
+                 install_dir: get_option('datadir') / 'dbus-1/services')
+  configure_file(input: 'DOMAIN.Tracker3.Miner.Files.service.in',
+                 output: domain + '.Tracker3.Miner.Files.service',
+                 configuration: conf,
+                 install_dir: get_option('datadir') / 'dbus-1/services')
+endif
diff --git a/data/meson.build b/data/meson.build
index 7f6672f49..da8cb0266 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -1,3 +1,5 @@
+subdir('domain')
+
 schemas = {
   'org.freedesktop.Tracker.Extract.gschema.xml': 'org.freedesktop.Tracker@0  Extract gschema 
xml'.format(tracker_api_major),
   'org.freedesktop.Tracker.FTS.gschema.xml': 'org.freedesktop.Tracker@0  FTS gschema 
xml'.format(tracker_api_major),
diff --git a/meson.build b/meson.build
index f89d33513..2a79fb774 100644
--- a/meson.build
+++ b/meson.build
@@ -345,6 +345,7 @@ 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', get_option('domain'))
 
 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..1d7129b6b 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', type: 'string', value: '',
+       description: 'Domain prefix to use for sandboxed')
 
 option('network_manager', type: 'feature', value: 'auto',
        description: 'Connection detection through NetworkManager')


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