[tracker-miners/wip/hadess/domain: 1/2] data: Add option to set the D-Bus domain at build time
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [tracker-miners/wip/hadess/domain: 1/2] data: Add option to set the D-Bus domain at build time
- Date: Fri, 28 Aug 2020 13:13:38 +0000 (UTC)
commit 51eb9e8831fa07aa9590468b65d3888d5ab66df2
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 | 16 ++++++++++++++++
meson_options.txt | 4 ++++
src/miners/fs/meson.build | 11 +++++++++--
.../org.freedesktop.Tracker3.Miner.Files.service.in | 6 +++---
src/tracker-control/meson.build | 11 +++++++++--
...reedesktop.Tracker3.Miner.Files.Control.service.in | 4 ++--
src/tracker-extract/meson.build | 11 +++++++++--
.../org.freedesktop.Tracker3.Miner.Extract.service.in | 10 +++++++---
10 files changed, 85 insertions(+), 14 deletions(-)
---
diff --git a/data/meson.build b/data/meson.build
index 7f6672f49..b3fa6dd70 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: join_paths(get_option('datadir'), 'tracker@0@'.format(tracker_api_major),
'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..238943f53
--- /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=@MINER_FS_CACHE_LOCATION@
+
+# 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..ba59132df 100644
--- a/meson.build
+++ b/meson.build
@@ -345,6 +345,21 @@ 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('prefix') / get_option('datadir') / 'tracker@0@'.format(tracker_api_major) /
'domain-ontologies' / rule_file
+ conf.set('DOMAIN_ONTOLOGY_OPTIONS', '--domain-ontology ' + domain_rule_path)
+ conf.set('MINER_FILES_INITIAL_SLEEP', '--initial-sleep 0')
+ if get_option('miner_fs_cache_location') == ''
+ conf.set('MINER_FS_CACHE_LOCATION', '$XDG_CACHE_HOME/' + get_option('domain_prefix') + '/miner/files')
+ else
+ conf.set('MINER_FS_CACHE_LOCATION', get_option('miner_fs_cache_location'))
+ endif
+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>'))
@@ -451,6 +466,7 @@ summary = [
' Prefix: ' + get_option('prefix'),
' Source code location: ' + meson.source_root(),
' Compiler: ' + cc.get_id(),
+ ' Domain prefix: ' + get_option('domain_prefix'),
'\nFeature Support:',
' Battery/mains power detection: ' + battery_detection_library_name,
' Support for network status detection: ' + have_network_manager.to_string(),
diff --git a/meson_options.txt b/meson_options.txt
index 5ad5868f5..be2881e3a 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -15,6 +15,10 @@ 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('miner_fs_cache_location', type: 'string', value: '',
+ description: 'Location of the miner cache, only used when domain_prefix is not \'org.freedesktop\'')
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..e700dee6f 100644
--- a/src/miners/fs/meson.build
+++ b/src/miners/fs/meson.build
@@ -31,10 +31,17 @@ executable('tracker-miner-fs-@0@'.format(tracker_api_major),
# This file allows starting the service with D-Bus autoactivation.
# It's also used by tracker-control to identify the miner.
+tmp_conf = configuration_data()
+tmp_conf.merge_from(conf)
+if get_option('domain_prefix') == 'org.freedesktop'
+ tmp_conf.set ('SYSTEMD_SERVICE', 'SystemdService=tracker-miner-fs-3.service')
+else
+ tmp_conf.set ('SYSTEMD_SERVICE', '')
+endif
dbus_service_file = configure_file(
input: 'org.freedesktop.Tracker3.Miner.Files.service.in',
- output: 'org.freedesktop.Tracker3.Miner.Files.service',
- configuration: conf,
+ output: get_option('domain_prefix') + '.Tracker3.Miner.Files.service',
+ configuration: tmp_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..cc35460dd 100644
--- a/src/miners/fs/org.freedesktop.Tracker3.Miner.Files.service.in
+++ b/src/miners/fs/org.freedesktop.Tracker3.Miner.Files.service.in
@@ -1,7 +1,7 @@
[D-BUS Service]
-Name=org.freedesktop.Tracker3.Miner.Files
-Exec=@libexecdir@/tracker-miner-fs-3
-SystemdService=tracker-miner-fs-3.service
+Name=@DOMAIN_PREFIX@.Tracker3.Miner.Files
+Exec=@libexecdir@/tracker-miner-fs-3 @DOMAIN_ONTOLOGY_OPTIONS@ @MINER_FILES_INITIAL_SLEEP@
+@SYSTEMD_SERVICE@
# Miner details needed for tracker-control
Path=/org/freedesktop/Tracker3/Miner/Files
diff --git a/src/tracker-control/meson.build b/src/tracker-control/meson.build
index 7da2e869b..92703504b 100644
--- a/src/tracker-control/meson.build
+++ b/src/tracker-control/meson.build
@@ -40,10 +40,17 @@ executable('tracker-miner-fs-control-@0@'.format(tracker_api_major),
)
# This file allows starting the service with D-Bus autoactivation.
+tmp_conf = configuration_data()
+tmp_conf.merge_from(conf)
+if get_option('domain_prefix') == 'org.freedesktop'
+ tmp_conf.set ('SYSTEMD_SERVICE', 'SystemdService=tracker-miner-fs-control-3.service')
+else
+ tmp_conf.set ('SYSTEMD_SERVICE', '')
+endif
dbus_service_file = configure_file(
input: 'org.freedesktop.Tracker3.Miner.Files.Control.service.in',
- output: 'org.freedesktop.Tracker3.Miner.Files.Control.service',
- configuration: conf,
+ output: get_option('domain_prefix') + '.Tracker3.Miner.Files.Control.service',
+ configuration: tmp_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..261a2f5bb 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
+@SYSTEMD_SERVICE@
diff --git a/src/tracker-extract/meson.build b/src/tracker-extract/meson.build
index c6a5c6127..179856abe 100644
--- a/src/tracker-extract/meson.build
+++ b/src/tracker-extract/meson.build
@@ -166,10 +166,17 @@ executable('tracker-extract-@0@'.format(tracker_api_major),
# This file allows starting the service with D-Bus autoactivation.
# It's also used by tracker-control to identify the miner.
+tmp_conf = configuration_data()
+tmp_conf.merge_from(conf)
+if get_option('domain_prefix') == 'org.freedesktop'
+ tmp_conf.set ('SYSTEMD_SERVICE', 'SystemdService=tracker-extract-3.service')
+else
+ tmp_conf.set ('SYSTEMD_SERVICE', '')
+endif
dbus_service_file = configure_file(
input: 'org.freedesktop.Tracker3.Miner.Extract.service.in',
- output: 'org.freedesktop.Tracker3.Miner.Extract.service',
- configuration: conf,
+ output: get_option('domain_prefix') + '.Tracker3.Miner.Extract.service',
+ configuration: tmp_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..cd396057a 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
-SystemdService=tracker-extract-3.service
+Name=@DOMAIN_PREFIX@.Tracker3.Miner.Extract
+Exec=@libexecdir@/tracker-extract-3 @DOMAIN_ONTOLOGY_OPTIONS@
+@SYSTEMD_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]