SERVER-108655 Use our own architectures for naming the top level folder in release packages (#39564)
GitOrigin-RevId: 322f362ecc205ffd8e0f04b9015d0a4e4d911574
This commit is contained in:
parent
d33d09a301
commit
f9112b417e
2
.bazelrc
2
.bazelrc
@ -530,7 +530,7 @@ try-import %workspace%/.bazelrc.evergreen
|
||||
try-import %workspace%/.bazelrc.common_bes
|
||||
|
||||
# local default dev settings
|
||||
try-import %workspace%/.bazelrc.mongo_version
|
||||
try-import %workspace%/.bazelrc.mongo_variables
|
||||
|
||||
# local git version info
|
||||
try-import %workspace%/.bazelrc.git
|
||||
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@ -292,6 +292,7 @@ buildozer
|
||||
.bazelrc.gitinfo
|
||||
.bazelrc.workstation
|
||||
.bazelrc.common_bes
|
||||
.bazelrc.mongo_variables
|
||||
.bazelrc.mongo_version
|
||||
.bazelrc.compiledb
|
||||
.bazelrc.sync
|
||||
|
||||
14
BUILD.bazel
14
BUILD.bazel
@ -220,13 +220,13 @@ mongo_install(
|
||||
"//conditions:default": ["//src/mongo/db:mongod"],
|
||||
}),
|
||||
package_extract_name = select({
|
||||
"//bazel/config:build_enterprise_linux_enabled": "mongodb-linux-{TARGET_CPU}-enterprise-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
"//bazel/config:build_enterprise_linux_disabled": "mongodb-linux-{TARGET_CPU}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
"//bazel/config:build_enterprise_windows_enabled": "mongodb-win32-{TARGET_CPU}-enterprise-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
"//bazel/config:build_enterprise_windows_disabled": "mongodb-win32-{TARGET_CPU}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
"//bazel/config:build_enterprise_mac_enabled": "mongodb-macos-{TARGET_CPU}-enterprise-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
"//bazel/config:build_enterprise_mac_disabled": "mongodb-macos-{TARGET_CPU}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
"//conditions:default": "mongodb-{TARGET_CPU}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
"//bazel/config:build_enterprise_linux_enabled": "mongodb-linux-{MONGO_ARCH}-enterprise-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
"//bazel/config:build_enterprise_linux_disabled": "mongodb-linux-{MONGO_ARCH}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
"//bazel/config:build_enterprise_windows_enabled": "mongodb-win32-{MONGO_ARCH}-enterprise-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
"//bazel/config:build_enterprise_windows_disabled": "mongodb-win32-{MONGO_ARCH}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
"//bazel/config:build_enterprise_mac_enabled": "mongodb-macos-{MONGO_ARCH}-enterprise-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
"//bazel/config:build_enterprise_mac_disabled": "mongodb-macos-{MONGO_ARCH}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
"//conditions:default": "mongodb-{MONGO_ARCH}-{MONGO_DISTMOD}-{MONGO_VERSION}",
|
||||
}),
|
||||
publish_debug_in_stripped = select({
|
||||
"@platforms//os:windows": True,
|
||||
|
||||
@ -10,7 +10,7 @@ py_library(
|
||||
"install_modules.py",
|
||||
"lint.py",
|
||||
"plus_interface.py",
|
||||
"set_mongo_version.py",
|
||||
"set_mongo_variables.py",
|
||||
"wrapper_debug.py",
|
||||
"wrapper_hook.py",
|
||||
],
|
||||
|
||||
@ -11,7 +11,7 @@ import sys
|
||||
REPO_ROOT = pathlib.Path(__file__).parent.parent.parent
|
||||
sys.path.append(str(REPO_ROOT))
|
||||
|
||||
from bazel.wrapper_hook.set_mongo_version import write_mongo_version_bazelrc
|
||||
from bazel.wrapper_hook.set_mongo_variables import write_mongo_variables_bazelrc
|
||||
|
||||
|
||||
def run_pty_command(cmd):
|
||||
@ -47,7 +47,7 @@ def run_pty_command(cmd):
|
||||
def generate_compiledb(bazel_bin, persistent_compdb, enterprise):
|
||||
|
||||
# compiledb ignores command line args so just make a version rc file in anycase
|
||||
write_mongo_version_bazelrc([])
|
||||
write_mongo_variables_bazelrc([])
|
||||
if persistent_compdb:
|
||||
info_proc = subprocess.run(
|
||||
[bazel_bin, "info", "output_base"], capture_output=True, text=True
|
||||
|
||||
45
bazel/wrapper_hook/set_mongo_variables.py
Normal file
45
bazel/wrapper_hook/set_mongo_variables.py
Normal file
@ -0,0 +1,45 @@
|
||||
import hashlib
|
||||
import os
|
||||
import pathlib
|
||||
import platform
|
||||
import subprocess
|
||||
|
||||
ARCH_NORMALIZE_MAP = {
|
||||
"amd64": "x86_64",
|
||||
"x86_64": "x86_64",
|
||||
"arm64": "aarch64",
|
||||
"aarch64": "aarch64",
|
||||
"ppc64le": "ppc64le",
|
||||
"s390x": "s390x",
|
||||
}
|
||||
|
||||
def get_mongo_arch(args):
|
||||
arch = platform.machine().lower()
|
||||
if arch in ARCH_NORMALIZE_MAP:
|
||||
return ARCH_NORMALIZE_MAP[arch]
|
||||
else:
|
||||
return arch
|
||||
|
||||
def get_mongo_version(args):
|
||||
proc = subprocess.run(["git", "describe", "--abbrev=0"], capture_output=True, text=True)
|
||||
return proc.stdout.strip()[1:]
|
||||
|
||||
def write_mongo_variables_bazelrc(args):
|
||||
mongo_version = get_mongo_version(args)
|
||||
mongo_arch = get_mongo_arch(args)
|
||||
|
||||
repo_root = pathlib.Path(os.path.abspath(__file__)).parent.parent.parent
|
||||
version_file = os.path.join(repo_root, ".bazelrc.mongo_variables")
|
||||
existing_hash = ""
|
||||
if os.path.exists(version_file):
|
||||
with open(version_file, encoding="utf-8") as f:
|
||||
existing_hash = hashlib.md5(f.read().encode()).hexdigest()
|
||||
|
||||
bazelrc_contents = f"""
|
||||
common --define=MONGO_ARCH={mongo_arch}
|
||||
common --define=MONGO_VERSION={mongo_version}
|
||||
"""
|
||||
current_hash = hashlib.md5(bazelrc_contents.encode()).hexdigest()
|
||||
if existing_hash != current_hash:
|
||||
with open(version_file, "w", encoding="utf-8") as f:
|
||||
f.write(bazelrc_contents)
|
||||
@ -1,29 +0,0 @@
|
||||
import hashlib
|
||||
import os
|
||||
import pathlib
|
||||
import subprocess
|
||||
|
||||
|
||||
def write_mongo_version_bazelrc(args):
|
||||
|
||||
# quick return don't waste time if set on command line
|
||||
if any(["MONGO_VERSION" in arg for arg in args]):
|
||||
return
|
||||
|
||||
|
||||
repo_root = pathlib.Path(os.path.abspath(__file__)).parent.parent.parent
|
||||
version_file = os.path.join(repo_root, ".bazelrc.mongo_version")
|
||||
existing_hash = ""
|
||||
if os.path.exists(version_file):
|
||||
with open(version_file, encoding="utf-8") as f:
|
||||
existing_hash = hashlib.md5(f.read().encode()).hexdigest()
|
||||
|
||||
|
||||
proc = subprocess.run(["git", "describe", "--abbrev=0"], capture_output=True, text=True)
|
||||
bazelrc_contents = f"""
|
||||
common --define=MONGO_VERSION={proc.stdout.strip()[1:]}
|
||||
"""
|
||||
current_hash = hashlib.md5(bazelrc_contents.encode()).hexdigest()
|
||||
if existing_hash != current_hash:
|
||||
with open(version_file, "w", encoding="utf-8") as f:
|
||||
f.write(bazelrc_contents)
|
||||
@ -22,7 +22,7 @@ def main():
|
||||
from bazel.wrapper_hook.engflow_check import engflow_auth
|
||||
from bazel.wrapper_hook.generate_common_bes_bazelrc import write_workstation_bazelrc
|
||||
from bazel.wrapper_hook.plus_interface import check_bazel_command_type, test_runner_interface
|
||||
from bazel.wrapper_hook.set_mongo_version import write_mongo_version_bazelrc
|
||||
from bazel.wrapper_hook.set_mongo_variables import write_mongo_variables_bazelrc
|
||||
|
||||
# This is used to autogenerate a BUILD.bazel that creates
|
||||
# Filegroups for select tags - used to group targets for installing
|
||||
@ -47,7 +47,7 @@ def main():
|
||||
|
||||
write_workstation_bazelrc(args)
|
||||
|
||||
write_mongo_version_bazelrc(args)
|
||||
write_mongo_variables_bazelrc(args)
|
||||
|
||||
args = test_runner_interface(
|
||||
sys.argv[1:],
|
||||
|
||||
@ -249,6 +249,16 @@ VERSIONS_TO_SKIP: Set[str] = set(
|
||||
)
|
||||
DISABLED_TESTS: Set[Tuple[str, str]] = set()
|
||||
|
||||
VALID_TAR_DIRECTORY_ARCHITECTURES = [
|
||||
"linux-aarch64",
|
||||
"linux-x86_64",
|
||||
"linux-ppc64le",
|
||||
"linux-s390x",
|
||||
"macos-aarch64",
|
||||
"macos-x86_64",
|
||||
"windows-x86_64",
|
||||
]
|
||||
|
||||
|
||||
@dataclasses.dataclass
|
||||
class Test:
|
||||
@ -523,6 +533,12 @@ def get_edition_alias(edition_name: str) -> str:
|
||||
return "org"
|
||||
return edition_name
|
||||
|
||||
def validate_top_level_directory(tar_name: str):
|
||||
command = f"tar -tf {tar_name} | head -n 1 | awk -F/ '{{print $1}}'"
|
||||
proc = subprocess.run(command, capture_output=True, shell=True, text=True)
|
||||
top_level_directory = proc.stdout.strip()
|
||||
if all(os_arch not in top_level_directory for os_arch in VALID_TAR_DIRECTORY_ARCHITECTURES):
|
||||
raise Exception(f"Found an unexpected os-arch pairing as the top level directory. Top level directory: {top_level_directory}")
|
||||
|
||||
arches: Set[str] = set()
|
||||
oses: Set[str] = set()
|
||||
@ -663,6 +679,8 @@ if args.command == "branch":
|
||||
)
|
||||
)
|
||||
|
||||
validate_top_level_directory("mongo-binaries.tgz")
|
||||
|
||||
if not args.skip_enterprise_check:
|
||||
logging.info(
|
||||
"Checking the source files used to build the binaries, use --skip-enterprise-check to skip this check."
|
||||
|
||||
Loading…
Reference in New Issue
Block a user