git: 230cb49ccce5 - main - sysutils/fusefs-mergerfs: Add new port

From: Emanuel Haupt <ehaupt_at_FreeBSD.org>
Date: Wed, 02 Oct 2024 07:52:37 UTC
The branch main has been updated by ehaupt:

URL: https://cgit.FreeBSD.org/ports/commit/?id=230cb49ccce5a79985875ad16e36da0b8f9e8c52

commit 230cb49ccce5a79985875ad16e36da0b8f9e8c52
Author:     Emanuel Haupt <ehaupt@FreeBSD.org>
AuthorDate: 2024-10-02 07:52:13 +0000
Commit:     Emanuel Haupt <ehaupt@FreeBSD.org>
CommitDate: 2024-10-02 07:52:32 +0000

    sysutils/fusefs-mergerfs: Add new port
    
    mergerfs is a union filesystem geared towards simplifying storage and
    management of files across numerous commodity storage devices. It is
    similar to mhddfs, unionfs, and aufs.
---
 sysutils/Makefile                                  |  1 +
 sysutils/fusefs-mergerfs/Makefile                  | 27 ++++++++++++++++++++
 sysutils/fusefs-mergerfs/distinfo                  |  3 +++
 .../files/patch-libfuse_lib_cpu.hpp                | 16 ++++++++++++
 .../fusefs-mergerfs/files/patch-libfuse_lib_fuse.c | 14 +++++++++++
 .../files/patch-libfuse_util_fusermount.c          | 15 +++++++++++
 .../files/patch-src_fs__readahead.cpp              | 14 +++++++++++
 .../files/patch-src_fs__umount2.hpp                | 17 +++++++++++++
 .../fusefs-mergerfs/files/patch-tools_preload.c    | 29 ++++++++++++++++++++++
 sysutils/fusefs-mergerfs/pkg-descr                 |  3 +++
 10 files changed, 139 insertions(+)

diff --git a/sysutils/Makefile b/sysutils/Makefile
index 6df31a304e66..5420cdcc9da9 100644
--- a/sysutils/Makefile
+++ b/sysutils/Makefile
@@ -457,6 +457,7 @@
     SUBDIR += fusefs-libs
     SUBDIR += fusefs-libs3
     SUBDIR += fusefs-lkl
+    SUBDIR += fusefs-mergerfs
     SUBDIR += fusefs-mhddfs
     SUBDIR += fusefs-mp3fs
     SUBDIR += fusefs-nbt
