git: f2c9ba7c53c9 - main - databases/mongodb80: new port 8.0.0-rc14

From: Ronald Klop <ronald_at_FreeBSD.org>
Date: Tue, 23 Jul 2024 15:47:22 UTC
The branch main has been updated by ronald:

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

commit f2c9ba7c53c9a599c36b722305a189fd912db5d2
Author:     Ronald Klop <ronald@FreeBSD.org>
AuthorDate: 2024-07-23 15:44:45 +0000
Commit:     Ronald Klop <ronald@FreeBSD.org>
CommitDate: 2024-07-23 15:44:45 +0000

    databases/mongodb80: new port 8.0.0-rc14
    
    Still release candidate, use with care.
    
    Notes:
    https://www.mongodb.com/docs/v8.0/release-notes/8.0/
---
 databases/Makefile                                 |   1 +
 databases/mongodb80/Makefile                       | 162 +++++++++++++++++++++
 databases/mongodb80/distinfo                       |   5 +
 databases/mongodb80/files/extrapatch-SConstruct    |  16 ++
 databases/mongodb80/files/make.test.sh             |  31 ++++
 databases/mongodb80/files/mongod.in                |  53 +++++++
 databases/mongodb80/files/patch-SConstruct         |  36 +++++
 .../mongodb80/files/patch-buildscripts_scons.py    |  18 +++
 .../patch-src_mongo_platform_waitable__atomic.cpp  |  65 +++++++++
 ...sl_time_internal_cctz_src_time__zone__format.cc |  13 ++
 ...asio-master_asio_include_asio_detail_config.hpp |  10 ++
 ...rty_boost_boost_mpl_aux___integral__wrapper.hpp |  11 ++
 ..._libbson_dist_src_libbson_src_bson_bson-error.c |  11 ++
 .../patch-src_third__party_mozjs_gen-config.sh     |  30 ++++
 .../patch-src_third__party_mozjs_get-sources.sh    |  14 ++
 databases/mongodb80/pkg-descr                      |   5 +
 databases/mongodb80/pkg-message                    |  16 ++
 databases/mongodb80/pkg-plist                      |   7 +
 18 files changed, 504 insertions(+)

diff --git a/databases/Makefile b/databases/Makefile
index f45f98b58c94..9edcb89fcdce 100644
--- a/databases/Makefile
+++ b/databases/Makefile
@@ -193,6 +193,7 @@
     SUBDIR += mongodb50
     SUBDIR += mongodb60
     SUBDIR += mongodb70
+    SUBDIR += mongodb80
     SUBDIR += movine
     SUBDIR += mroonga
     SUBDIR += mtop
