commit:     5c43cb4a04c6df2de851fe7a739bcaeb27b8668c
Author:     François Valenduc <francoisvalenduc <AT> gmail <DOT> com>
AuthorDate: Fri May  2 11:13:20 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue May  6 19:10:33 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=5c43cb4a

dev-db/mongodb: add 7.0.18

Bug: https://bugs.gentoo.org/882515
Signed-off-by: François Valenduc <francoisvalenduc <AT> gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/41580
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-db/mongodb/Manifest                            |   1 +
 dev-db/mongodb/files/extrapatch-sconstruct.patch   |  16 ++
 .../mongodb/files/mongodb-7.0.1-sconstruct.patch   | 115 ++++++++++
 .../mongodb/files/mongodb-7.0.18-boost-1.85.patch  | 204 ++++++++++++++++++
 .../mongodb/files/mongodb-7.0.2-sconstruct.patch   | 236 +++++++++++++++++++++
 dev-db/mongodb/mongodb-7.0.18.ebuild               | 206 ++++++++++++++++++
 6 files changed, 778 insertions(+)

diff --git a/dev-db/mongodb/Manifest b/dev-db/mongodb/Manifest
index c0321b0ab545..b53236d593ff 100644
--- a/dev-db/mongodb/Manifest
+++ b/dev-db/mongodb/Manifest
@@ -1,2 +1,3 @@
 DIST mongodb-5.0.30.gh.tar.gz 57312372 BLAKE2B 
72b026115cf3c8b1b81857bc5bffcd5b72bae4b581a7ada598bc7bbe594f264f581212159788113c5709ab751dd8a57943a3cc9b78f0d31aeb50375fa1da2c28
 SHA512 
97642da12cf199fa3f17825b1eb20e4d9bc1f65c8950f54b36347af11b6964cdd2007d11b01147d0c253077ef14121de52517c1739b433b49a9cbbe2596d9d05
 DIST mongodb-6.0.22.gh.tar.gz 87688277 BLAKE2B 
1ff5206cb996763ca051129572eb9bf6f8cff0ceeae7f86c4472e49a7d2210de602beead53d3aba7d8ee3b168a50a2505b8cfc91cd22968dd39a42ba13432e73
 SHA512 
4a3258b22d31ee81d5932d82dc5d19aec0b3648593d57cedd21b74c46bf4bfea833a519f4e90c1f2f860aa46781297dd16b7324145713e36eee81d41e684c420
+DIST mongodb-7.0.18.gh.tar.gz 87225100 BLAKE2B 
7ede32f4c6b6968ee8d797ce71457133020a3e4a039cd0db914e344e5042a0b871deb5741f86098b2e82b9ff619a511a754a06a29dcbb9527a3b7a7edf52b3ac
 SHA512 
599767db66e95d8dd0bd0e6d51fd70129ea6df1e18a0cdaa52bc6cbe301c982684ff5aab446c50cb825573051e372d8f791aeab7df58e2a4d855e6073f2b46d5

