[tracker-miners/sam/test-runner-fix: 12/31] writeback: Allow running tracker-writeback from the source tree



commit 968af8dae19c1cf47454580062c7b9c3ac8fdc90
Author: Sam Thursfield <sam afuera me uk>
Date:   Sat Nov 17 11:54:28 2018 +0100

    writeback: Allow running tracker-writeback from the source tree
    
    This commit adds a TRACKER_WRITEBACK_MODULES_DIR environment variable
    which lets us cause tracker-writeback to look for its modules in a
    custom location. This means it no longer needs to be installed into /usr
    in order to be used.
    
    This is needed to allow running the functional-test suite from the
    source tree. There is already a similar feature in tracker-extract.

 src/tracker-writeback/tracker-writeback-module.c | 21 ++++++++++++++++++---
 1 file changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/tracker-writeback/tracker-writeback-module.c 
b/src/tracker-writeback/tracker-writeback-module.c
index 3a1933ae3..cff2beb08 100644
--- a/src/tracker-writeback/tracker-writeback-module.c
+++ b/src/tracker-writeback/tracker-writeback-module.c
@@ -49,11 +49,19 @@ static gboolean
 writeback_module_load (GTypeModule *module)
 {
        TrackerWritebackModule *writeback_module;
+       const gchar *writeback_modules_dir;
        gchar *path;
 
        writeback_module = TRACKER_WRITEBACK_MODULE (module);
 
-       path = g_build_filename (WRITEBACK_MODULES_DIR, writeback_module->name, NULL);
+       writeback_modules_dir = g_getenv("TRACKER_WRITEBACK_MODULES_DIR");
+       if (G_LIKELY (writeback_modules_dir == NULL)) {
+               writeback_modules_dir = WRITEBACK_MODULES_DIR;
+       } else {
+               g_message ("Writeback modules directory is '%s' (set in env)", writeback_modules_dir);
+       }
+
+       path = g_build_filename (writeback_modules_dir, writeback_module->name, NULL);
        writeback_module->module = g_module_open (path, G_MODULE_BIND_LOCAL);
        g_free (path);
 
@@ -129,11 +137,18 @@ GList *
 tracker_writeback_modules_list (void)
 {
        GError *error = NULL;
-       const gchar *name;
+       const gchar *writeback_modules_dir, *name;
        GList *list = NULL;
        GDir *dir;
 
-       dir = g_dir_open (WRITEBACK_MODULES_DIR, 0, &error);
+       writeback_modules_dir = g_getenv("TRACKER_WRITEBACK_MODULES_DIR");
+       if (G_LIKELY (writeback_modules_dir == NULL)) {
+               writeback_modules_dir = WRITEBACK_MODULES_DIR;
+       } else {
+               g_message ("Writeback modules directory is '%s' (set in env)", writeback_modules_dir);
+       }
+
+       dir = g_dir_open (writeback_modules_dir, 0, &error);
 
        if (error) {
                g_critical ("Could not get writeback modules list: %s", error->message);


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