From d820c4bc5eff63a67ff55c66e2bec9985f05ee10 Mon Sep 17 00:00:00 2001 From: bbhtt Date: Tue, 9 Jun 2026 00:36:15 +0530 Subject: [PATCH] tests: Fix FL_CACHE_DIR when system helper is compiled out The tests assumed that a system installation always uses the XDG cache location unless running as root. However, Flatpak only uses that cache location when the system helper is available at both compile and run time. [1] Builds configured with -Dsystem_helper=disabled instead use the repo-local cache directory [2], causing the tests to look for cached summaries in the wrong location and fail. [1]: https://github.com/flatpak/flatpak/blob/96ad6825f3e7115eb95abeba55600b2a39b71178/common/flatpak-dir.c#L4853-L4862 [2]: https://github.com/flatpak/flatpak/blob/96ad6825f3e7115eb95abeba55600b2a39b71178/common/flatpak-dir.c#L4942-L4943 --- tests/libtest.sh | 15 +++++++++------ tests/meson.build | 1 + 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/tests/libtest.sh b/tests/libtest.sh index 592d16c4f..fd96cfd21 100644 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -136,13 +136,16 @@ if [ x${USE_SYSTEMDIR-} == xyes ] ; then export FL_DIR=${SYSTEMDIR} export U= export INVERT_U=--user - if [ x${UID} == x0 ] ; then - # If running as root (which happens on some build machines), the - # system-helper will not be used, and hence the fallback cache dir will - # be used in _flatpak_dir_ensure_repo(). - export FL_CACHE_DIR=$FL_DIR/repo/tmp/cache - else + if [ x${HAVE_SYSTEM_HELPER-} == x1 ] && [ x${UID} != x0 ] ; then + # If system helper is compiled during build and will actually be + # used at runtime eg. UID != 0, Flatpak stores summary caches + # in the user's XDG cache directory export FL_CACHE_DIR=${XDG_CACHE_HOME}/flatpak/system-cache + else + # If the system helper is unavailable at build time, or it + # cannot be used eg. UID == 0 Flatpak uses the repo-local cache + # directory. + export FL_CACHE_DIR=$FL_DIR/repo/tmp/cache fi else export FL_DIR=${USERDIR} diff --git a/tests/meson.build b/tests/meson.build index a0942df37..53f8656de 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -31,6 +31,7 @@ tests_environment = { 'FLATPAK_BWRAP' : env_flatpak_bwrap, 'FLATPAK_DBUSPROXY' : env_flatpak_dbusproxy, 'HAVE_SECCOMP' : libseccomp_dep.found() ? '1' : '0', + 'HAVE_SYSTEM_HELPER' : build_system_helper ? '1' : '0', } tests_environment_prepend = {