diff --git a/dev-db/mongodb/files/extrapatch-sconstruct.patch 
b/dev-db/mongodb/files/extrapatch-sconstruct.patch
new file mode 100644
index 000000000000..21c09bc5c9a1
--- /dev/null
+++ b/dev-db/mongodb/files/extrapatch-sconstruct.patch
@@ -0,0 +1,16 @@
+--- a/SConstruct
++++ b/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/dev-db/mongodb/files/mongodb-7.0.1-sconstruct.patch 
b/dev-db/mongodb/files/mongodb-7.0.1-sconstruct.patch
new file mode 100644
index 000000000000..9c7cf21fc0c8
--- /dev/null
+++ b/dev-db/mongodb/files/mongodb-7.0.1-sconstruct.patch
@@ -0,0 +1,115 @@
+diff --git a/SConstruct b/SConstruct
+index 2ebeb0e..44ce93a 100644
+--- a/SConstruct
++++ b/SConstruct
+@@ -23,7 +23,6 @@ from pkg_resources import parse_version
+ 
+ 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
+@@ -1657,13 +1656,6 @@ 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'
+@@ -3034,7 +3026,6 @@ if env.TargetOSIs('posix'):
+     env.Append(
+         CCFLAGS=[
+             "-fasynchronous-unwind-tables",
+-            "-g2" if not env.TargetOSIs('emscripten') else "-g",
+             "-Wall",
+             "-Wsign-compare",
+             "-Wno-unknown-pragmas",
+@@ -3101,6 +3092,8 @@ if env.TargetOSIs('posix'):
+ 
+     # env.Append( " -Wconversion" ) TODO: this doesn't really work yet
+     env.Append(CXXFLAGS=["-Woverloaded-virtual"])
++    env.Append(CXXFLAGS=os.environ['CXXFLAGS'])
++    env.Append(LINKFLAGS=os.environ['LDFLAGS'])
+ 
+     # On OS X, clang doesn't want the pthread flag at link time, or it
+     # issues warnings which make it impossible for us to declare link
+@@ -3151,7 +3144,7 @@ if env.TargetOSIs('posix'):
+         ], )
+ 
+     #make scons colorgcc friendly
+-    for key in ('HOME', 'TERM'):
++    for key in ('HOME', 'TERM', 'PATH'):
+         try:
+             env['ENV'][key] = os.environ[key]
+         except KeyError:
+@@ -3553,33 +3546,6 @@ def doConfigure(myenv):
+         myenv.AddMethod(
+             functools.partial(var_func, var=var, func=CheckFlag), 
f"Check{var}Supported")
+ 
+-    if myenv.ToolchainIs('gcc', 'clang'):
+-        # This tells clang/gcc to use the gold linker if it is available - we 
prefer the gold linker
+-        # because it is much faster. Don't use it if the user has already 
configured another linker
+-        # selection manually.
+-        if any(flag.startswith('-fuse-ld=') for flag in env['LINKFLAGS']):
+-            myenv.FatalError(
+-                f"Use the '--linker' option instead of modifying the 
LINKFLAGS directly.")
+-
+-        linker_ld = get_option('linker')
+-        if linker_ld == 'auto':
+-            if not env.TargetOSIs('darwin', 'macOS'):
+-                if not myenv.AddToLINKFLAGSIfSupported('-fuse-ld=lld'):
+-                    myenv.FatalError(
+-                        f"The recommended linker 'lld' is not supported with 
the current compiler configuration, you can try the 'gold' linker with 
'--linker=gold'."
+-                    )
+-        elif link_model.startswith("dynamic") and linker_ld == 'bfd':
+-            # BFD is not supported due to issues with it causing warnings 
from some of
+-            # the third party libraries that mongodb is linked with:
+-            # https://jira.mongodb.org/browse/SERVER-49465
+-            myenv.FatalError(f"Linker {linker_ld} is not supported with 
dynamic link model builds.")
+-        else:
+-            if not myenv.AddToLINKFLAGSIfSupported(f'-fuse-ld={linker_ld}'):
+-                myenv.FatalError(f"Linker {linker_ld} could not be 
configured.")
+-
+-        if has_option('gcov') and 
myenv.AddToCCFLAGSIfSupported('-fprofile-update=single'):
+-            myenv.AppendUnique(LINKFLAGS=['-fprofile-update=single'])
+-
+     detectCompiler = Configure(
+         myenv,
+         help=False,
+@@ -5119,17 +5085,13 @@ def doConfigure(myenv):
+         "BOOST_LOG_NO_SHORTHAND_NAMES",
+         "BOOST_LOG_USE_NATIVE_SYSLOG",
+         "BOOST_LOG_WITHOUT_THREAD_ATTR",
++        "BOOST_LOG_DYN_LINK",
+         "BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS",
+         "BOOST_SYSTEM_NO_DEPRECATED",
+         "BOOST_THREAD_USES_DATETIME",
+         ("BOOST_THREAD_VERSION", "5"),
+     ])
+ 
+-    if link_model.startswith("dynamic") and not link_model == 'dynamic-sdk':
+-        conf.env.AppendUnique(CPPDEFINES=[
+-            "BOOST_LOG_DYN_LINK",
+-        ])
+-
+     if use_system_version_of_library("boost"):
+         if not conf.CheckCXXHeader("boost/filesystem/operations.hpp"):
+             myenv.ConfError("can't find boost headers")
+@@ -5326,6 +5288,9 @@ def doConfigure(myenv):
+ 
+     mongoc_mode = get_option('use-system-mongo-c')
+     conf.env['MONGO_HAVE_LIBMONGOC'] = False
++    conf.env.ParseConfig('pkg-config libbson-1.0 libmongoc-1.0 --cflags')
++    conf.env['LIBDEPS_LIBBSON_SYSLIBDEP'] = 'bson-1.0'
++
+     if mongoc_mode != 'off':
+         if conf.CheckLibWithHeader(
+             ["mongoc-1.0"],

diff --git a/dev-db/mongodb/files/mongodb-7.0.18-boost-1.85.patch 
b/dev-db/mongodb/files/mongodb-7.0.18-boost-1.85.patch
new file mode 100644
index 000000000000..ab9c56c2a83a
--- /dev/null
+++ b/dev-db/mongodb/files/mongodb-7.0.18-boost-1.85.patch
@@ -0,0 +1,204 @@
+From 50d52404a69171052a9a55259ba7cd1ec9ce6a18 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Fran=C3=A7ois=20Valenduc?= <[email protected]>
+Date: Sat, 26 Apr 2025 12:07:21 +0200
+Subject: [PATCH] fix for boost 1.85
+
+---
+ src/mongo/db/initialize_server_global_state.cpp     |  4 ++--
+ src/mongo/db/startup_warnings_mongod.cpp            |  1 +
+ src/mongo/db/storage/backup_block.cpp               |  5 ++++-
+ .../db/storage/storage_engine_lock_file_posix.cpp   |  4 ++--
+ src/mongo/db/storage/storage_engine_metadata.cpp    |  4 ++--
+ src/mongo/scripting/engine.cpp                      |  1 +
+ src/mongo/shell/shell_utils_launcher.cpp            | 13 +++++++------
+ src/mongo/shell/shell_utils_launcher.h              |  2 +-
+ src/mongo/unittest/golden_test_base.cpp             |  2 +-
+ 9 files changed, 21 insertions(+), 15 deletions(-)
+
+diff --git a/src/mongo/db/initialize_server_global_state.cpp 
b/src/mongo/db/initialize_server_global_state.cpp
+index 02a30aac334..e774cc4019a 100644
+--- a/src/mongo/db/initialize_server_global_state.cpp
++++ b/src/mongo/db/initialize_server_global_state.cpp
+@@ -33,7 +33,7 @@
+ #include "mongo/db/initialize_server_global_state.h"
+ #include "mongo/db/initialize_server_global_state_gen.h"
+ 
+-#include <boost/filesystem/operations.hpp>
++#include <boost/filesystem.hpp>
+ #include <fmt/format.h>
+ #include <iostream>
+ #include <memory>
+@@ -310,7 +310,7 @@ bool checkAndMoveLogFile(const std::string& 
absoluteLogpath) {
+                                     << "\" should name a file, not a 
directory.");
+         }
+ 
+-        if (!serverGlobalParams.logAppend && 
boost::filesystem::is_regular(absoluteLogpath)) {
++        if (!serverGlobalParams.logAppend && 
boost::filesystem::is_regular_file(absoluteLogpath)) {
+             std::string renameTarget = absoluteLogpath + "." + 
terseCurrentTimeForFilename();
+             boost::system::error_code ec;
+             boost::filesystem::rename(absoluteLogpath, renameTarget, ec);
+diff --git a/src/mongo/db/startup_warnings_mongod.cpp 
b/src/mongo/db/startup_warnings_mongod.cpp
+index af81012ad41..c334e4b386c 100644
+--- a/src/mongo/db/startup_warnings_mongod.cpp
++++ b/src/mongo/db/startup_warnings_mongod.cpp
+@@ -33,6 +33,7 @@
+ #include "mongo/db/startup_warnings_mongod.h"
+ 
+ #include <boost/filesystem/operations.hpp>
++#include <boost/filesystem/exception.hpp>
+ #include <fstream>
+ 
+ #ifdef __linux__
+diff --git a/src/mongo/db/storage/backup_block.cpp 
b/src/mongo/db/storage/backup_block.cpp
+index 9b8dc29f209..10fd6632fc3 100644
+--- a/src/mongo/db/storage/backup_block.cpp
++++ b/src/mongo/db/storage/backup_block.cpp
+@@ -30,6 +30,9 @@
+ #include "mongo/db/storage/backup_block.h"
+ 
+ #include <boost/filesystem.hpp>
++#include <boost/filesystem/fstream.hpp>
++#include <boost/filesystem/operations.hpp>
++#include <boost/filesystem/path.hpp>
+ #include <set>
+ 
+ #include "mongo/base/string_data.h"
+@@ -59,7 +62,7 @@ std::string extractIdentFromPath(const 
boost::filesystem::path& dbpath,
+ 
+     // Remove the file extension and convert to generic form (i.e. replace 
"\" with "/"
+     // on windows, no-op on unix).
+-    return boost::filesystem::change_extension(identWithExtension, 
"").generic_string();
++    return 
boost::filesystem::path(identWithExtension).replace_extension("").generic_string();
+ }
+ 
+ }  // namespace details
+diff --git a/src/mongo/db/storage/storage_engine_lock_file_posix.cpp 
b/src/mongo/db/storage/storage_engine_lock_file_posix.cpp
+index 41fefe73cdf..e8d1d0c08ed 100644
+--- a/src/mongo/db/storage/storage_engine_lock_file_posix.cpp
++++ b/src/mongo/db/storage/storage_engine_lock_file_posix.cpp
+@@ -57,7 +57,7 @@ void flushMyDirectory(const boost::filesystem::path& file) {
+     // if called without a fully qualified path it asserts; that makes 
mongoperf fail.
+     // so make a warning. need a better solution longer term.
+     // massert(40389, str::stream() << "Couldn't find parent dir for file: " 
<< file.string(),);
+-    if (!file.has_branch_path()) {
++    if (!file.has_parent_path()) {
+         LOGV2(22274,
+               "warning flushMyDirectory couldn't find parent dir for file: 
{file}",
+               "flushMyDirectory couldn't find parent dir for file",
+@@ -66,7 +66,7 @@ void flushMyDirectory(const boost::filesystem::path& file) {
+     }
+ 
+ 
+-    boost::filesystem::path dir = file.branch_path();  // parent_path in new 
boosts
++    boost::filesystem::path dir = file.parent_path();  // parent_path in new 
boosts
+ 
+     LOGV2_DEBUG(22275, 1, "flushing directory {dir_string}", 
"dir_string"_attr = dir.string());
+ 
+diff --git a/src/mongo/db/storage/storage_engine_metadata.cpp 
b/src/mongo/db/storage/storage_engine_metadata.cpp
+index 4008ac80d9b..fe2abacbfca 100644
+--- a/src/mongo/db/storage/storage_engine_metadata.cpp
++++ b/src/mongo/db/storage/storage_engine_metadata.cpp
+@@ -222,7 +222,7 @@ void flushMyDirectory(const boost::filesystem::path& file) 
{
+     // if called without a fully qualified path it asserts; that makes 
mongoperf fail.
+     // so make a warning. need a better solution longer term.
+     // massert(13652, str::stream() << "Couldn't find parent dir for file: " 
<< file.string(),);
+-    if (!file.has_branch_path()) {
++    if (!file.has_parent_path()) {
+         LOGV2(22283,
+               "warning flushMyDirectory couldn't find parent dir for file: 
{file}",
+               "flushMyDirectory couldn't find parent dir for file",
+@@ -231,7 +231,7 @@ void flushMyDirectory(const boost::filesystem::path& file) 
{
+     }
+ 
+ 
+-    boost::filesystem::path dir = file.branch_path();  // parent_path in new 
boosts
++    boost::filesystem::path dir = file.parent_path();  // parent_path in new 
boosts
+ 
+     LOGV2_DEBUG(22284, 1, "flushing directory {dir_string}", 
"dir_string"_attr = dir.string());
+ 
+diff --git a/src/mongo/scripting/engine.cpp b/src/mongo/scripting/engine.cpp
+index 7faf89e5ae8..c5e21a62c4d 100644
+--- a/src/mongo/scripting/engine.cpp
++++ b/src/mongo/scripting/engine.cpp
+@@ -34,6 +34,7 @@
+ 
+ #include <algorithm>
+ #include <boost/filesystem/operations.hpp>
++#include <boost/filesystem/directory.hpp>
+ 
+ #include "mongo/base/string_data.h"
+ #include "mongo/client/dbclient_base.h"
+diff --git a/src/mongo/shell/shell_utils_launcher.cpp 
b/src/mongo/shell/shell_utils_launcher.cpp
+index 30a04df5a89..1ff93db38be 100644
+--- a/src/mongo/shell/shell_utils_launcher.cpp
++++ b/src/mongo/shell/shell_utils_launcher.cpp
+@@ -36,6 +36,7 @@
+ #include <boost/iostreams/stream_buffer.hpp>
+ #include <boost/iostreams/tee.hpp>
+ #include <csignal>
++#include <boost/filesystem.hpp>
+ #include <fcntl.h>
+ #include <fmt/format.h>
+ #include <fstream>
+@@ -316,26 +317,26 @@ void copyDir(const boost::filesystem::path& from, const 
boost::filesystem::path&
+     boost::filesystem::directory_iterator i(from);
+     while (i != end) {
+         boost::filesystem::path p = *i;
+-        if (p.leaf() == "metrics.interim" || p.leaf() == 
"metrics.interim.temp") {
++        if (p.filename() == "metrics.interim" || p.filename() == 
"metrics.interim.temp") {
+             // Ignore any errors for metrics.interim* files as these may 
disappear during copy
+             boost::system::error_code ec;
+-            boost::filesystem::copy_file(p, to / p.leaf(), ec);
++            boost::filesystem::copy_file(p, to / p.filename(), ec);
+             if (ec) {
+                 LOGV2_INFO(22814,
+                            "Skipping copying of file from '{from}' to "
+                            "'{to}' due to: {error}",
+                            "Skipping copying of file due to error"
+                            "from"_attr = p.generic_string(),
+-                           "to"_attr = (to / p.leaf()).generic_string(),
++                           "to"_attr = (to / p.filename()).generic_string(),
+                            "error"_attr = ec.message());
+             }
+-        } else if (p.leaf() != "mongod.lock" && p.leaf() != 
"WiredTiger.lock") {
++        } else if (p.filename() != "mongod.lock" && p.filename() != 
"WiredTiger.lock") {
+             if (boost::filesystem::is_directory(p)) {
+-                boost::filesystem::path newDir = to / p.leaf();
++                boost::filesystem::path newDir = to / p.filename();
+                 boost::filesystem::create_directory(newDir);
+                 copyDir(p, newDir);
+             } else {
+-                boost::filesystem::copy_file(p, to / p.leaf());
++                boost::filesystem::copy_file(p, to / p.filename());
+             }
+         }
+         ++i;
+diff --git a/src/mongo/shell/shell_utils_launcher.h 
b/src/mongo/shell/shell_utils_launcher.h
+index 65337f061b3..b92d1126c5d 100644
+--- a/src/mongo/shell/shell_utils_launcher.h
++++ b/src/mongo/shell/shell_utils_launcher.h
+@@ -29,7 +29,7 @@
+ 
+ #pragma once
+ 
+-#include <boost/filesystem/convenience.hpp>
++#include <boost/filesystem/path.hpp>
+ #include <map>
+ #include <sstream>
+ #include <string>
+diff --git a/src/mongo/unittest/golden_test_base.cpp 
b/src/mongo/unittest/golden_test_base.cpp
+index 1544fd3a37b..14f96d0ec75 100644
+--- a/src/mongo/unittest/golden_test_base.cpp
++++ b/src/mongo/unittest/golden_test_base.cpp
+@@ -95,7 +95,7 @@ GoldenTestEnvironment::GoldenTestEnvironment() : 
_goldenDataRoot(".") {
+     fs::path outputRoot;
+     if (opts.outputRootPattern) {
+         fs::path pattern(*opts.outputRootPattern);
+-        outputRoot = pattern.parent_path() / fs::unique_path(pattern.leaf());
++        outputRoot = pattern.parent_path() / 
fs::unique_path(pattern.filename());
+     } else {
+         outputRoot = fs::temp_directory_path() / 
fs::unique_path("out-%%%%-%%%%-%%%%-%%%%");
+     }
+-- 
+2.49.0
+

diff --git a/dev-db/mongodb/files/mongodb-7.0.2-sconstruct.patch 
b/dev-db/mongodb/files/mongodb-7.0.2-sconstruct.patch
new file mode 100644
index 000000000000..20b1d19bfd27
--- /dev/null
+++ b/dev-db/mongodb/files/mongodb-7.0.2-sconstruct.patch
@@ -0,0 +1,236 @@
+diff --git a/SConstruct2 b/SConstruct
+index e9aa2ca..5814f4a 100644
+--- a/SConstruct2
++++ b/SConstruct
+@@ -25,7 +25,7 @@ from pkg_resources import parse_version
+ 
+ import SCons
+ import SCons.Script
+-from mongo_tooling_metrics.lib.top_level_metrics import SConsToolingMetrics
++#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
+@@ -1724,13 +1724,13 @@ 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,
+-)
++#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'
+@@ -3132,7 +3132,7 @@ if env.TargetOSIs('posix'):
+     env.Append(
+         CCFLAGS=[
+             "-fasynchronous-unwind-tables",
+-            "-g2" if not env.TargetOSIs('emscripten') else "-g",
++#            "-g2" if not env.TargetOSIs('emscripten') else "-g",
+             "-Wall",
+             "-Wsign-compare",
+             "-Wno-unknown-pragmas",
+@@ -3200,6 +3200,8 @@ if env.TargetOSIs('posix'):
+ 
+     # env.Append( " -Wconversion" ) TODO: this doesn't really work yet
+     env.Append(CXXFLAGS=["-Woverloaded-virtual"])
++    env.Append(CXXFLAGS=os.environ['CXXFLAGS'])
++    env.Append(LINKFLAGS=os.environ['LDFLAGS'])
+ 
+     # On OS X, clang doesn't want the pthread flag at link time, or it
+     # issues warnings which make it impossible for us to declare link
+@@ -3250,7 +3252,7 @@ if env.TargetOSIs('posix'):
+         ], )
+ 
+     #make scons colorgcc friendly
+-    for key in ('HOME', 'TERM'):
++    for key in ('HOME', 'TERM', 'PATH'):
+         try:
+             env['ENV'][key] = os.environ[key]
+         except KeyError:
+@@ -3644,35 +3646,35 @@ def doConfigure(myenv):
+         myenv.AddMethod(
+             functools.partial(var_func, var=var, func=CheckFlag), 
f"Check{var}Supported")
+ 
+-    if myenv.ToolchainIs('gcc', 'clang'):
+-        # This tells clang/gcc to use the gold linker if it is available - we 
prefer the gold linker
+-        # because it is much faster. Don't use it if the user has already 
configured another linker
+-        # selection manually.
+-        if any(flag.startswith('-fuse-ld=') for flag in env['LINKFLAGS']):
+-            myenv.FatalError(
+-                f"Use the '--linker' option instead of modifying the 
LINKFLAGS directly.")
+-
+-        linker_ld = get_option('linker')
+-
+-        if linker_ld == "bfd" and env.get("BAZEL_BUILD_ENABLED"):
+-            myenv.FatalError(f"The linker 'bfd' is not supported with 
BAZEL_BUILD_ENABLED.")
+-        elif linker_ld == 'auto':
+-            if not env.TargetOSIs('darwin', 'macOS'):
+-                if not myenv.AddToLINKFLAGSIfSupported('-fuse-ld=lld'):
+-                    myenv.FatalError(
+-                        f"The recommended linker 'lld' is not supported with 
the current compiler configuration, you can try the 'gold' linker with 
'--linker=gold'."
+-                    )
+-        elif link_model.startswith("dynamic") and linker_ld == 'bfd':
+-            # BFD is not supported due to issues with it causing warnings 
from some of
+-            # the third party libraries that mongodb is linked with:
+-            # https://jira.mongodb.org/browse/SERVER-49465
+-            myenv.FatalError(f"Linker {linker_ld} is not supported with 
dynamic link model builds.")
+-        else:
+-            if not myenv.AddToLINKFLAGSIfSupported(f'-fuse-ld={linker_ld}'):
+-                myenv.FatalError(f"Linker {linker_ld} could not be 
configured.")
+-
+-        if has_option('gcov') and 
myenv.AddToCCFLAGSIfSupported('-fprofile-update=single'):
+-            myenv.AppendUnique(LINKFLAGS=['-fprofile-update=single'])
++#    if myenv.ToolchainIs('gcc', 'clang'):
++#        # This tells clang/gcc to use the gold linker if it is available - 
we prefer the gold linker
++#        # because it is much faster. Don't use it if the user has already 
configured another linker
++#        # selection manually.
++#        if any(flag.startswith('-fuse-ld=') for flag in env['LINKFLAGS']):
++#            myenv.FatalError(
++#                f"Use the '--linker' option instead of modifying the 
LINKFLAGS directly.")
++#
++#        linker_ld = get_option('linker')
++#
++#        if linker_ld == "bfd" and env.get("BAZEL_BUILD_ENABLED"):
++#            myenv.FatalError(f"The linker 'bfd' is not supported with 
BAZEL_BUILD_ENABLED.")
++#        elif linker_ld == 'auto':
++#            if not env.TargetOSIs('darwin', 'macOS'):
++#                if not myenv.AddToLINKFLAGSIfSupported('-fuse-ld=lld'):
++#                    myenv.FatalError(
++#                        f"The recommended linker 'lld' is not supported with 
the current compiler configuration, you can try the 'gold' linker with 
'--linker=gold'."
++#                    )
++#        elif link_model.startswith("dynamic") and linker_ld == 'bfd':
++#            # BFD is not supported due to issues with it causing warnings 
from some of
++#            # the third party libraries that mongodb is linked with:
++#            # https://jira.mongodb.org/browse/SERVER-49465
++#            myenv.FatalError(f"Linker {linker_ld} is not supported with 
dynamic link model builds.")
++#        else:
++#            if not myenv.AddToLINKFLAGSIfSupported(f'-fuse-ld={linker_ld}'):
++#                myenv.FatalError(f"Linker {linker_ld} could not be 
configured.")
++#
++#        if has_option('gcov') and 
myenv.AddToCCFLAGSIfSupported('-fprofile-update=single'):
++#            myenv.AppendUnique(LINKFLAGS=['-fprofile-update=single'])
+ 
+     detectCompiler = Configure(
+         myenv,
+@@ -4765,42 +4767,42 @@ def doConfigure(myenv):
+     if optBuild == "off" and myenv.ToolchainIs('clang') and 
env.TargetOSIs('darwin'):
+         myenv.AddToLINKFLAGSIfSupported("-Wl,-no_deduplicate")
+ 
+-    # Apply any link time optimization settings as selected by the 'lto' 
option.
+-    if has_option('lto'):
+-        if myenv.ToolchainIs('msvc'):
+-            # Note that this is actually more aggressive than LTO, it is 
whole program
+-            # optimization due to /GL. However, this is historically what we 
have done for
+-            # windows, so we are keeping it.
+-            #
+-            # /GL implies /LTCG, so no need to say it in CCFLAGS, but we do 
need /LTCG on the
+-            # link flags.
+-            myenv.Append(CCFLAGS=['/GL'])
+-            myenv.Append(LINKFLAGS=['/LTCG'])
+-            myenv.Append(ARFLAGS=['/LTCG'])
+-        elif myenv.ToolchainIs('gcc', 'clang'):
+-            # For GCC and clang, the flag is -flto, and we need to pass it 
both on the compile
+-            # and link lines.
+-            if not myenv.AddToCCFLAGSIfSupported('-flto') or \
+-                    not myenv.AddToLINKFLAGSIfSupported('-flto'):
+-                myenv.ConfError("Link time optimization requested, "
+-                                "but selected compiler does not honor -flto")
+-
+-            if myenv.TargetOSIs('darwin'):
+-                
myenv.AddToLINKFLAGSIfSupported('-Wl,-object_path_lto,${TARGET}.lto')
+-            else:
+-                # According to intel benchmarks -fno-plt increases perf
+-                # See PM-2215
+-                if linker_ld != "gold":
+-                    myenv.ConfError("lto compilation currently only works 
with the --linker=gold")
+-                if link_model != "object":
+-                    myenv.ConfError(
+-                        "lto compilation currently only works with the 
--link-model=object")
+-                if not myenv.AddToCCFLAGSIfSupported('-fno-plt') or \
+-                    not myenv.AddToLINKFLAGSIfSupported('-fno-plt'):
+-                    myenv.ConfError("-fno-plt is not supported by the 
compiler")
+-
+-        else:
+-            myenv.ConfError("Don't know how to enable --lto on current 
toolchain")
++#    # Apply any link time optimization settings as selected by the 'lto' 
option.
++#    if has_option('lto'):
++#        if myenv.ToolchainIs('msvc'):
++#            # Note that this is actually more aggressive than LTO, it is 
whole program
++#            # optimization due to /GL. However, this is historically what we 
have done for
++#            # windows, so we are keeping it.
++#            #
++#            # /GL implies /LTCG, so no need to say it in CCFLAGS, but we do 
need /LTCG on the
++#            # link flags.
++#            myenv.Append(CCFLAGS=['/GL'])
++#            myenv.Append(LINKFLAGS=['/LTCG'])
++#            myenv.Append(ARFLAGS=['/LTCG'])
++#        elif myenv.ToolchainIs('gcc', 'clang'):
++#            # For GCC and clang, the flag is -flto, and we need to pass it 
both on the compile
++#            # and link lines.
++#            if not myenv.AddToCCFLAGSIfSupported('-flto') or \
++#                    not myenv.AddToLINKFLAGSIfSupported('-flto'):
++#                myenv.ConfError("Link time optimization requested, "
++#                                "but selected compiler does not honor -flto")
++#
++#            if myenv.TargetOSIs('darwin'):
++#                
myenv.AddToLINKFLAGSIfSupported('-Wl,-object_path_lto,${TARGET}.lto')
++#            else:
++#                # According to intel benchmarks -fno-plt increases perf
++#                # See PM-2215
++#                if linker_ld != "gold":
++#                    myenv.ConfError("lto compilation currently only works 
with the --linker=gold")
++#                if link_model != "object":
++#                    myenv.ConfError(
++#                        "lto compilation currently only works with the 
--link-model=object")
++#                if not myenv.AddToCCFLAGSIfSupported('-fno-plt') or \
++#                    not myenv.AddToLINKFLAGSIfSupported('-fno-plt'):
++#                    myenv.ConfError("-fno-plt is not supported by the 
compiler")
++#
++#        else:
++#            myenv.ConfError("Don't know how to enable --lto on current 
toolchain")
+ 
+     if get_option('runtime-hardening') == "on" and optBuild != "off":
+         # Older glibc doesn't work well with _FORTIFY_SOURCE=2. Selecting 
2.11 as the minimum was an
+@@ -5263,16 +5265,17 @@ def doConfigure(myenv):
+         "BOOST_LOG_NO_SHORTHAND_NAMES",
+         "BOOST_LOG_USE_NATIVE_SYSLOG",
+         "BOOST_LOG_WITHOUT_THREAD_ATTR",
++        "BOOST_LOG_DYN_LINK",
+         "BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS",
+         "BOOST_SYSTEM_NO_DEPRECATED",
+         "BOOST_THREAD_USES_DATETIME",
+         ("BOOST_THREAD_VERSION", "5"),
+     ])
+ 
+-    if link_model.startswith("dynamic") and not link_model == 'dynamic-sdk':
+-        conf.env.AppendUnique(CPPDEFINES=[
+-            "BOOST_LOG_DYN_LINK",
+-        ])
++#    if link_model.startswith("dynamic") and not link_model == 'dynamic-sdk':
++#        conf.env.AppendUnique(CPPDEFINES=[
++#            "BOOST_LOG_DYN_LINK",
++#        ])
+ 
+     if use_system_version_of_library("boost"):
+         if not conf.CheckCXXHeader("boost/filesystem/operations.hpp"):
+@@ -5473,6 +5476,8 @@ def doConfigure(myenv):
+ 
+     mongoc_mode = get_option('use-system-mongo-c')
+     conf.env['MONGO_HAVE_LIBMONGOC'] = False
++    # conf.env.ParseConfig('pkg-config libbson-1.0 libmongoc-1.0 --cflags')
++    # conf.env['LIBDEPS_LIBBSON_SYSLIBDEP'] = 'bson-1.0'
+     if mongoc_mode != 'off':
+         if conf.CheckLibWithHeader(
+             ["mongoc-1.0"],

diff --git a/dev-db/mongodb/mongodb-7.0.18.ebuild 
b/dev-db/mongodb/mongodb-7.0.18.ebuild
new file mode 100644
index 000000000000..32c42f584768
--- /dev/null
+++ b/dev-db/mongodb/mongodb-7.0.18.ebuild
@@ -0,0 +1,206 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+PYTHON_COMPAT=( python3_{11..13} )
+
+SCONS_MIN_VERSION="3.3.1"
+CHECKREQS_DISK_BUILD="2400M"
+CHECKREQS_DISK_USR="512M"
+CHECKREQS_MEMORY="1024M"
+
+inherit check-reqs eapi9-ver flag-o-matic multiprocessing pax-utils 
python-any-r1 scons-utils systemd toolchain-funcs
+
+MY_PV=r${PV/_rc/-rc}
+MY_P=mongo-${MY_PV}
+
+DESCRIPTION="A high-performance, open source, schema-free document-oriented 
database"
+HOMEPAGE="https://www.mongodb.com";
+SRC_URI="https://github.com/mongodb/mongo/archive/refs/tags/${MY_PV}.tar.gz -> 
${P}.gh.tar.gz"
+S="${WORKDIR}/${MY_P}"
+
+LICENSE="Apache-2.0 SSPL-1"
+SLOT="0"
+KEYWORDS="~amd64 ~arm64 -riscv"
+CPU_FLAGS="cpu_flags_x86_avx"
+IUSE="debug kerberos mongosh ssl +tools ${CPU_FLAGS}"
+
+# https://github.com/mongodb/mongo/wiki/Test-The-Mongodb-Server
+# resmoke needs python packages not yet present in Gentoo
+RESTRICT="test"
+
+RDEPEND="acct-group/mongodb
+       acct-user/mongodb
+       >=app-arch/snappy-1.1.7:=
+       app-arch/zstd:=
+       >=dev-cpp/yaml-cpp-0.6.2:=
+       dev-libs/boost:=[nls]
+       >=dev-libs/libpcre-8.42[cxx]
+       dev-libs/snowball-stemmer:=
+       net-misc/curl
+       dev-libs/libbson
+       dev-libs/mongo-c-driver
+       >=sys-libs/zlib-1.2.12:=
+       kerberos? ( dev-libs/cyrus-sasl[kerberos] )
+       ssl? (
+               >=dev-libs/openssl-1.0.1g:0=
+       )"
+DEPEND="${RDEPEND}
+       ${PYTHON_DEPS}
+       sys-libs/ncurses:0=
+       sys-libs/readline:0=
+       debug? ( dev-debug/valgrind )"
+BDEPEND="
+       $(python_gen_any_dep '
+               >=dev-build/scons-3.1.1[${PYTHON_USEDEP}]
+               dev-python/cheetah3[${PYTHON_USEDEP}]
+               dev-python/psutil[${PYTHON_USEDEP}]
+               dev-python/pyyaml[${PYTHON_USEDEP}]
+               dev-python/pymongo[${PYTHON_USEDEP}]
+       ')
+"
+PDEPEND="
+       mongosh? ( app-admin/mongosh-bin )
+       tools? ( >=app-admin/mongo-tools-100 )
+"
+
+PATCHES=(
+       "${FILESDIR}/mongodb-4.4.29-no-enterprise.patch"
+       "${FILESDIR}/${PN}-5.0.2-no-compass.patch"
+       "${FILESDIR}/${PN}-5.0.2-skip-reqs-check.patch"
+       "${FILESDIR}/${PN}-4.4.10-boost-1.81.patch"
+       "${FILESDIR}/${PN}-7.0.1-sconstruct.patch"
+       "${FILESDIR}/extrapatch-sconstruct.patch"
+       "${FILESDIR}/mongodb-7.0.18-boost-1.85.patch"
+)
+
+python_check_deps() {
+       python_has_version -b ">=dev-build/scons-3.1.1[${PYTHON_USEDEP}]" &&
+       python_has_version -b "dev-python/cheetah3[${PYTHON_USEDEP}]" &&
+       python_has_version -b "dev-python/psutil[${PYTHON_USEDEP}]" &&
+       python_has_version -b "dev-python/pyyaml[${PYTHON_USEDEP}]"
+       python_has_version -b "dev-python/pymongo[${PYTHON_USEDEP}]"
+}
+
+pkg_pretend() {
+       # Bug 809692 + 890294
+       if use amd64 && ! use cpu_flags_x86_avx; then
+               ewarn "MongoDB 5.0 requires use of the AVX instruction set."
+               ewarn "This ebuild will use 
--experimental-optimization=-sandybridge which"
+               ewarn "will result in an experimental build of MongoDB as per 
upstream."
+               ewarn 
"https://docs.mongodb.com/v5.0/administration/production-notes/";
+       fi
+
+       if [[ -n ${REPLACING_VERSIONS} ]]; then
+               if ver_replacing -lt 4.4; then
+                       ewarn "To upgrade from a version earlier than the 
4.4-series, you must"
+                       ewarn "successively upgrade major releases until you 
have upgraded"
+                       ewarn "to 4.4-series. Then upgrade to 5.0 series."
+               else
+                       ewarn "Be sure to set featureCompatibilityVersion to 
4.4 before upgrading."
+               fi
+       fi
+}
+
+src_prepare() {
+       default
+
+       # remove bundled libs
+       rm -r src/third_party/{boost,snappy-*,yaml-cpp} || die
+
+       # remove compass
+       rm -r src/mongo/installer/compass || die
+}
+
+src_configure() {
+       # https://github.com/mongodb/mongo/wiki/Build-Mongodb-From-Source
+       # --use-system-icu fails tests
+       # --use-system-tcmalloc is strongly NOT recommended:
+       # for MONGO_GIT_HASH use GitOrigin-RevId from the commit of the tag
+       scons_opts=(
+               AR="$(tc-getAR)"
+               CC="$(tc-getCC)"
+               CXX="$(tc-getCXX)"
+               CCFLAGS="${CXXFLAGS}"
+
+               VERBOSE=1
+               VARIANT_DIR=gentoo
+               MONGO_VERSION="${PV}"
+               MONGO_GIT_HASH="966efda23d779a86c76c34e1b13e561d68f2bb37"
+
+               --disable-warnings-as-errors
+               --force-jobs # Reapply #906897, fix #935274
+               --jobs="$(makeopts_jobs)"
+               --use-system-boost
+               --use-system-snappy
+               --use-system-stemmer
+               --use-system-yaml
+               --use-system-zlib
+               --use-system-zstd
+       )
+
+       use arm64 && scons_opts+=( --use-hardware-crc32=off ) # Bug 701300
+       use amd64 && scons_opts+=( --experimental-optimization=-sandybridge ) # 
Bug 890294
+       use debug && scons_opts+=( --dbg=on )
+       use kerberos && scons_opts+=( --use-sasl-client )
+
+       scons_opts+=( --ssl=$(usex ssl on off) )
+
+       # Needed to avoid forcing FORTIFY_SOURCE
+       # Gentoo's toolchain applies these anyway
+       scons_opts+=( --runtime-hardening=off )
+
+       # gold is an option here but we don't really do that anymore
+       if tc-ld-is-lld; then
+                scons_opts+=( --linker=lld )
+       else
+                scons_opts+=( --linker=bfd )
+       fi
+
+       # respect mongoDB upstream's basic recommendations
+       # see bug #536688 and #526114
+       if ! use debug; then
+               filter-flags '-m*'
+               filter-flags '-O?'
+       fi
+
+       default
+}
+
+src_compile() {
+       PREFIX="${EPREFIX}/usr" ./buildscripts/scons.py "${scons_opts[@]}" 
install-devcore || die
+}
+
+src_install() {
+       dobin build/install/bin/{mongo,mongod,mongos}
+
+       doman debian/mongo*.1
+       dodoc docs/building.md
+
+       newinitd "${FILESDIR}/${PN}.initd-r3" ${PN}
+       newconfd "${FILESDIR}/${PN}.confd-r3" ${PN}
+       newinitd "${FILESDIR}/mongos.initd-r3" mongos
+       newconfd "${FILESDIR}/mongos.confd-r3" mongos
+
+       insinto /etc
+       newins "${FILESDIR}/${PN}.conf-r3" ${PN}.conf
+       newins "${FILESDIR}/mongos.conf-r2" mongos.conf
+
+       systemd_newunit "${FILESDIR}/${PN}.service-r1" "${PN}.service"
+
+       insinto /etc/logrotate.d/
+       newins "${FILESDIR}/${PN}.logrotate" ${PN}
+
+       # see bug #526114
+       pax-mark emr "${ED}"/usr/bin/{mongo,mongod,mongos}
+
+       diropts -m0750 -o mongodb -g mongodb
+       keepdir /var/log/${PN}
+}
+
+pkg_postinst() {
+       ewarn "Make sure to read the release notes and follow the upgrade 
process:"
+       ewarn "  https://docs.mongodb.com/manual/release-notes/$(ver_cut 1-2)/"
+       ewarn "  https://docs.mongodb.com/manual/release-notes/$(ver_cut 
1-2)/#upgrade-procedures"
+}


Reply via email to