git: 31d8a7eb3429 - main - databases/mongosh: new port

From: Ronald Klop <ronald_at_FreeBSD.org>
Date: Thu, 21 Nov 2024 08:53:36 UTC
The branch main has been updated by ronald:

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

commit 31d8a7eb3429202e96349c29c0bb240395989ec8
Author:     Fabien Amelinck <fabien.amelinck@advens.fr>
AuthorDate: 2024-11-21 07:52:25 +0000
Commit:     Ronald Klop <ronald@FreeBSD.org>
CommitDate: 2024-11-21 08:52:59 +0000

    databases/mongosh: new port
    
    Standalone MongoDB Shell replacing deprecated Mongo CLI.
    NodeJS doesn't need to be installed.
    
    PR:     279519
---
 databases/Makefile                                 |   1 +
 databases/mongosh/Makefile                         | 146 +++++++++++++++++++++
 databases/mongosh/distinfo                         |  11 ++
 .../patch-node__modules_kerberos_binding.gyp       |  32 +++++
 ...h-node__modules_kerberos_src_kerberos__common.h |  11 ++
 ...__modules_mongodb-client-encryption_binding.gyp |  35 +++++
 ..._modules_mongodb-client-encryption_package.json |  11 ++
 .../patch-node__modules_os-dns-native_binding.gyp  |  13 ++
 databases/mongosh/files/node-patches/004-openssl3  |  15 +++
 .../files/node-patches/005-src_cares__wrap.h       |  11 ++
 databases/mongosh/files/patch-package.json         |  36 +++++
 ...ts_nodejs-patches_002-workaround-node-bug-52229 |  17 +++
 .../mongosh/files/patch-scripts_prep-fle-addon.sh  |  20 +++
 .../mongosh/files/patch-scripts_sort-workspaces.js |  11 ++
 databases/mongosh/pkg-descr                        |   5 +
 databases/mongosh/pkg-plist                        |   1 +
 16 files changed, 376 insertions(+)

diff --git a/databases/Makefile b/databases/Makefile
index e6a3650e68df..dd01bdb43647 100644
--- a/databases/Makefile
+++ b/databases/Makefile
@@ -188,6 +188,7 @@
     SUBDIR += mongodb60
     SUBDIR += mongodb70
     SUBDIR += mongodb80
+    SUBDIR += mongosh
     SUBDIR += movine
     SUBDIR += mroonga
     SUBDIR += mtop
