summaryrefslogtreecommitdiff
path: root/buildscripts/generate_compile_expansions_shared_cache.py
diff options
context:
space:
mode:
authorLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
committerLucas de Castro Borges <lucas@gnuabordo.com.br>2025-02-11 15:07:35 -0300
commit4cb8841196d0625dfa3825aa326f071cd27c7b8b (patch)
tree1682a647d4463397c119183369ae6f750d5fdcff /buildscripts/generate_compile_expansions_shared_cache.py
parentaa03c6362cbaa767638e6eed9b031d86dd2643d1 (diff)
parent8f0827553e09872941945a093b647a4211a9db7f (diff)
Update upstream source from tag 'upstream/6.0.0'master
Update to upstream version '6.0.0' with Debian dir 5604a80ec1c96ca76f25f40d78e6ef855abec322
Diffstat (limited to 'buildscripts/generate_compile_expansions_shared_cache.py')
-rwxr-xr-xbuildscripts/generate_compile_expansions_shared_cache.py54
1 files changed, 53 insertions, 1 deletions
diff --git a/buildscripts/generate_compile_expansions_shared_cache.py b/buildscripts/generate_compile_expansions_shared_cache.py
index 5b6183fa6d9..1f9fea582dd 100755
--- a/buildscripts/generate_compile_expansions_shared_cache.py
+++ b/buildscripts/generate_compile_expansions_shared_cache.py
@@ -7,7 +7,9 @@ $ python generate_compile_expansions.py --out compile_expansions.yml
"""
import argparse
+import json
import os
+import re
import sys
import shlex
import yaml
@@ -23,6 +25,7 @@ def generate_expansions():
"""
args = parse_args()
expansions = {}
+ expansions.update(generate_version_expansions())
expansions.update(generate_scons_cache_expansions())
with open(args.out, "w") as out:
@@ -37,6 +40,39 @@ def parse_args():
return parser.parse_args()
+def generate_version_expansions():
+ """Generate expansions from a version.json file if given, or $MONGO_VERSION."""
+ expansions = {}
+
+ if os.path.exists(VERSION_JSON):
+ with open(VERSION_JSON, "r") as fh:
+ data = fh.read()
+ version_data = json.loads(data)
+ version_line = version_data['version']
+ version_parts = match_verstr(version_line)
+ if not version_parts:
+ raise ValueError("Unable to parse version.json")
+ else:
+ if not os.getenv("MONGO_VERSION"):
+ raise Exception("$MONGO_VERSION not set and no version.json provided")
+ version_line = os.getenv("MONGO_VERSION").lstrip("r")
+ version_parts = match_verstr(version_line)
+ if not version_parts:
+ raise ValueError("Unable to parse version from stdin and no version.json provided")
+
+ if version_parts[0]:
+ expansions["suffix"] = "v6.0-latest"
+ expansions["src_suffix"] = "v6.0-latest"
+ expansions["is_release"] = "false"
+ else:
+ expansions["suffix"] = version_line
+ expansions["src_suffix"] = "r{0}".format(version_line)
+ expansions["is_release"] = "true"
+ expansions["version"] = version_line
+
+ return expansions
+
+
def generate_scons_cache_expansions():
"""Generate scons cache expansions from some files and environment variables."""
expansions = {}
@@ -61,7 +97,7 @@ def generate_scons_cache_expansions():
if sys.platform.startswith("win"):
shared_mount_root = 'X:\\'
else:
- shared_mount_root = '/efs/scons'
+ shared_mount_root = '/efs'
default_cache_path = os.path.join(shared_mount_root, system_uuid, "scons-cache")
expansions["scons_cache_path"] = default_cache_path
expansions[
@@ -89,5 +125,21 @@ def generate_scons_cache_expansions():
return expansions
+def match_verstr(verstr):
+ """Match a version string and capture the "extra" part.
+
+ If the version is a release like "2.3.4" or "2.3.4-rc0", this will return
+ None. If the version is a pre-release like "2.3.4-325-githash" or
+ "2.3.4-pre-", this will return "-pre-" or "-325-githash" If the version
+ begins with the letter 'r', it will also match, e.g. r2.3.4, r2.3.4-rc0,
+ r2.3.4-git234, r2.3.4-rc0-234-githash If the version is invalid (i.e.
+ doesn't start with "2.3.4" or "2.3.4-rc0", this will return False.
+ """
+ res = re.match(r'^r?(?:\d+\.\d+\.\d+(?:-rc\d+|-alpha\d+)?)(-.*)?', verstr)
+ if not res:
+ return False
+ return res.groups()
+
+
if __name__ == "__main__":
generate_expansions()