From a73363ef4da9279fd59cc2cc26828ed7342f2cb9 Mon Sep 17 00:00:00 2001 From: Patrick Griffis Date: Mon, 19 Aug 2024 11:54:27 -0500 Subject: [PATCH] Add ability to set custom fusermount path This is only exposed in Meson as Autotools isn't recommended. This also removes the 'fuse' option as it seems redundant. --- configure.ac | 2 ++ meson.build | 9 ++++++++- meson_options.txt | 11 +++++------ src/builder-context.c | 6 ++---- src/meson.build | 3 ++- tests/libtest.sh | 6 +++++- tests/meson.build | 1 + 7 files changed, 25 insertions(+), 13 deletions(-) diff --git a/configure.ac b/configure.ac index c63f0759..26d3379f 100644 --- a/configure.ac +++ b/configure.ac @@ -230,6 +230,8 @@ GLIB_TESTS FLATPAK_BUILDER_VERSION=flatpak_builder_version AC_SUBST(FLATPAK_BUILDER_VERSION) +AC_DEFINE([FUSERMOUNT], ["fusermount"], [Path to fusermount binary]) + AC_CONFIG_FILES([ Makefile data/Makefile diff --git a/meson.build b/meson.build index c2749f06..5bb58154 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project( 'flatpak-builder', 'c', license: 'LGPL-2.1-or-later', - meson_version: '>= 0.56.2', + meson_version: '>= 0.62.0', version: '1.4.4', default_options: 'c_std=gnu99', ) @@ -44,6 +44,13 @@ debugedit = find_program('debugedit', version: '>= 5.0') appstreamcli = find_program('appstreamcli', version: '>= 0.15.0') appstreamcli_compose = run_command(appstreamcli, ['compose', '--help'], check: true) +fusermount = get_option('system_fusermount') +if fusermount == '' + fusermount_program = find_program(['fusermount3', 'fusermount'], required: true) +else + fusermount_program = find_program(fusermount, required: true) +endif + subdir('src') subdir('doc') if get_option('tests') diff --git a/meson_options.txt b/meson_options.txt index d5a0bd22..fbd37111 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -23,9 +23,8 @@ option( description: 'Whether to build and run unit tests' ) option( - 'fuse', - type: 'combo', - choices: ['2', '3', 'compatible'], - value: 'compatible', - description: 'Target a specific version of FUSE for best performance or support multiple versions' -) + 'system_fusermount', + type: 'string', + description: 'system fusermount executable, or empty string to try multiple names (fusermount3, fusermount) automatically', + value: '', +) \ No newline at end of file diff --git a/src/builder-context.c b/src/builder-context.c index f813f3f4..0fdf993a 100644 --- a/src/builder-context.c +++ b/src/builder-context.c @@ -839,8 +839,7 @@ static char *rofiles_unmount_path = NULL; static void rofiles_umount_handler (int signum) { - char *argv[] = { "fusermount", "-uz", NULL, - NULL }; + char *argv[] = { FUSERMOUNT, "-uz", NULL, NULL }; argv[2] = rofiles_unmount_path; g_debug ("Unmounting read-only fs: %s %s %s", argv[0], argv[1], argv[2]); @@ -979,8 +978,7 @@ gboolean builder_context_disable_rofiles (BuilderContext *self, GError **error) { - char *argv[] = { "fusermount", "-u", NULL, - NULL }; + char *argv[] = { FUSERMOUNT, "-u", NULL, NULL }; if (!self->use_rofiles) return TRUE; diff --git a/src/meson.build b/src/meson.build index 91798347..a737b41d 100644 --- a/src/meson.build +++ b/src/meson.build @@ -39,7 +39,8 @@ config_data.set('GLIB_VERSION_MIN_REQUIRED', 'GLIB_VERSION_2_66') # We support targeting specific fuse versions to optimize performance. # Currently only fuse2 has optimizations but this allows for future fuse3 # optimizations. -config_data.set('ASSUME_FUSE_2', get_option('fuse') == '2') +config_data.set('ASSUME_FUSE_2', fusermount_program.version().version_compare('< 3.0.0')) +config_data.set_quoted('FUSERMOUNT', fusermount_program.full_path()) config_h = configure_file( configuration: config_data, diff --git a/tests/libtest.sh b/tests/libtest.sh index 3536e922..46687626 100644 --- a/tests/libtest.sh +++ b/tests/libtest.sh @@ -30,6 +30,10 @@ else test_builddir=$(dirname $0) fi +if [ -z "${FUSERMOUNT}" ]; then + FUSERMOUNT=fusermount +fi + assert_not_reached () { echo $@ 1>&2; exit 1 } @@ -296,7 +300,7 @@ run_sh () { # fuse support is needed (and the kernel module needs to be loaded) for several # flatpak-builder tests skip_without_fuse () { - if [ ! -w /dev/fuse ] || ! command -v fusermount >/dev/null; then + if [ ! -w /dev/fuse ] || ! command -v "$FUSERMOUNT" >/dev/null; then echo "1..0 # SKIP this test requires fuse support" exit 0 fi diff --git a/tests/meson.build b/tests/meson.build index c324bf60..2275419a 100644 --- a/tests/meson.build +++ b/tests/meson.build @@ -6,6 +6,7 @@ test_env.set('FLATPAK_TESTS_DEBUG', '1') test_env.set('G_TEST_SRCDIR', meson.current_source_dir()) test_env.set('G_TEST_BUILDDIR', meson.current_build_dir()) test_env.prepend('PATH', meson.current_build_dir() / '..' / 'src', separator: ':') +test_env.set('FUSERMOUNT', fusermount_program.full_path()) test_names = [ 'test-builder',