diff --git a/databases/mongosh/Makefile b/databases/mongosh/Makefile
new file mode 100644
index 000000000000..f181f49c9b31
--- /dev/null
+++ b/databases/mongosh/Makefile
@@ -0,0 +1,146 @@
+PORTNAME=	mongosh
+DISTVERSIONPREFIX=	v
+DISTVERSION=	2.2.5
+CATEGORIES=	databases shells net
+MASTER_SITES=	https://registry.npmjs.org/mongodb-client-encryption/-/:mongocrypt \
+		https://registry.npmjs.org/kerberos/-/:kerberos \
+		https://registry.npmjs.org/os-dns-native/-/:dns \
+		https://github.com/${GH_ACCOUNT}/${PORTNAME}/releases/download/${DISTVERSIONFULL}/:modules
+		# https://nodejs.org/dist/latest-v${NODEJS_VERSION}.x/:node
+DISTFILES=	mongodb-client-encryption-${MONGO_CRYPT_VER}.tgz:mongocrypt \
+		kerberos-${KERBEROS_VER}.tgz:kerberos \
+		os-dns-native-${OSDNSNATIVE_VER}.tgz:dns \
+		${NODE_MODULES_TARBALL}:modules \
+		# ${NODEJS_TARBALL}:node \
+		# SHASUMS256.txt:node
+DIST_SUBDIR=	${PORTNAME}
+EXTRACT_ONLY=	${DISTFILE_DEFAULT}
+
+MAINTAINER=	fabien.amelinck+freebsd@advens.fr
+COMMENT=	MongoDB Shell CLI REPL
+WWW=		https://github.com/mongodb-js/mongosh/
+
+LICENSE=	APACHE20
+
+FETCH_DEPENDS=	npm${NODEJS_SUFFIX}>0:www/npm${NODEJS_SUFFIX}
+BUILD_DEPENDS=	bash>0:shells/bash \
+		brotli>=1.0.9,1:archivers/brotli \
+		c-ares>=1.17.2:dns/c-ares \
+		libnghttp2>=1.45.1:www/libnghttp2 \
+		libuv>=1.42.0:devel/libuv \
+		objdump:devel/binutils \
+		git>0:devel/git \
+		${PREFIX}/include/gssapi/gssapi_generic.h:security/krb5
+RUN_DEPENDS=	ca_root_nss>=0:security/ca_root_nss
+LIB_DEPENDS=	libmongocrypt.so:databases/libmongocrypt \
+		libbrotlidec.so:archivers/brotli \
+		libcares.so:dns/c-ares \
+		libnghttp2.so:www/libnghttp2 \
+		libuv.so:devel/libuv
+
+USES=		compiler:c++11-lib gmake localbase pkgconfig nodejs:20,build python:build ssl
+
+USE_GITHUB=	yes
+GH_ACCOUNT=	VultureProject
+GH_PROJECT=	mongosh
+
+MPROTECT_DISABLE=	bin/mongosh
+
+CXXFLAGS+=	-DNODE_API_EXPERIMENTAL \
+		-DNODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT
+
+CUSTOM_ENV=	SEGMENT_API_KEY=dummy BUILD_TYPE=dynamic
+CONFIGURE_ENV=	${CUSTOM_ENV}
+MAKE_ENV=	${CUSTOM_ENV} \
+		NODE_JS_VERSION=file://${_DISTDIR}/${NODEJS_TARBALL} \
+		BOXEDNODE_CONFIGURE_ARGS="--shared-brotli,--shared-cares,--shared-libuv,--shared-nghttp2,--shared-zlib,--shared-openssl,--openssl-use-def-ca-store,--without-npm"
+REINPLACE_ARGS=	-i ''
+
+MONGO_CRYPT_VER=6.0.0
+KERBEROS_VER=	2.1.0
+OSDNSNATIVE_VER=1.2.0
+NODE_MODULES_DIR=	${WRKSRC}/node_modules
+NODE_MODULES_TARBALL=	${PORTNAME}-${DISTVERSIONFULL}-node-modules.tar.xz
+NPM_CACHE_DIR=	/tmp/.npm
+NODEJS_TARBALL=	node-v${NODEJS_PORTVERSION}.tar.gz
+
+post-fetch:
+.if !exists(/tmp/checkpoint)
+	${FETCH_CMD} -o ${_DISTDIR} https://nodejs.org/dist/v${NODEJS_PORTVERSION}/${NODEJS_TARBALL}
+	${FETCH_CMD} -o ${_DISTDIR} https://nodejs.org/dist/v${NODEJS_PORTVERSION}/SHASUMS256.txt
+	${TOUCH} /tmp/checkpoint
+.endif
+
+post-extract:
+.if !exists(${NODE_MODULES_DIR})
+	${TAR} -xzf /${_DISTDIR}/${NODE_MODULES_TARBALL} -C ${WRKSRC}
+	${REINPLACE_CMD} -e "s/'make'/'gmake'/g" \
+		-e "s/'V='/'V=0'/g" \
+		-e 's/(await (0, nv_1.default)(range)).pop()/{"version": "${NODEJS_PORTVERSION}"}/g' \
+		-e "s|\$${releaseBaseUrl}/\(SHASUMS256.txt\)|${_DISTDIR}/\1|g" \
+		-e 's/await (0, node_fetch_1.default)(shaSumsUrl)/{"ok":1}/g' \
+		-e "s/shaSums.text()/fs_1.promises.readFile(shaSumsUrl, 'utf8')/g" \
+		-e "s/catch (_a) { }/catch (_a) { console.error(_a) }/g" \
+		${NODE_MODULES_DIR}/boxednode/lib/index.js
+	${GREP} -A20 "const shaSumsUrl" ${NODE_MODULES_DIR}/boxednode/lib/index.js
+	${REINPLACE_CMD} -e "s|\('install',\) \('--ignore-scripts'\)|\1 '--offline', '--cache ${NPM_CACHE_DIR}', \2|g" \
+		${NODE_MODULES_DIR}/boxednode/lib/native-addons.js
+	${GREP} "ignore-scripts" ${NODE_MODULES_DIR}/boxednode/lib/native-addons.js
+.endif
+
+post-patch:
+	${FIND} ${WRKSRC}/scripts -name "*.orig" -delete
+	${CP} -v ${FILESDIR}/node-patches/* ${WRKSRC}/scripts/nodejs-patches
+
+do-configure:
+.for module in mongodb-client-encryption kerberos os-dns-native
+	cd ${NODE_MODULES_DIR}/${module} && ${CONFIGURE_ENV} node-gyp configure --nodedir=${LOCALBASE}
+.endfor
+
+do-build:
+.for module in mongodb-client-encryption kerberos os-dns-native
+	cd ${NODE_MODULES_DIR}/${module} && ${MAKE_ENV} ${MAKE_CMD} BUILDTYPE=Release -C build -d
+.endfor
+	${REINPLACE_CMD} 's/"version": "0.0.0-dev.0"/"version": "${DISTVERSION}"/g' ${WRKSRC}/packages/cli-repl/package.json
+	cd ${WRKSRC} && ${MAKE_ENV} /usr/local/bin/npm run compile-exec
+
+do-install:
+	${INSTALL_PROGRAM} ${WRKSRC}/dist/mongosh ${STAGEDIR}${PREFIX}/bin
+
+npm-pkg-list: extract
+	${GREP} registry.npmjs.org ${WRKSRC}/package-lock.json | \
+		| ${SED} -E 's/^[[:space:]]+//g' \
+		| ${SED} -E 's#^.*org/|.tgz",##g' \
+		| ${SORT} \
+		| /usr/bin/uniq \
+		| ${SED} -E 's/(.*)-([^-])/\1@\2/g' \
+		| ${SED} -E 's|/-/.*@|@|g' \
+		> ${FILESDIR}/npm-pkg.list
+
+.for module in mongodb-client-encryption kerberos os-dns-native mongodb-crypt-library-version glibc-version
+	cd ${NODE_MODULES_DIR}/${module} && /usr/local/bin/npm list 2>/dev/null \
+		| ${GREP} UNMET \
+		| ${AWK} 'BEGIN{FS="UNMET DEPENDENCY "}{print $$2}' \
+		> ${FILESDIR}/npm-pkg-${module}.list
+.endfor
+
+node-modules-archive: build
+	${RM} -R ${NODE_MODULES_DIR}
+.for module in mongodb-client-encryption kerberos os-dns-native
+	${MKDIR} -v ${NODE_MODULES_DIR}/${module}
+	${TAR} -xzf ${_DISTDIR}/${module}-*.tgz -C ${NODE_MODULES_DIR}/${module} --strip-components 1
+.endfor
+	for f in ${FILESDIR}/node-modules-patches/*; do patch -N -d ${WRKSRC} < $$f; done
+
+	cd ${WRKSRC} && npx cross-env PUPPETEER_SKIP_DOWNLOAD=1 /usr/local/bin/npm install --cache ${NPM_CACHE_DIR}
+
+.for module in mongodb-client-encryption kerberos os-dns-native mongodb-crypt-library-version glibc-version
+	/usr/local/bin/npm cache add $$(cat ${FILESDIR}/npm-pkg-${module}.list) --cache ${NPM_CACHE_DIR} || true
+	cd ${NODE_MODULES_DIR}/${module} && ${CONFIGURE_ENV} /usr/local/bin/npm install --ignore-scripts --cache ${NPM_CACHE_DIR}
+.endfor
+	${FIND} ${WRKSRC} -name "*.orig" -or -name "*.bak" -delete
+
+	cd ${WRKSRC} && ${TAR} -cJf /tmp/${NODE_MODULES_TARBALL} node_modules
+
+.include <bsd.port.mk>
+.include "${PORTSDIR}/www/node${NODEJS_VERSION}/Makefile.version"
diff --git a/databases/mongosh/distinfo b/databases/mongosh/distinfo
new file mode 100644
index 000000000000..8dffa8c17bde
--- /dev/null
+++ b/databases/mongosh/distinfo
@@ -0,0 +1,11 @@
+TIMESTAMP = 1731685667
+SHA256 (mongosh/mongodb-client-encryption-6.0.0.tgz) = b72d6ad4e4c449ba4548f8f4f8708d37c1490c6615caefa8c56a02f22897b64a
+SIZE (mongosh/mongodb-client-encryption-6.0.0.tgz) = 15734
+SHA256 (mongosh/kerberos-2.1.0.tgz) = eeb1d33472dcf15be8ae46e30ffc76455a62356a91cee52bb8d48f97a35a58c7
+SIZE (mongosh/kerberos-2.1.0.tgz) = 28988
+SHA256 (mongosh/os-dns-native-1.2.0.tgz) = cfe145091dd469c4fe6923b61ef85621222526a0ed74b01b6b3739069d244f7d
+SIZE (mongosh/os-dns-native-1.2.0.tgz) = 6525
+SHA256 (mongosh/mongosh-v2.2.5-node-modules.tar.xz) = 2a1f75f49bcb49a93bd58d38d8a3fdbae685d57ade77e85b95ceba10c5b047c3
+SIZE (mongosh/mongosh-v2.2.5-node-modules.tar.xz) = 155537736
+SHA256 (mongosh/VultureProject-mongosh-v2.2.5_GH0.tar.gz) = 38fd3c21433d2b8d371161941843a3c6a6652e41c4a9d3cfa3917164630f3928
+SIZE (mongosh/VultureProject-mongosh-v2.2.5_GH0.tar.gz) = 8653615
diff --git a/databases/mongosh/files/node-modules-patches/patch-node__modules_kerberos_binding.gyp b/databases/mongosh/files/node-modules-patches/patch-node__modules_kerberos_binding.gyp
new file mode 100644
index 000000000000..6c40a322285e
--- /dev/null
+++ b/databases/mongosh/files/node-modules-patches/patch-node__modules_kerberos_binding.gyp
@@ -0,0 +1,32 @@
+--- node_modules/kerberos/binding.gyp.orig	2024-05-13 15:16:38 UTC
++++ node_modules/kerberos/binding.gyp
+@@ -34,14 +34,18 @@
+               'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
+             }
+         }],
+-        ['OS=="mac" or OS=="linux"', {
++        ['OS=="mac" or OS=="linux" or OS=="freebsd"', {
+           'sources': [
+             'src/unix/base64.cc',
+             'src/unix/kerberos_gss.cc',
+             'src/unix/kerberos_unix.cc'
+           ]
+         }],
+-        ['(OS=="mac" or OS=="linux") and (kerberos_use_rtld!="true")', {
++        ['(OS=="mac" or OS=="linux" or OS=="freebsd") and (kerberos_use_rtld!="true")', {
++          'defines': ['NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT'],
++          'include_dirs': [
++            '/usr/local/include'
++          ],
+           'link_settings': {
+             'libraries': [
+               '-lkrb5',
+@@ -58,7 +62,7 @@
+             }]
+           ]
+         }],
+-        ['(OS=="mac" or OS=="linux") and (kerberos_use_rtld=="true")', {
++        ['(OS=="mac" or OS=="linux" or OS=="freebsd") and (kerberos_use_rtld=="true")', {
+           'defines': ['KERBEROS_USE_RTLD=1'],
+           'link_settings': {
+             'libraries': [
diff --git a/databases/mongosh/files/node-modules-patches/patch-node__modules_kerberos_src_kerberos__common.h b/databases/mongosh/files/node-modules-patches/patch-node__modules_kerberos_src_kerberos__common.h
new file mode 100644
index 000000000000..ca2ad82d6d29
--- /dev/null
+++ b/databases/mongosh/files/node-modules-patches/patch-node__modules_kerberos_src_kerberos__common.h
@@ -0,0 +1,11 @@
+--- node_modules/kerberos/src/kerberos_common.h.orig	2024-05-13 16:09:25 UTC
++++ node_modules/kerberos/src/kerberos_common.h
+@@ -1,7 +1,7 @@
+ #ifndef KERBEROS_COMMON_H
+ #define KERBEROS_COMMON_H
+ 
+-#if defined(__linux__) || defined(__APPLE__)
++#if defined(__linux__) || defined(__APPLE__) || defined(__FreeBSD__)
+ #include "unix/kerberos_gss.h"
+ 
+ namespace node_kerberos {
diff --git a/databases/mongosh/files/node-modules-patches/patch-node__modules_mongodb-client-encryption_binding.gyp b/databases/mongosh/files/node-modules-patches/patch-node__modules_mongodb-client-encryption_binding.gyp
new file mode 100644
index 000000000000..bf3a39c2554f
--- /dev/null
+++ b/databases/mongosh/files/node-modules-patches/patch-node__modules_mongodb-client-encryption_binding.gyp
@@ -0,0 +1,35 @@
+--- node_modules/mongodb-client-encryption/binding.gyp.orig	2024-05-13 14:10:24 UTC
++++ node_modules/mongodb-client-encryption/binding.gyp
+@@ -38,9 +38,14 @@
+           }
+       }],
+       ['build_type=="dynamic"', {
++        'defines': [ 'NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT' ],
++        'include_dirs': [
++          '/usr/include',
++          '/usr/local/include'
++        ],
+         'link_settings': {
+           'libraries': [
+-            '-lmongocrypt'
++            '-L/usr/local/lib -lmongocrypt'
+           ]
+         }
+       }],
+@@ -48,13 +53,12 @@
+         'conditions': [
+           ['OS!="win"', {
+             'include_dirs': [
+-              '<(module_root_dir)/deps/include'
++              '/usr/include',
++              '/usr/local/include'
+             ],
+             'link_settings': {
+               'libraries': [
+-                '<(module_root_dir)/deps/lib/libmongocrypt-static.a',
+-                '<(module_root_dir)/deps/lib/libkms_message-static.a',
+-                '<(module_root_dir)/deps/lib/libbson-static-for-libmongocrypt.a'
++                '-L/usr/local/lib -lmongocrypt'
+               ]
+             }
+           }],
diff --git a/databases/mongosh/files/node-modules-patches/patch-node__modules_mongodb-client-encryption_package.json b/databases/mongosh/files/node-modules-patches/patch-node__modules_mongodb-client-encryption_package.json
new file mode 100644
index 000000000000..63545e891861
--- /dev/null
+++ b/databases/mongosh/files/node-modules-patches/patch-node__modules_mongodb-client-encryption_package.json
@@ -0,0 +1,11 @@
+--- node_modules/mongodb-client-encryption/package.json.orig	2024-05-13 13:50:11 UTC
++++ node_modules/mongodb-client-encryption/package.json
+@@ -16,7 +16,7 @@
+     "lib": "lib"
+   },
+   "scripts": {
+-    "install": "prebuild-install --runtime napi --tag-prefix node-v || node-gyp rebuild",
++    "install": "prebuild-install --runtime napi --tag-prefix node-v || BUILD_TYPE=dynamic node-gyp rebuild",
+     "build:ts": "tsc",
+     "clang-format": "clang-format --style=file:.clang-format --Werror -i addon/*",
+     "check:eslint": "eslint src test",
diff --git a/databases/mongosh/files/node-modules-patches/patch-node__modules_os-dns-native_binding.gyp b/databases/mongosh/files/node-modules-patches/patch-node__modules_os-dns-native_binding.gyp
new file mode 100644
index 000000000000..340a86450dc4
--- /dev/null
+++ b/databases/mongosh/files/node-modules-patches/patch-node__modules_os-dns-native_binding.gyp
@@ -0,0 +1,13 @@
+--- node_modules/os-dns-native/binding.gyp.orig	2024-05-13 16:56:54 UTC
++++ node_modules/os-dns-native/binding.gyp
+@@ -19,10 +19,6 @@
+         "link_settings": {
+           "libraries": ["-ldnsapi"]
+         }
+-      }, {
+-        "link_settings": {
+-          "libraries": ["-lresolv"]
+-        }
+       }]
+     ]
+   }]
diff --git a/databases/mongosh/files/node-patches/004-openssl3 b/databases/mongosh/files/node-patches/004-openssl3
new file mode 100644
index 000000000000..6b1f10fb4a83
--- /dev/null
+++ b/databases/mongosh/files/node-patches/004-openssl3
@@ -0,0 +1,15 @@
+--- a/src/crypto/crypto_util.cc	2023-05-16 06:58:21 UTC
++++ b/src/crypto/crypto_util.cc
+@@ -205,10 +205,12 @@ void InitCryptoOnce() {
+   // No-op with OPENSSL_NO_COMP builds of OpenSSL.
+   sk_SSL_COMP_zero(SSL_COMP_get_compression_methods());
+ 
++#if OPENSSL_VERSION_MAJOR < 3
+ #ifndef OPENSSL_NO_ENGINE
+   ERR_load_ENGINE_strings();
+   ENGINE_load_builtin_engines();
+ #endif  // !OPENSSL_NO_ENGINE
++#endif
+ }
+ 
+ void GetFipsCrypto(const FunctionCallbackInfo<Value>& args) {
diff --git a/databases/mongosh/files/node-patches/005-src_cares__wrap.h b/databases/mongosh/files/node-patches/005-src_cares__wrap.h
new file mode 100644
index 000000000000..80c07e6aab7a
--- /dev/null
+++ b/databases/mongosh/files/node-patches/005-src_cares__wrap.h
@@ -0,0 +1,11 @@
+--- a/src/cares_wrap.h	2023-05-16 06:58:21 UTC
++++ b/src/cares_wrap.h
+@@ -23,7 +23,7 @@
+ # include <netdb.h>
+ #endif  // __POSIX__
+ 
+-# include <ares_nameser.h>
++# include <arpa/nameser.h>
+ 
+ namespace node {
+ namespace cares_wrap {
diff --git a/databases/mongosh/files/patch-package.json b/databases/mongosh/files/patch-package.json
new file mode 100644
index 000000000000..001034097bb1
--- /dev/null
+++ b/databases/mongosh/files/patch-package.json
@@ -0,0 +1,36 @@
+--- package.json.orig	2024-05-15 14:01:43 UTC
++++ package.json
+@@ -9,7 +9,7 @@
+   "author": "Compass Team <compass@mongodb.com>",
+   "scripts": {
+     "bootstrap-with-chromium": "npm install && npm run compile",
+-    "bootstrap": "npx cross-env PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1 npm install && npm run compile",
++    "bootstrap": "npx cross-env PUPPETEER_SKIP_DOWNLOAD=1 npm install && npm run compile",
+     "clean": "lerna clean -y && rm -Rf node_modules",
+     "check": "lerna run check --since HEAD --exclude-dependents",
+     "check-ci": "npm run check --workspaces --if-present",
+@@ -33,7 +33,7 @@
+     "start-browser": "npm run start --workspace @mongosh/browser-repl",
+     "start": "npm run start-cli",
+     "precompile-exec": "npm run compile-cli",
+-    "compile-exec": "npm run evergreen-release compile",
++    "compile-exec": "SEGMENT_API_KEY=dummy npm run evergreen-release compile",
+     "compile-all": "npm run compile-compass && npm run compile-exec",
+     "evergreen-release": "cd packages/build && npm run evergreen-release --",
+     "release": "cd packages/build && npm run release --",
+@@ -59,7 +59,6 @@
+     "create-vulnerability-tickets": "mongodb-sbom-tools generate-vulnerability-report --snyk-reports=.sbom/snyk-test-result.json,.sbom/node-js-vuln.json --dependencies=.sbom/dependencies.json,.sbom/node-js-dep.json --create-jira-issues",
+     "where": "monorepo-where",
+     "reformat": "npm run reformat --workspaces --if-present",
+-    "prepare": "husky install",
+     "precommit": "precommit",
+     "preinstall": "node scripts/sort-workspaces.js"
+   },
+@@ -101,7 +100,6 @@
+     "duplexpair": "^1.0.2",
+     "find-up": "^5.0.0",
+     "glob": "^10.3.12",
+-    "husky": "^8.0.3",
+     "mocha": "^10.2.0",
+     "mongodb": "^6.5.0",
+     "mongodb-runner": "^5.4.6",
diff --git a/databases/mongosh/files/patch-scripts_nodejs-patches_002-workaround-node-bug-52229 b/databases/mongosh/files/patch-scripts_nodejs-patches_002-workaround-node-bug-52229
new file mode 100644
index 000000000000..bed349e3cb91
--- /dev/null
+++ b/databases/mongosh/files/patch-scripts_nodejs-patches_002-workaround-node-bug-52229
@@ -0,0 +1,17 @@
+--- scripts/nodejs-patches/002-workaround-node-bug-52229.orig	2024-05-16 08:32:21 UTC
++++ scripts/nodejs-patches/002-workaround-node-bug-52229
+@@ -2,13 +2,12 @@ diff --git a/common.gypi b/common.gypi
+ index efcd8da84815..fe11453f09b5 100644
+ --- a/common.gypi
+ +++ b/common.gypi
+-@@ -268,6 +268,9 @@
++@@ -268,6 +268,8 @@
+      # Defines these mostly for node-gyp to pickup.
+      'defines': [
+        '_GLIBCXX_USE_CXX11_ABI=1',
+ +      # Work around https://github.com/nodejs/node/issues/52229
+ +      "NODE_API_EXPERIMENTAL_NOGC_ENV_OPT_OUT=1",
+-+      "NAPI_EXPERIMENTAL=1",
+      ],
+ 
+      # Forcibly disable -Werror.  We support a wide range of compilers, it's
diff --git a/databases/mongosh/files/patch-scripts_prep-fle-addon.sh b/databases/mongosh/files/patch-scripts_prep-fle-addon.sh
new file mode 100644
index 000000000000..bfc90c06c7bb
--- /dev/null
+++ b/databases/mongosh/files/patch-scripts_prep-fle-addon.sh
@@ -0,0 +1,20 @@
+--- scripts/prep-fle-addon.sh.orig	2024-05-13 17:26:57 UTC
++++ scripts/prep-fle-addon.sh
+@@ -62,7 +62,7 @@ if [ x"$PREBUILT_OSNAME" != x"" ]; then
+   mv -v prebuilts/nocrypto/include include
+   mv -v prebuilts/$LIB/*bson* lib
+   rm -rf prebuilts
+-else
++elif [ `uname` != FreeBSD ]; then
+   if [ `uname` = Darwin ]; then
+     export CFLAGS="-mmacosx-version-min=10.15";
+   fi
+@@ -86,7 +86,7 @@ else
+   cd ../../
+ fi
+ 
+-if [ x"$FLE_NODE_SOURCE_PATH" != x"" ]; then
++if [ x"$FLE_NODE_SOURCE_PATH" != x"" -a `uname` != FreeBSD -a "$BUILD_TYPE" != dynamic ]; then
+   mkdir -p "$FLE_NODE_SOURCE_PATH"/deps/lib
+   mkdir -p "$FLE_NODE_SOURCE_PATH"/deps/include
+   cp -rv "$BUILDROOT"/lib*/*-static* "$FLE_NODE_SOURCE_PATH"/deps/lib
diff --git a/databases/mongosh/files/patch-scripts_sort-workspaces.js b/databases/mongosh/files/patch-scripts_sort-workspaces.js
new file mode 100644
index 000000000000..0fe4e6da9222
--- /dev/null
+++ b/databases/mongosh/files/patch-scripts_sort-workspaces.js
@@ -0,0 +1,11 @@
+--- scripts/sort-workspaces.js.orig	2024-05-03 16:42:16 UTC
++++ scripts/sort-workspaces.js
+@@ -22,7 +22,7 @@ async function main() {
+   ));
+ 
+   // should use the scopes in lerna.json
+-  const { stdout } = await exec('npx -y lerna ls --all --no-since --toposort --json');
++  const { stdout } = await exec('npx -y lerna ls --all --toposort --json');
+   packageJSON.workspaces = JSON.parse(stdout).map(({ location }) => path.relative(monorepoRoot, location));
+ 
+   await fs.writeFile(
diff --git a/databases/mongosh/pkg-descr b/databases/mongosh/pkg-descr
new file mode 100644
index 000000000000..1bacc1542255
--- /dev/null
+++ b/databases/mongosh/pkg-descr
@@ -0,0 +1,5 @@
+Standalone MongoDB Shell replacing deprecated Mongo CLI.
+NodeJS doesn't need to be installed.
+
+This port is maintained by VultureOS Team.
+Contact us if you experience any issue: https://discord.gg/E5Bs97J
diff --git a/databases/mongosh/pkg-plist b/databases/mongosh/pkg-plist
new file mode 100644
index 000000000000..061e8b2e4302
--- /dev/null
+++ b/databases/mongosh/pkg-plist
@@ -0,0 +1 @@
+bin/mongosh