[gnome-boxes/wip/carlosg/tracker3] Bundle Tracker Miners inside the Flatpak



commit bf728ca6c89e18f06aad6f7f24c3441b0d110b7c
Author: Sam Thursfield <sam afuera me uk>
Date:   Sun Aug 2 14:08:44 2020 +0200

    Bundle Tracker Miners inside the Flatpak
    
    This allows Boxes to use Tracker for indexing on systems which don't
    have Tracker 3 available on the host.

 build-aux/flatpak/org.gnome.Boxes.json             | 50 +++++-----------------
 data/meson.build                                   |  1 +
 data/tracker/meson.build                           | 33 ++++++++++++++
 ...g.gnome.Boxes.Tracker3.Miner.Extract.service.in |  7 +++
 ...org.gnome.Boxes.Tracker3.Miner.Files.service.in |  7 +++
 data/tracker/org.gnome.Boxes.domain.rule.in        | 20 +++++++++
 src/media-manager.vala                             | 10 +++++
 7 files changed, 88 insertions(+), 40 deletions(-)
---
diff --git a/build-aux/flatpak/org.gnome.Boxes.json b/build-aux/flatpak/org.gnome.Boxes.json
index 24013de3..3f091234 100644
--- a/build-aux/flatpak/org.gnome.Boxes.json
+++ b/build-aux/flatpak/org.gnome.Boxes.json
@@ -16,14 +16,15 @@
         "--system-talk-name=org.freedesktop.timedate1",
         "--system-talk-name=org.freedesktop.Accounts",
         "--filesystem=/var/lib/AccountsService/icons:ro",
-        "--talk-name=org.freedesktop.Tracker1",
-        "--env=TRACKER_SPARQL_BACKEND=bus",
         "--talk-name=org.freedesktop.secrets",
         "--filesystem=xdg-run/dconf",
         "--filesystem=~/.config/dconf:ro",
         "--filesystem=home",
         "--talk-name=ca.desrt.dconf",
-        "--env=DCONF_USER_CONFIG_DIR=.config/dconf"
+        "--env=DCONF_USER_CONFIG_DIR=.config/dconf",
+        "--add-policy=Tracker3.dbus:org.freedesktop.Tracker3.Miner.Files=tracker:Software",
+        "--own-name=org.gnome.BoxesDevel.Tracker3.Miner.Files",
+        "--own-name=org.gnome.BoxesDevel.Tracker3.Miner.Extract"
     ],
     "modules" : [
         {
@@ -289,59 +290,28 @@
                 }
             ]
         },
-        {
-            "name" : "tracker",
-            "buildsystem" : "meson",
-            "cleanup" : [
-                "/bin",
-                "/etc",
-                "/libexec"
-            ],
-            "config-opts" : [
-                "-Dbash_completion=no",
-                "-Dfunctional_tests=false",
-                "-Dman=false",
-                "-Ddocs=false",
-                "-Dsystemd_user_services=no"
-            ],
-            "sources" : [
-                {
-                    "type" : "git",
-                    "url" : "https://gitlab.gnome.org/GNOME/tracker.git";,
-                    "branch": "tracker-2.3"
-                }
-            ]
-        },
         {
             "name": "tracker-miners",
             "buildsystem": "meson",
             "cleanup": [
                 "/etc",
-                "/lib",
                 "/libexec",
-                "/share/dbus-1/services/org.freedesktop.Tracker1.Miner.Extract.service",
-                "/share/dbus-1/services/org.freedesktop.Tracker1.Writeback.service",
-                "/share/tracker/miners/org.freedesktop.Tracker1.Miner.Applications.service",
-                "/share/tracker/miners/org.freedesktop.Tracker1.Miner.Extract.service",
-                "/share/tracker/miners/org.freedesktop.Tracker1.Miner.RSS.service",
-                "/share/tracker-miners",
-                "/share/glib-2.0/schemas/org.freedesktop.Tracker.Extract.gschema.xml",
-                "/share/glib-2.0/schemas/org.freedesktop.Tracker.Writeback.gschema.xml"
+                "/share/dbus-1/services",
+                "/share/tracker/miners"
             ],
             "config-opts": [
-                "-Dextract=false",
+                "-Dextract=true",
                 "-Dgeneric_media_extractor=none",
-                "-Dminer_apps=false",
+                "-Dman=false",
                 "-Dminer_fs=true",
                 "-Dminer_rss=false",
-                "-Dsystemd_user_services=no",
+                "-Dsystemd_user_services=false",
                 "-Dwriteback=false"
             ],
             "sources": [
                 {
                     "type": "git",
-                    "url": "https://gitlab.gnome.org/GNOME/tracker-miners.git";,
-                    "branch" : "tracker-miners-2.3"
+                    "url": "https://gitlab.gnome.org/GNOME/tracker-miners.git";
                 }
             ]
         },