diff --git a/databases/mongodb80/Makefile b/databases/mongodb80/Makefile
new file mode 100644
index 000000000000..79ba19ee6abb
--- /dev/null
+++ b/databases/mongodb80/Makefile
@@ -0,0 +1,162 @@
+PORTNAME=	mongodb
+DISTVERSIONPREFIX=	r
+DISTVERSION=	8.0.0-rc14
+CATEGORIES=	databases net
+PKGNAMESUFFIX=	${DISTVERSION:R:S/.//}
+
+MAINTAINER=	ronald@FreeBSD.org
+COMMENT=	MongoDB Community Edition (8.0.x Branch)
+WWW=		https://www.mongodb.com/docs/v8.0/
+
+LICENSE=	APACHE20 SSPLv1 # mongodb is SSPLv1, C++ driver is APACHE20
+LICENSE_COMB=	multi
+LICENSE_NAME_SSPLv1=	Server Side Public License Version 1
+LICENSE_FILE_SSPLv1=	${WRKSRC}/LICENSE-Community.txt
+LICENSE_PERMS_SSPLv1=	dist-mirror dist-sell pkg-mirror pkg-sell auto-accept
+
+ONLY_FOR_ARCHS=	aarch64 amd64 powerpc64le
+ONLY_FOR_ARCHS_REASON=	only ported to amd64, aarch64, and powerpc64le on FreeBSD; upstream supports arm64, ppc64le, s390x, and x86-64
+
+BUILD_DEPENDS=	${PY_SETUPTOOLS} \
+		${PYTHON_PKGNAMEPREFIX}cheetah3>0:devel/py-cheetah3@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}gitpython>0:devel/py-gitpython@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}packaging>0:devel/py-packaging@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}psutil>0:sysutils/py-psutil@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pymongo>0:databases/py-pymongo@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pyyaml>=3.11:devel/py-pyyaml@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}retry2>0:devel/py-retry2@${PY_FLAVOR}
+# build depends used while running ${WRKSRC}/src/third_party/mozjs/gen-config.sh
+BUILD_DEPENDS+=	gm4:devel/m4 \
+		gsed:textproc/gsed
+LIB_DEPENDS=	libcurl.so:ftp/curl \
+		libpcre2-8.so:devel/pcre2 \
+		libsnappy.so:archivers/snappy \
+		libstemmer.so:textproc/snowballstemmer \
+		libunwind.so:devel/libunwind \
+		libyaml-cpp.so:devel/yaml-cpp \
+		libzstd.so:archivers/zstd
+
+USES=		compiler:c++20-lang cpe python:build scons shebangfix
+# gmake is used while running ${WRKSRC}/src/third_party/mozjs/gen-config.sh
+USES+=		gmake pkgconfig
+
+# mozjs tag comes from ${WRKSRC}/src/third_party/mozjs/get-sources.sh
+MOZJS_TAG=	bb6edb4fcd43607c87de81df8c58db11a663634a
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	mongodb mongodb-forks:mozjs
+GH_PROJECT=	mongo spidermonkey:mozjs
+GH_TAGNAME=	${MOZJS_TAG}:mozjs
+USE_RC_SUBR=	mongod
+
+SHEBANG_FILES=	buildscripts/scons.py
+python_OLD_CMD=	@python_interpreter@
+
+CONFIGURE_ENV+=	M4=${LOCALBASE}/bin/gm4
+MAKE_ARGS=	--allocator=system \
+		--cxx-std=20 \
+		--disable-warnings-as-errors \
+		--libc++ \
+		--runtime-hardening=on \
+		--use-system-libunwind \
+		--use-system-pcre2 \
+		--use-system-snappy \
+		--use-system-stemmer \
+		--use-system-yaml \
+		--use-system-zlib \
+		--use-system-zstd \
+		-j${MAKE_JOBS_NUMBER} \
+		AR=llvm-ar \
+		MONGO_VERSION=${DISTVERSION} \
+		VERBOSE=on
+
+CFLAGS+=	-DBOOST_NO_CXX98_FUNCTION_BASE
+
+CONFLICTS_INSTALL=	mongodb[0-9][0-9]
+
+EXTRACT_AFTER_ARGS=	--exclude src/third_party/pcre2 \
+			--exclude src/third_party/snappy-* \
+			--exclude src/third_party/libstemmer_c \
+			--exclude src/third_party/unwind \
+			--exclude src/third_party/yaml-cpp \
+			--exclude src/third_party/zlib-* \
+			--exclude src/third_party/zstandard \
+			--no-same-owner --no-same-permissions
+
+USERS=		mongodb
+GROUPS=		mongodb
+
+OPTIONS_DEFINE=		LTO NOAVX SASL SSL
+OPTIONS_DEFINE_aarch64=	ARMV80A
+OPTIONS_DEFAULT=	NOAVX SASL SSL
+
+# MongoDB on non-LSE ARM cpu like Raspberry Pi can work but is unsupported upstream.
+# Can give corruption on high concurrency.
+# Please read https://jira.mongodb.org/browse/SERVER-71772.
+ARMV80A_DESC=	Enable non-LSE ARM64 CPUs like RPI4.
+NOAVX_DESC=	"Disable AVX instructions on amd64 (Sandybridge+)"
+
+ARMV80A_EXTRA_PATCHES=	${FILESDIR}/extrapatch-SConstruct
+
+LTO_MAKE_ARGS=	--lto=on
+
+NOAVX_MAKE_ARGS=	--experimental-optimization="-sandybridge"
+
+SASL_LIB_DEPENDS=	libsasl2.so:security/cyrus-sasl2
+SASL_MAKE_ARGS=		--use-sasl-client
+
+SSL_USES=	ssl
+SSL_MAKE_ARGS=	--ssl
+
+.include <bsd.port.pre.mk>
+
+ALL_TARGET=	install-servers
+
+# This ports is only following the Major Release.
+# https://docs.mongodb.com/manual/reference/versioning/
+PORTSCOUT=	limit:^7\.0\.
+
+CPE_PRODUCT=	mongodb
+
+.if ${ARCH} == amd64
+MOZJS_ARCH=	x86_64
+.elif ${ARCH} == powerpc64le
+MOZJS_ARCH=	ppc64le
+.elif ${ARCH} == aarch64
+MOZJS_ARCH=	${ARCH}
+.endif
+
+post-patch:
+# fix build with python-3.11
+	${REINPLACE_CMD} -e 's#rU#r#g' ${WRKDIR}/spidermonkey-${MOZJS_TAG}/python/mozbuild/mozbuild/util.py
+	${REINPLACE_CMD} -e 's#rU#r#g' ${WRKDIR}/spidermonkey-${MOZJS_TAG}/python/mozbuild/mozbuild/preprocessor.py
+	${REINPLACE_CMD} -e 's#rU#r#g' ${WRKDIR}/spidermonkey-${MOZJS_TAG}/python/mozbuild/mozbuild/backend/base.py
+	${REINPLACE_CMD} -e 's#rU#r#g' ${WRKDIR}/spidermonkey-${MOZJS_TAG}/python/mozbuild/mozbuild/action/process_define_files.py
+
+pre-configure:
+	# Verify we downloaded the proper mozjs git tag.
+	sh -c "test \"X`grep -E '^LIB_GIT_REVISION=' ${WRKSRC}/src/third_party/mozjs/get-sources.sh`\" = \"XLIB_GIT_REVISION=${MOZJS_TAG}\""
+
+do-configure:
+# Replacement of ${WRKSRC}/src/third_party/mozjs/get-sources.sh
+	${LN} -sF ${WRKDIR}/spidermonkey-${MOZJS_TAG} ${WRKSRC}/src/third_party/mozjs/mozilla-release
+	cd ${WRKSRC}/src/third_party/mozjs && PYTHON3="${PYTHON_CMD}" ${SH} ./gen-config.sh ${MOZJS_ARCH} freebsd
+
+do-build:
+	${WRKSRC}/buildscripts/scons.py	-C ${WRKSRC} ${MAKE_ARGS}
+
+do-install:
+.for f in mongod mongos
+	${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/${f}
+.endfor
+	${INSTALL_DATA} ${WRKSRC}/rpm/mongod.conf ${STAGEDIR}${PREFIX}/etc/mongodb.conf.sample
+	${MKDIR} ${STAGEDIR}${DOCSDIR}
+.for doc in LICENSE-Community.txt MPL-2 README THIRD-PARTY-NOTICES
+	${MV} ${STAGEDIR}${PREFIX}/${doc} ${STAGEDIR}${DOCSDIR}/
+.endfor
+	${RM} ${STAGEDIR}${PREFIX}/bin/resmoke.py
+
+do-test:
+	${SH} ${FILESDIR}/make.test.sh "${STAGEDIR}${PREFIX}/bin"
+
+.include <bsd.port.post.mk>
diff --git a/databases/mongodb80/distinfo b/databases/mongodb80/distinfo
new file mode 100644
index 000000000000..f007641034d7
--- /dev/null
+++ b/databases/mongodb80/distinfo
@@ -0,0 +1,5 @@
+TIMESTAMP = 1721728990
+SHA256 (mongodb-mongo-r8.0.0-rc14_GH0.tar.gz) = 73560b1f0d84367029368081c5a29b7469c31cece893fbf7e480bb40f1118301
+SIZE (mongodb-mongo-r8.0.0-rc14_GH0.tar.gz) = 94721112
+SHA256 (mongodb-forks-spidermonkey-bb6edb4fcd43607c87de81df8c58db11a663634a_GH0.tar.gz) = 8b237164cb3f492aa1658080b91bafb3c98fe72da11ffb65513e4bffe01553f9
+SIZE (mongodb-forks-spidermonkey-bb6edb4fcd43607c87de81df8c58db11a663634a_GH0.tar.gz) = 164675678
diff --git a/databases/mongodb80/files/extrapatch-SConstruct b/databases/mongodb80/files/extrapatch-SConstruct
new file mode 100644
index 000000000000..05946bd82cdc
--- /dev/null
+++ b/databases/mongodb80/files/extrapatch-SConstruct
@@ -0,0 +1,16 @@
+--- SConstruct.orig	2023-06-07 17:07:38 UTC
++++ SConstruct
+@@ -3217,8 +3205,12 @@ if not env.TargetOSIs('windows', 'macOS') and (env.Too
+     # setting it for both C and C++ by setting both of CFLAGS and
+     # CXXFLAGS.
+ 
++    arm_march_flag = "armv8-a"
++    if get_option('use-hardware-crc32') == "on":
++        arm_march_flag += "+crc"
++
+     default_targeting_flags_for_architecture = {
+-        "aarch64": {"-march=": "armv8.2-a", "-mtune=": "generic"},
++        "aarch64": {"-march=": arm_march_flag, "-mtune=": "generic"},
+         "i386": {"-march=": "nocona", "-mtune=": "generic"},
+         "ppc64le": {"-mcpu=": "power8", "-mtune=": "power8", "-mcmodel=": "medium"},
+         "s390x": {"-march=": "z196", "-mtune=": "zEC12"},
diff --git a/databases/mongodb80/files/make.test.sh b/databases/mongodb80/files/make.test.sh
new file mode 100755
index 000000000000..c42bb1973e6b
--- /dev/null
+++ b/databases/mongodb80/files/make.test.sh
@@ -0,0 +1,31 @@
+#! /bin/sh
+
+set -e
+
+usage() {
+	echo "Usage: $0 <path>"
+	echo "<path>    path to the executables"
+}
+
+test "$#" -eq 1 || ( usage && exit 1 )
+
+set -x
+
+PATH="$1:$PATH"
+
+DBDIR=$( mktemp -d -t tmp.mongodb )
+
+trap 'rm -rf "$DBDIR"' EXIT
+
+# Trivial check if the binaries execute at all.
+mongod --version
+mongos --version
+
+# Check if an empty database can be created.
+mkdir "$DBDIR/db"
+tail -F "$DBDIR/log" | ( grep -qFe "Waiting for connections" && kill $(cat "$DBDIR/pid") ) &
+script -eF "$DBDIR/log" \
+	timeout -s TERM -k 30s 60s \
+	mongod --dbpath "$DBDIR/db" --pidfilepath "$DBDIR/pid"
+
+echo "Test successful"
diff --git a/databases/mongodb80/files/mongod.in b/databases/mongodb80/files/mongod.in
new file mode 100644
index 000000000000..20b0f5c0f43d
--- /dev/null
+++ b/databases/mongodb80/files/mongod.in
@@ -0,0 +1,53 @@
+#!/bin/sh
+
+# PROVIDE: mongod
+# REQUIRE: NETWORK ldconfig
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# mongod_enable (bool):  Set to "NO" by default.
+#                        Set it to "YES" to enable mongod.
+# mongod_dbpath (str):   Default to "/var/db/mongodb"
+#                        Base database directory.
+# mongod_flags (str):    Custom additional arguments to be passed to mongod.
+#                        Default to "--logpath ${mongod_dbpath}/mongod.log --logappend".
+# mongod_config (str):	 Default to "%%PREFIX%%/etc/mongodb.conf"
+#                        Path to config file
+#
+
+. /etc/rc.subr
+
+name="mongod"
+rcvar=mongod_enable
+
+load_rc_config $name
+
+: ${mongod_enable="NO"}
+: ${mongod_dbpath="/var/db/mongodb"}
+: ${mongod_flags="--logpath ${mongod_dbpath}/mongod.log --logappend --setParameter=disabledSecureAllocatorDomains=\*"}
+: ${mongod_user="mongodb"}
+: ${mongod_group="mongodb"}
+: ${mongod_config="%%PREFIX%%/etc/mongodb.conf"}
+
+pidfile="${mongod_dbpath}/mongod.lock"
+command=%%PREFIX%%/bin/${name}
+command_args="--config $mongod_config --dbpath $mongod_dbpath --fork >/dev/null 2>/dev/null"
+start_precmd="${name}_prestart"
+
+mongod_create_dbpath()
+{
+        mkdir ${mongod_dbpath} >/dev/null 2>/dev/null
+        [ $? -eq 0 ] && chown -R ${mongod_user}:${mongod_group} ${mongod_dbpath}
+}
+
+mongod_prestart()
+{
+        if [ ! -d ${mongod_dbpath} ]; then
+                mongod_create_dbpath || return 1
+        fi
+        return 0
+}
+
+run_rc_command "$1"
diff --git a/databases/mongodb80/files/patch-SConstruct b/databases/mongodb80/files/patch-SConstruct
new file mode 100644
index 000000000000..375b9238a97a
--- /dev/null
+++ b/databases/mongodb80/files/patch-SConstruct
@@ -0,0 +1,36 @@
+--- SConstruct.orig	2024-07-22 19:17:33 UTC
++++ SConstruct
+@@ -25,7 +25,6 @@ import SCons.Script
+ 
+ import SCons
+ import SCons.Script
+-from mongo_tooling_metrics.lib.top_level_metrics import SConsToolingMetrics
+ from site_scons.mongo import build_profiles
+ 
+ # This must be first, even before EnsureSConsVersion, if
+@@ -1722,16 +1721,6 @@ env.AddMethod(lambda env, name, **kwargs: add_option(n
+ del envDict
+ env.AddMethod(lambda env, name, **kwargs: add_option(name, **kwargs), 'AddOption')
+ 
+-# The placement of this is intentional. Here we setup an atexit method to store tooling metrics.
+-# We should only register this function after env, env_vars and the parser have been properly initialized.
+-SConsToolingMetrics.register_metrics(
+-    utc_starttime=datetime.utcnow(),
+-    artifact_dir=env.Dir('$BUILD_DIR').get_abspath(),
+-    env_vars=env_vars,
+-    env=env,
+-    parser=_parser,
+-)
+-
+ if get_option('build-metrics'):
+     env['BUILD_METRICS_ARTIFACTS_DIR'] = '$BUILD_ROOT/$VARIANT_DIR'
+     env.Tool('build_metrics')
+@@ -1835,7 +1824,7 @@ if unknown_vars:
+ 
+ unknown_vars = env_vars.UnknownVariables()
+ if unknown_vars:
+-    env.FatalError("Unknown variables specified: {0}", ", ".join(list(unknown_vars.keys())))
++    print("Unknown variables specified: {0}", ", ".join(list(unknown_vars.keys())))
+ 
+ install_actions.setup(env, get_option('install-action'))
+ 
diff --git a/databases/mongodb80/files/patch-buildscripts_scons.py b/databases/mongodb80/files/patch-buildscripts_scons.py
new file mode 100644
index 000000000000..5759ae7f71d9
--- /dev/null
+++ b/databases/mongodb80/files/patch-buildscripts_scons.py
@@ -0,0 +1,18 @@
+--- buildscripts/scons.py.orig	2024-07-23 11:11:41 UTC
++++ buildscripts/scons.py
+@@ -18,15 +18,6 @@ sys.path = [SCONS_DIR, SITE_TOOLS_DIR] + sys.path
+ 
+ sys.path = [SCONS_DIR, SITE_TOOLS_DIR] + sys.path
+ 
+-# pylint: disable=C0413
+-from mongo.pip_requirements import verify_requirements, MissingRequirements
+-
+-try:
+-    verify_requirements()
+-except MissingRequirements as ex:
+-    print(ex)
+-    sys.exit(1)
+-
+ try:
+     import SCons.Script
+ except ImportError as import_err:
diff --git a/databases/mongodb80/files/patch-src_mongo_platform_waitable__atomic.cpp b/databases/mongodb80/files/patch-src_mongo_platform_waitable__atomic.cpp
new file mode 100644
index 000000000000..92a361721080
--- /dev/null
+++ b/databases/mongodb80/files/patch-src_mongo_platform_waitable__atomic.cpp
@@ -0,0 +1,65 @@
+--- src/mongo/platform/waitable_atomic.cpp.orig	2024-07-23 11:53:14 UTC
++++ src/mongo/platform/waitable_atomic.cpp
+@@ -34,6 +34,9 @@
+ #ifdef __linux__
+ #include <linux/futex.h>
+ #include <sys/syscall.h>
++#elif defined(__FreeBSD__)
++#include <sys/types.h>
++#include <sys/umtx.h>
+ #elif defined(_WIN32)
+ #include <synchapi.h>
+ #endif
+@@ -228,6 +231,52 @@ bool waitUntil(const void* uaddr,
+     }
+ 
+     if (__ulock_wait(UL_COMPARE_AND_WAIT, const_cast<void*>(uaddr), old, timeoutMicros) != -1)
++        return true;
++
++    // There isn't a good list of possible errors, so assuming that anything other than a timeout
++    // error is a possible spurious wakeup.
++    return timeoutOverflow || errno != ETIMEDOUT;
++}
++
++#elif defined(__FreeBSD__)
++
++void notifyOne(const void* uaddr) {
++    _umtx_op(const_cast<void*>(uaddr), UMTX_OP_WAKE, 1, NULL, NULL);
++}
++
++void notifyMany(const void* uaddr, int nToWake) {
++    _umtx_op(const_cast<void*>(uaddr), UMTX_OP_WAKE, nToWake, NULL, NULL);
++}
++
++void notifyAll(const void* uaddr) {
++    _umtx_op(const_cast<void*>(uaddr), UMTX_OP_WAKE, INT_MAX, NULL, NULL);
++}
++
++bool waitUntil(const void* uaddr,
++               uint32_t old,
++               boost::optional<system_clock::time_point> deadline) {
++    struct timespec timeout;
++    bool timeoutOverflow = false;
++    if (deadline) {
++        int64_t micros = durationCount<Microseconds>(*deadline - system_clock::now());
++        if (micros <= 0) {
++            return false;  // Synthesize a timeout.
++        }
++
++        if (micros > int64_t(std::numeric_limits<uint32_t>::max())) {
++            // 2**32 micros is a little over an hour. If this happens, we wait as long as we can,
++            // then return as-if a spurious wakeup happened, rather than a timeout. This will cause
++            // the caller to loop and we will compute a smaller time each pass, eventually reaching
++            // a representable timeout.
++            micros = std::numeric_limits<uint32_t>::max();
++            timeoutOverflow = true;
++        }
++
++	timeout.tv_sec = micros / 1000;
++	timeout.tv_nsec = (micros % 1000) * 1000;
++    }
++
++    if (_umtx_op(const_cast<void*>(uaddr), UMTX_OP_WAIT, old, (void*)sizeof(struct timespec), &timeout) != -1)
+         return true;
+ 
+     // There isn't a good list of possible errors, so assuming that anything other than a timeout
diff --git a/databases/mongodb80/files/patch-src_third__party_abseil-cpp_dist_absl_time_internal_cctz_src_time__zone__format.cc b/databases/mongodb80/files/patch-src_third__party_abseil-cpp_dist_absl_time_internal_cctz_src_time__zone__format.cc
new file mode 100644
index 000000000000..d498ecfd3fbd
--- /dev/null
+++ b/databases/mongodb80/files/patch-src_third__party_abseil-cpp_dist_absl_time_internal_cctz_src_time__zone__format.cc
@@ -0,0 +1,13 @@
+# https://github.com/abseil/abseil-cpp/commit/ded2ec077d911de647d47ab48ef3a8e24a1fb64a
+# https://github.com/abseil/abseil-cpp/issues/1587
+--- src/third_party/abseil-cpp/dist/absl/time/internal/cctz/src/time_zone_format.cc.orig	2024-07-23 13:17:01 UTC
++++ src/third_party/abseil-cpp/dist/absl/time/internal/cctz/src/time_zone_format.cc
+@@ -19,7 +19,7 @@
+ #endif
+ 
+ #if defined(HAS_STRPTIME) && HAS_STRPTIME
+-#if !defined(_XOPEN_SOURCE) && !defined(__OpenBSD__)
++#if !defined(_XOPEN_SOURCE) && !defined(__FreeBSD__) && !defined(__OpenBSD__)
+ #define _XOPEN_SOURCE 500  // Exposes definitions for SUSv2 (UNIX 98).
+ #endif
+ #endif
diff --git a/databases/mongodb80/files/patch-src_third__party_asio-master_asio_include_asio_detail_config.hpp b/databases/mongodb80/files/patch-src_third__party_asio-master_asio_include_asio_detail_config.hpp
new file mode 100644
index 000000000000..09713cbc0028
--- /dev/null
+++ b/databases/mongodb80/files/patch-src_third__party_asio-master_asio_include_asio_detail_config.hpp
@@ -0,0 +1,10 @@
+--- src/third_party/asio-master/asio/include/asio/detail/config.hpp.orig	2023-04-29 10:17:24 UTC
++++ src/third_party/asio-master/asio/include/asio/detail/config.hpp
+@@ -19,6 +19,7 @@
+ // individual scons objects.
+ # define ASIO_STANDALONE // MongoDB
+ # define ASIO_SEPARATE_COMPILATION // MongoDB
++# define ASIO_HAS_STD_INVOKE_RESULT // FreeBSD
+ 
+ #if defined(ASIO_STANDALONE)
+ # define ASIO_DISABLE_BOOST_ARRAY 1
diff --git a/databases/mongodb80/files/patch-src_third__party_boost_boost_mpl_aux___integral__wrapper.hpp b/databases/mongodb80/files/patch-src_third__party_boost_boost_mpl_aux___integral__wrapper.hpp
new file mode 100644
index 000000000000..f6e1178b4a65
--- /dev/null
+++ b/databases/mongodb80/files/patch-src_third__party_boost_boost_mpl_aux___integral__wrapper.hpp
@@ -0,0 +1,11 @@
+--- src/third_party/boost/boost/mpl/aux_/integral_wrapper.hpp.orig	2023-06-15 22:07:57 UTC
++++ src/third_party/boost/boost/mpl/aux_/integral_wrapper.hpp
+@@ -56,7 +56,7 @@ struct AUX_WRAPPER_NAME
+ // have to #ifdef here: some compilers don't like the 'N + 1' form (MSVC),
+ // while some other don't like 'value + 1' (Borland), and some don't like
+ // either
+-#if BOOST_WORKAROUND(__EDG_VERSION__, <= 243)
++#if 1 //BOOST_WORKAROUND(__EDG_VERSION__, <= 243)
+  private:
+     BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, next_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N + 1)));
+     BOOST_STATIC_CONSTANT(AUX_WRAPPER_VALUE_TYPE, prior_value = BOOST_MPL_AUX_STATIC_CAST(AUX_WRAPPER_VALUE_TYPE, (N - 1)));
diff --git a/databases/mongodb80/files/patch-src_third__party_libbson_dist_src_libbson_src_bson_bson-error.c b/databases/mongodb80/files/patch-src_third__party_libbson_dist_src_libbson_src_bson_bson-error.c
new file mode 100644
index 000000000000..4ee39110eefd
--- /dev/null
+++ b/databases/mongodb80/files/patch-src_third__party_libbson_dist_src_libbson_src_bson_bson-error.c
@@ -0,0 +1,11 @@
+--- src/third_party/libbson/dist/src/libbson/src/bson/bson-error.c.orig	2024-07-04 10:59:36 UTC
++++ src/third_party/libbson/dist/src/libbson/src/bson/bson-error.c
+@@ -130,7 +130,7 @@ bson_strerror_r (int err_code,                    /* I
+    // required) by the POSIX spec (see:
+    // https://pubs.opengroup.org/onlinepubs/9699919799/functions/strerror.html#tag_16_574_08).
+    (void) strerror_r (err_code, buf, buflen);
+-#elif defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700
++#elif defined(__FreeBSD__) || ( defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 700 )
+    // The behavior (of `strerror_l`) is undefined if the locale argument to
+    // `strerror_l()` is the special locale object LC_GLOBAL_LOCALE or is not a
+    // valid locale object handle.
diff --git a/databases/mongodb80/files/patch-src_third__party_mozjs_gen-config.sh b/databases/mongodb80/files/patch-src_third__party_mozjs_gen-config.sh
new file mode 100644
index 000000000000..e05c48c9f8f7
--- /dev/null
+++ b/databases/mongodb80/files/patch-src_third__party_mozjs_gen-config.sh
@@ -0,0 +1,30 @@
+--- src/third_party/mozjs/gen-config.sh.orig	2024-07-22 19:17:33 UTC
++++ src/third_party/mozjs/gen-config.sh
+@@ -29,6 +29,9 @@ case "$_Path" in
+ }
+ 
+ case "$_Path" in
++    "platform/aarch64/freebsd")
++        _CONFIG_OPTS="--host=aarch64-freebsd"
++	;;
+     "platform/aarch64/linux")
+         _CONFIG_OPTS="--host=aarch64-linux"
+     ;;
+@@ -109,7 +112,7 @@ CFLAGS="$CFLAGS -D__STDC_FORMAT_MACROS" \
+     --disable-js-shell \
+     --disable-tests "$_CONFIG_OPTS"
+ 
+-make recurse_export
++gmake recurse_export
+ 
+ cd ../../../..
+ 
+@@ -164,7 +167,7 @@ find "$_Path/build" -name '*.cpp' |
+ find "$_Path/build" -name '*.cpp' |
+     while read unified_file ; do
+         echo "Processing $unified_file"
+-        sed $SEDOPTION \
++        gsed $SEDOPTION \
+             -e 's|#include ".*/js/src/|#include "|' \
+             -e 's|#error ".*/js/src/|#error "|' \
+             "$unified_file"
diff --git a/databases/mongodb80/files/patch-src_third__party_mozjs_get-sources.sh b/databases/mongodb80/files/patch-src_third__party_mozjs_get-sources.sh
new file mode 100644
index 000000000000..278f09c46e52
--- /dev/null
+++ b/databases/mongodb80/files/patch-src_third__party_mozjs_get-sources.sh
@@ -0,0 +1,14 @@
+--- src/third_party/mozjs/get-sources.sh.orig	2024-07-22 19:17:33 UTC
++++ src/third_party/mozjs/get-sources.sh
+@@ -12,9 +12,9 @@ LIB_GIT_REPO=git@github.com:mongodb-forks/spidermonkey
+ LIB_GIT_REVISION=bb6edb4fcd43607c87de81df8c58db11a663634a
+ LIB_GIT_REPO=git@github.com:mongodb-forks/spidermonkey.git
+ 
+-DEST_DIR=$(git rev-parse --show-toplevel)/src/third_party/mozjs
++DEST_DIR=$(realpath .)
+ 
+-LIB_GIT_DIR=$(mktemp -d /tmp/import-spidermonkey.XXXXXX)
++LIB_GIT_DIR=$(mktemp -d /var/tmp/import-spidermonkey.XXXXXX)
+ trap "rm -rf $LIB_GIT_DIR" EXIT
+ 
+ git clone $LIB_GIT_REPO $LIB_GIT_DIR
diff --git a/databases/mongodb80/pkg-descr b/databases/mongodb80/pkg-descr
new file mode 100644
index 000000000000..5bf5a965fd47
--- /dev/null
+++ b/databases/mongodb80/pkg-descr
@@ -0,0 +1,5 @@
+Distributed document-oriented "NoSQL" database.
+
+Mongo (from "humongous") is a high-performance, open source,
+schema-free, document-oriented database. A common name in the
+"NOSQL" community.
diff --git a/databases/mongodb80/pkg-message b/databases/mongodb80/pkg-message
new file mode 100644
index 000000000000..fb041b1ff931
--- /dev/null
+++ b/databases/mongodb80/pkg-message
@@ -0,0 +1,16 @@
+[
+{ type: install
+  message: <<EOM
+MongoDB on Raspberry Pi can work but is unsupported upstream.
+Please read https://jira.mongodb.org/browse/SERVER-71772 and enable option 
+ARMV80A if you run this on a non-LSE ARM cpu like Raspberry Pi 4.
+
+MongoDB 6.0 and up do not include the 'mongo' CLI shell anymore. You can
+use the MongoDB Shell (https://github.com/mongodb-js/mongosh).
+# pkg install npm
+$ npm install mongosh
+$ npx mongosh mongodb://127.0.0.1:27017/
+
+EOM
+}
+]
diff --git a/databases/mongodb80/pkg-plist b/databases/mongodb80/pkg-plist
new file mode 100644
index 000000000000..feaf3313657d
--- /dev/null
+++ b/databases/mongodb80/pkg-plist
@@ -0,0 +1,7 @@
+bin/mongod
+bin/mongos
+@sample etc/mongodb.conf.sample
+%%DOCSDIR%%/LICENSE-Community.txt
+%%DOCSDIR%%/MPL-2
+%%DOCSDIR%%/README
+%%DOCSDIR%%/THIRD-PARTY-NOTICES