From 186d91759dd0e0815f5a9d3a709e2ececa24ff3d Mon Sep 17 00:00:00 2001
From: Markus Volk <f_l_k@t-online.de>
Date: Mon, 18 Sep 2023 02:47:55 +0200
Subject: [PATCH] tracker: fix reproducibility issue

Tracker's design seems to be strictly for non-cross builds and leaks buildpaths into the
binaries at various places. Avoid this to improve binary reproducibility.

todo: Some of these paths may need to be adjusted to make the test environment work

Upstream-Status: Inappropriate [oe-specific]

Signed-off-by: Markus Volk <f_l_k@t-online.de>
---
 meson.build                   | 6 +++---
 src/common/meson.build        | 4 ++--
 src/http/tracker-http.c       | 2 +-
 src/libtinysparql/meson.build | 4 ++--
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/meson.build b/meson.build
index 308ada3..0120be7 100644
--- a/meson.build
+++ b/meson.build
@@ -341,7 +341,7 @@ have_rtld_noload = cc.has_header_symbol('dlfcn.h', 'RTLD_NOLOAD')
 conf.set('HAVE_RTLD_NOLOAD', have_rtld_noload)
 
 # Config that goes in some other generated files (.desktop, .service, etc)
-conf.set('abs_top_builddir', meson.current_build_dir())
+conf.set('abs_top_builddir', '/usr/src/debug/tracker')
 conf.set('libexecdir', join_paths(get_option('prefix'), get_option('libexecdir')))
 
 configure_file(input: 'config.h.meson.in',
@@ -382,8 +382,8 @@ subdir('utils')
 subdir('fuzzing')
 
 test_c_args = tracker_c_args + [
-    '-DTOP_BUILDDIR="@0@"'.format(build_root),
-    '-DTOP_SRCDIR="@0@"'.format(source_root),
+    '-DTOP_BUILDDIR="@0@/"'.format('/usr/src/debug/tracker'),
+    '-DTOP_SRCDIR="@0@/"'.format('/usr/src/debug/tracker'),
 ]
 
 tracker_uninstalled_testutils_dir = join_paths(meson.current_source_dir(), 'utils')
diff --git a/src/common/meson.build b/src/common/meson.build
index b961ec3..edd76ce 100644
--- a/src/common/meson.build
+++ b/src/common/meson.build
@@ -70,10 +70,10 @@ libtracker_common = static_library('tracker-common',
   dependencies: [tracker_common_dependencies, gmodule],
   c_args: [
     '-DPRIVATE_LIBDIR="@0@"'.format(tracker_internal_libs_dir),
-    '-DBUILD_LIBDIR="@0@"'.format(meson.current_build_dir()),
+    '-DBUILD_LIBDIR="@0@"'.format('/usr/src/debug/tracker'),
     # Global build root is required to detect noinst situations (tests/introspection),
     # event when built as a subproject
-    '-DBUILDROOT="@0@"'.format(meson.global_build_root()),
+    '-DBUILDROOT="@0@"'.format('/usr/src/debug/tracker'),
   ] + tracker_c_args,
   include_directories: [configinc, srcinc],
   gnu_symbol_visibility: 'hidden',
diff --git a/src/http/tracker-http.c b/src/http/tracker-http.c
index dd82e99..cb3f1f7 100644
--- a/src/http/tracker-http.c
+++ b/src/http/tracker-http.c
@@ -53,7 +53,7 @@ ensure_types (void)
 
 		current_dir = g_get_current_dir ();
 
-		if (g_strcmp0 (current_dir, BUILDROOT) == 0) {
+		if (0) {
 			/* Detect in-build runtime of this code, this may happen
 			 * building introspection information or running tests.
 			 * We want the in-tree modules to be loaded then.
diff --git a/src/libtinysparql/meson.build b/src/libtinysparql/meson.build
index e229b51..031f7e1 100644
--- a/src/libtinysparql/meson.build
+++ b/src/libtinysparql/meson.build
@@ -103,10 +103,10 @@ libtracker_sparql_private = static_library('tracker-sparql-private',
     c_args: [
 	'-include', 'tracker-private.h',
         '-DPRIVATE_LIBDIR="@0@"'.format(tracker_internal_libs_dir),
-        '-DBUILD_LIBDIR="@0@"'.format(meson.current_build_dir()),
+        '-DBUILD_LIBDIR="@0@"'.format('/usr/src/debug/tracker'),
         # Global build root is required to detect noinst situations (tests/introspection),
         # event when built as a subproject
-        '-DBUILDROOT="@0@"'.format(meson.global_build_root()),
+        '-DBUILDROOT="@0@"'.format('/usr/src/debug/tracker'),
     ] + tracker_c_args,
 
     dependencies: [libtracker_sparql_dependencies],