diff --git a/sysutils/fusefs-mergerfs/Makefile b/sysutils/fusefs-mergerfs/Makefile
new file mode 100644
index 000000000000..023c4618a341
--- /dev/null
+++ b/sysutils/fusefs-mergerfs/Makefile
@@ -0,0 +1,27 @@
+PORTNAME=	mergerfs
+DISTVERSION=	2.40.2
+CATEGORIES=	sysutils
+PKGNAMEPREFIX=	fusefs-
+
+MAINTAINER=	ehaupt@FreeBSD.org
+COMMENT=	Featureful FUSE based union filesystem
+WWW=		https://github.com/trapexit/mergerfs
+
+LICENSE=	ISCL
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+NOT_FOR_ARCHS=	i386
+
+USES=		fuse gmake localbase:ldflags
+USE_GITHUB=	yes
+GH_ACCOUNT=	trapexit
+
+PLIST_FILES=	bin/mergerfs \
+		lib/mergerfs/preload.so \
+		share/man/man1/mergerfs.1.gz
+
+post-install:
+	${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/mergerfs \
+		${STAGEDIR}${PREFIX}/lib/mergerfs/preload.so
+
+.include <bsd.port.mk>
diff --git a/sysutils/fusefs-mergerfs/distinfo b/sysutils/fusefs-mergerfs/distinfo
new file mode 100644
index 000000000000..37bfb871ee16
--- /dev/null
+++ b/sysutils/fusefs-mergerfs/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1727772197
+SHA256 (trapexit-mergerfs-2.40.2_GH0.tar.gz) = b4f45e635f29b0a8ba1727e6c1f503356d47943a14af8b4586d3e36350f82464
+SIZE (trapexit-mergerfs-2.40.2_GH0.tar.gz) = 743230
diff --git a/sysutils/fusefs-mergerfs/files/patch-libfuse_lib_cpu.hpp b/sysutils/fusefs-mergerfs/files/patch-libfuse_lib_cpu.hpp
new file mode 100644
index 000000000000..953ff7e2e86b
--- /dev/null
+++ b/sysutils/fusefs-mergerfs/files/patch-libfuse_lib_cpu.hpp
@@ -0,0 +1,16 @@
+--- libfuse/lib/cpu.hpp.orig	2024-02-29 20:41:22 UTC
++++ libfuse/lib/cpu.hpp
+@@ -5,8 +5,12 @@
+ #endif
+ 
+ #include <pthread.h>
++#ifdef __FreeBSD__
++#define sched_getaffinity(pid, size, set) 0
++#define pthread_setaffinity_np(thread, size, set) 0
++#else
+ #include <sched.h>
+-
++#endif
+ #include <set>
+ #include <unordered_map>
+ #include <vector>
diff --git a/sysutils/fusefs-mergerfs/files/patch-libfuse_lib_fuse.c b/sysutils/fusefs-mergerfs/files/patch-libfuse_lib_fuse.c
new file mode 100644
index 000000000000..cdbfe55e710c
--- /dev/null
+++ b/sysutils/fusefs-mergerfs/files/patch-libfuse_lib_fuse.c
@@ -0,0 +1,14 @@
+--- libfuse/lib/fuse.c.orig	2024-02-29 20:41:22 UTC
++++ libfuse/lib/fuse.c
+@@ -48,8 +48,10 @@
+ #include <time.h>
+ #include <unistd.h>
+ 
+-#ifdef HAVE_MALLOC_TRIM
++#ifdef __linux__
+ #include <malloc.h>
++#else
++#define malloc_trim(x) ((void)(x))
+ #endif
+ 
+ #define FUSE_UNKNOWN_INO UINT64_MAX
diff --git a/sysutils/fusefs-mergerfs/files/patch-libfuse_util_fusermount.c b/sysutils/fusefs-mergerfs/files/patch-libfuse_util_fusermount.c
new file mode 100644
index 000000000000..7657ee4ce378
--- /dev/null
+++ b/sysutils/fusefs-mergerfs/files/patch-libfuse_util_fusermount.c
@@ -0,0 +1,15 @@
+--- libfuse/util/fusermount.c.orig	2024-02-29 20:41:22 UTC
++++ libfuse/util/fusermount.c
+@@ -28,7 +28,12 @@
+ #include <sys/fsuid.h>
+ #include <sys/socket.h>
+ #include <sys/utsname.h>
++#ifdef __linux__
+ #include <sched.h>
++#else
++#define sched_getaffinity(pid, size, set) 0
++#define pthread_setaffinity_np(thread, size, set) 0
++#endif
+ 
+ #define FUSE_COMMFD_ENV		"_FUSE_COMMFD"
+ 
diff --git a/sysutils/fusefs-mergerfs/files/patch-src_fs__readahead.cpp b/sysutils/fusefs-mergerfs/files/patch-src_fs__readahead.cpp
new file mode 100644
index 000000000000..3bb873358455
--- /dev/null
+++ b/sysutils/fusefs-mergerfs/files/patch-src_fs__readahead.cpp
@@ -0,0 +1,14 @@
+--- src/fs_readahead.cpp.orig	2024-02-29 20:41:22 UTC
++++ src/fs_readahead.cpp
+@@ -25,7 +25,11 @@
+ #include <fstream>
+ #include <string>
+ 
++#ifdef __FreeBSD__
++#include <sys/types.h>
++#else
+ #include <sys/sysmacros.h>
++#endif
+ 
+ namespace l
+ {
diff --git a/sysutils/fusefs-mergerfs/files/patch-src_fs__umount2.hpp b/sysutils/fusefs-mergerfs/files/patch-src_fs__umount2.hpp
new file mode 100644
index 000000000000..ce291a314c01
--- /dev/null
+++ b/sysutils/fusefs-mergerfs/files/patch-src_fs__umount2.hpp
@@ -0,0 +1,17 @@
+--- src/fs_umount2.hpp.orig	2024-02-29 20:41:22 UTC
++++ src/fs_umount2.hpp
+@@ -19,7 +19,14 @@
+ #pragma once
+ 
+ #include <errno.h>
++#ifdef __linux__
+ #include <sys/mount.h>
++#else
++#include <sys/param.h>
++#include <sys/mount.h>
++#define umount2(target, flags) unmount(target, flags)
++#define MNT_DETACH 0
++#endif
+ 
+ #include <string>
+ 
diff --git a/sysutils/fusefs-mergerfs/files/patch-tools_preload.c b/sysutils/fusefs-mergerfs/files/patch-tools_preload.c
new file mode 100644
index 000000000000..a9a3ad06b3c3
--- /dev/null
+++ b/sysutils/fusefs-mergerfs/files/patch-tools_preload.c
@@ -0,0 +1,29 @@
+--- tools/preload.c.orig	2024-02-29 20:41:22 UTC
++++ tools/preload.c
+@@ -25,10 +25,25 @@
+ #include <string.h>
+ #include <sys/ioctl.h>
+ #include <stdarg.h>
+-#include <sys/stat.h>
++#include <sys/stat.h>
++#ifdef __linux__
++#define S_IFMT S_IFMT
++#define S_IFREG S_IFREG
++#else
++#define S_IFMT 0
++#define S_IFREG 0
++#endif
+ #include <sys/types.h>
+ #include <unistd.h>
+ #include <fcntl.h>
++
++#ifdef __linux__
++#define O_TMPFILE O_TMPFILE
++#define O_PATH O_PATH
++#else
++#define O_TMPFILE 0
++#define O_PATH 0
++#endif
+ 
+ typedef char IOCTL_BUF[4096];
+ #define IOCTL_APP_TYPE  0xDF
diff --git a/sysutils/fusefs-mergerfs/pkg-descr b/sysutils/fusefs-mergerfs/pkg-descr
new file mode 100644
index 000000000000..cff399af2600
--- /dev/null
+++ b/sysutils/fusefs-mergerfs/pkg-descr
@@ -0,0 +1,3 @@
+mergerfs is a union filesystem geared towards simplifying storage and
+management of files across numerous commodity storage devices. It is
+similar to mhddfs, unionfs, and aufs.