diff --git a/data/meson.build b/data/meson.build
index d32638a8..fdc102eb 100644
--- a/data/meson.build
+++ b/data/meson.build
@@ -110,3 +110,4 @@ install_data ('QEMU_Session', install_dir : join_paths (data_dir, 'gnome-boxes/s
 install_data ('disk.img', install_dir : join_paths (data_dir, 'gnome-boxes/unattended'))
 
 subdir ('osinfo')
+subdir ('tracker')
diff --git a/data/tracker/meson.build b/data/tracker/meson.build
new file mode 100644
index 00000000..a4008b4e
--- /dev/null
+++ b/data/tracker/meson.build
@@ -0,0 +1,33 @@
+# Files needed for running Tracker inside the Flatpak sandbox, for systems
+# which don't have a suitable version of Tracker in the host OS.
+#
+# We must export the .service files from the sandbox so they work on the
+# session bus. This means the Tracker domain name must correspond with the
+# application ID.
+
+
+domain_ontologies_dir = get_option('datadir') / 'tracker3' / 'domain-ontologies'
+dbus_services_dir = get_option('datadir') / 'dbus-1' / 'services'
+
+tracker_domain_config = configuration_data()
+tracker_domain_config.set('application_id', application_id)
+tracker_domain_config.set('domain_rule', get_option('prefix') / domain_ontologies_dir / application_id + 
'.domain.rule')
+
+configure_file(
+  input: 'org.gnome.Boxes.domain.rule.in',
+  output: application_id + '.domain.rule',
+  configuration: tracker_domain_config,
+  install_dir: domain_ontologies_dir)
+
+configure_file(
+  input: 'org.gnome.Boxes.Tracker3.Miner.Extract.service.in',
+  output: application_id + '.Tracker3.Miner.Extract.service',
+  configuration: tracker_domain_config,
+  install_dir: dbus_services_dir)
+
+configure_file(
+  input: 'org.gnome.Boxes.Tracker3.Miner.Files.service.in',
+  output: application_id + '.Tracker3.Miner.Files.service',
+  configuration: tracker_domain_config,
+  install_dir: dbus_services_dir)
+
diff --git a/data/tracker/org.gnome.Boxes.Tracker3.Miner.Extract.service.in 
b/data/tracker/org.gnome.Boxes.Tracker3.Miner.Extract.service.in
new file mode 100644
index 00000000..eb7a87aa
--- /dev/null
+++ b/data/tracker/org.gnome.Boxes.Tracker3.Miner.Extract.service.in
@@ -0,0 +1,7 @@
+[D-BUS Service]
+Name=@application_id@.Tracker3.Miner.Extract
+Exec=/app/libexec/tracker-extract-3 --domain-ontology @domain_rule@
+
+# Miner details needed for tracker-control
+Path=/org/freedesktop/Tracker3/Miner/Extract
+NameSuffix=Miner.Files
diff --git a/data/tracker/org.gnome.Boxes.Tracker3.Miner.Files.service.in 
b/data/tracker/org.gnome.Boxes.Tracker3.Miner.Files.service.in
new file mode 100644
index 00000000..4fa7371d
--- /dev/null
+++ b/data/tracker/org.gnome.Boxes.Tracker3.Miner.Files.service.in
@@ -0,0 +1,7 @@
+[D-BUS Service]
+Name=@application_id@.Tracker3.Miner.Files
+Exec=/app/libexec/tracker-miner-fs-3 --domain-ontology @domain_rule@ --initial-sleep 0
+
+# Miner details needed for tracker-control
+Path=/org/freedesktop/Tracker3/Miner/Files
+NameSuffix=Miner.Files
diff --git a/data/tracker/org.gnome.Boxes.domain.rule.in b/data/tracker/org.gnome.Boxes.domain.rule.in
new file mode 100644
index 00000000..b0c3f549
--- /dev/null
+++ b/data/tracker/org.gnome.Boxes.domain.rule.in
@@ -0,0 +1,20 @@
+# This defines a private Tracker domain for GNOME Photos.
+#
+# It's used to run the Tracker indexer inside a Flatpak sandbox, when Photos is
+# running on a host that doesn't have a suitable version of Tracker installed.
+
+[DomainOntology]
+# Location for the Tracker database
+CacheLocation=$XDG_CACHE_HOME/gnome-boxes/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=@application_id@
+
+# List of miners we expect to run in this domain.
+Miners=Miner.Files;Miner.Extract
diff --git a/src/media-manager.vala b/src/media-manager.vala
index 26992977..f1aa7f51 100644
--- a/src/media-manager.vala
+++ b/src/media-manager.vala
@@ -226,7 +226,17 @@ private MediaManager () {
             connection = Sparql.Connection.bus_new ("org.freedesktop.Tracker3.Miner.Files",
                                                     null, null);
         } catch (GLib.Error error) {
+#if !FLATPAK
             critical ("Error connecting to Tracker: %s", error.message);
+#else
+            message ("Error connecting to host Tracker Miners: %s", error.message);
+            try {
+                connection = Sparql.Connection.bus_new (config.APPLICATION_ID + "Tracker3.Miner.Files",
+                                                        null, null);
+            } catch (GLib.Error error) {
+                critical ("Error starting local Tracker Miners: %s", error.message);
+            }
+#endif
         }
     }
 


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