From 7affd66ff09747ad95b2e6de0b86ab06c97ca8f1 Mon Sep 17 00:00:00 2001
From: Markus Volk <f_l_k@t-online.de>
Date: Tue, 12 Sep 2023 17:00:41 +0200
Subject: [PATCH] meson: fix reproducibility

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 | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meson.build b/meson.build
index fe65280b6..6af5abec9 100644
--- a/meson.build
+++ b/meson.build
@@ -323,7 +323,7 @@ conf.set('PACKAGE_VERSION', '"@0@"'.format(meson.project_version()))
 conf.set('TRACKER_VERSION', '"@0@"'.format(meson.project_version()))
 
 # Config that goes in some other generated files (.desktop, .pc, etc)
-conf.set('abs_top_builddir', meson.current_build_dir())
+conf.set('abs_top_builddir', '')
 conf.set('exec_prefix', get_option('prefix'))
 conf.set('bindir', join_paths(get_option('prefix'), get_option('bindir')))
 conf.set('datadir', datadir)
@@ -353,7 +353,7 @@ tracker_c_args = [
 configinc = include_directories('./')
 srcinc = include_directories('src/')
 
-build_root = meson.current_build_dir()
+build_root = ''
 
 # We use tracker-miners-3.0 rather than tracker3-miners inside the lib64
 # directory, following the existing convention in that directory.
@@ -378,8 +378,8 @@ subdir('src')
 subdir('docs')
 
 test_c_args = tracker_c_args + [
-  '-DTOP_BUILDDIR="@0@/"'.format(meson.project_build_root()),
-  '-DTOP_SRCDIR="@0@/"'.format(meson.project_source_root()),
+  '-DTOP_BUILDDIR="@0@/"'.format(''),
+  '-DTOP_SRCDIR="@0@/"'.format('/usr/src/debug/tracker'),
 ]
 
 if get_option('tests_tap_protocol')
diff --git a/src/common/tracker-landlock.c b/src/common/tracker-landlock.c
index a3f390585..778ae62d9 100644
--- a/src/common/tracker-landlock.c	2026-03-15 01:40:56.000000000 +0100
+++ b/src/common/tracker-landlock.c	2026-03-26 16:49:16.948259117 +0100
@@ -299,7 +299,7 @@
 			          LANDLOCK_ACCESS_FS_READ_DIR);
 		}
 	}
-
+#if 0
 	current_dir = g_get_current_dir ();
 
 	/* Detect running in-tree */
@@ -319,7 +319,7 @@
 			          in_tree_rules[i].flags);
 		}
 	}
-
+#endif
 	/* Add user cache for readonly databases */
 #ifdef MINER_FS_CACHE_LOCATION
 	add_rule (landlock_fd, MINER_FS_CACHE_LOCATION,
--- a/src/indexer/meson.build	2026-03-15 01:40:56.000000000 +0100
+++ b/src/indexer/meson.build	2026-03-26 16:55:09.020362168 +0100
@@ -91,9 +91,9 @@ executable('localsearch-@0@'.format(tracker_api_major),
     dependencies: tracker_miner_fs_deps,
     c_args: [
         tracker_c_args,
-        '-DBUILDROOT="@0@"'.format(meson.global_build_root()),
-        '-DBUILDDIR="@0@"'.format(meson.current_build_dir()),
-        '-DBUILD_EXTRACTDIR="@0@"'.format(meson.project_build_root() / 'src' / 'extractor'),
+        '-DBUILDROOT="@0@"'.format(get_option('prefix') / 'src'),
+        '-DBUILDDIR="@0@"'.format(''),
+        '-DBUILD_EXTRACTDIR="@0@"'.format(get_option('prefix') / 'src' / 'extractor'),
         '-DLIBEXECDIR="@0@"'.format(get_option('prefix') / get_option('libexecdir')),
     ],
     install: true,
--- a/tests/indexer/meson.build	2026-03-15 01:40:56.000000000 +0100
+++ b/tests/indexer/meson.build	2026-03-26 17:01:29.686224071 +0100
@@ -18,7 +18,7 @@
 ]
 
 libtracker_miner_test_environment = environment()
-libtracker_miner_test_environment.set('GSETTINGS_SCHEMA_DIR', join_paths(meson.project_build_root(), 'data'))
+libtracker_miner_test_environment.set('GSETTINGS_SCHEMA_DIR', '/usr/src/debug/tracker-miners/data')
 
 libtracker_miner_test_deps = [tracker_miners_common_dep, tracker_miner_dep, tracker_sparql]
 
