From b0feb1b4233a76c93264cd9f7906c80dcd561d6b Mon Sep 17 00:00:00 2001
From: Will Angenent <will.angenent@gmail.com>
Date: Tue, 21 Mar 2023 03:00:19 +0000
Subject: [PATCH] Detect installed fusermount or fusermount3 binary

---
 bootstrap.sh        | 2 +-
 mk/config.mk        | 8 +++++++-
 podman_bootstrap.sh | 2 +-
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/bootstrap.sh b/bootstrap.sh
index 462cfe4b3..8813f9db8 100755
--- a/bootstrap.sh
+++ b/bootstrap.sh
@@ -353,7 +353,7 @@ gentoo()
 		echo "Installing git..."
 		sudo emerge dev-vcs/git
 	fi
-	if [ -z "$(which fusermount)" ]; then
+	if [ -z "$(which fusermount 2>/dev/null)" ] && [ -z "$(which fusermount3 2>/dev/null)" ]; then
 		echo "Installing fuse..."
 		sudo emerge sys-fs/fuse
 	fi
diff --git a/mk/config.mk b/mk/config.mk
index 6a7a70d97..cdd69bd8c 100644
--- a/mk/config.mk
+++ b/mk/config.mk
@@ -42,7 +42,13 @@ else ifeq ($(UNAME),FreeBSD)
 	VBM=VBoxManage
 	HOST_TARGET ?= $(HOST_ARCH)-unknown-freebsd
 else
-	FUMOUNT=fusermount -u
+	# Detect which version of the fusermount binary is available.
+	ifneq (, $(shell which fusermount3))
+		FUMOUNT=fusermount3 -u
+	else
+		FUMOUNT=fusermount -u
+	endif
+
 	export NPROC=nproc
 	export REDOX_MAKE=make
 	VB_AUDIO=pulse
diff --git a/podman_bootstrap.sh b/podman_bootstrap.sh
index d33f86e55..47794a28f 100755
--- a/podman_bootstrap.sh
+++ b/podman_bootstrap.sh
@@ -291,7 +291,7 @@ gentoo()
 		echo "Installing git..."
 		sudo emerge dev-vcs/git
 	fi
-	if [ -z "$(which fusermount)" ]; then
+	if [ -z "$(which fusermount 2>/dev/null)" ] && [ -z "$(which fusermount3 2>/dev/null)" ]; then
 		echo "Installing fuse..."
 		sudo emerge sys-fs/fuse
 	fi
-- 
GitLab