SERVER-108027: adjust packaging script for 8.2 (#38964)

GitOrigin-RevId: d1e86f7010554951f740b6b0c91a2c2a15d9b050
This commit is contained in:
Dylan Richardson 2025-07-23 12:38:09 -05:00 committed by MongoDB Bot
parent 0288d3d9f0
commit 7b3641a16d
3 changed files with 72 additions and 9 deletions

View File

@ -48,6 +48,21 @@ ARCH_CHOICES = ["x86_64", "arm64", "aarch64", "s390x"]
# Made up names for the flavors of distribution we package for.
DISTROS = ["suse", "debian", "redhat", "ubuntu", "amazon", "amazon2", "amazon2023"]
unexpected_lts_release_series = ("8.2",)
def get_suffix(version, stable_name: str, unstable_name: str) -> str:
parts = version.split(".")
major = int(parts[0])
minor = int(parts[1])
series = f"{major}.{minor}"
if major >= 5:
is_stable_version = (minor == 0 or series in unexpected_lts_release_series)
return stable_name if is_stable_version else unstable_name
else:
return stable_name if minor % 2 == 0 else unstable_name
class Spec(object):
"""Spec class."""
@ -104,12 +119,9 @@ class Spec(object):
# e.g., "1.8.2" < "1.8.10", "1.8.2" < "1.8.2-rc1"
return self.ver > version_string
def suffix(self):
def suffix(self) -> str:
"""Return suffix."""
if int(self.ver.split(".")[0]) >= 5:
return "-org" if int(self.ver.split(".")[1]) == 0 else "-org-unstable"
else:
return "-org" if int(self.ver.split(".")[1]) % 2 == 0 else "-org-unstable"
return get_suffix(self.ver, "-org", "-org-unstable")
def prelease(self):
"""Return pre-release verison suffix."""

View File

@ -54,11 +54,8 @@ class EnterpriseSpec(packager.Spec):
"""EnterpriseSpec class."""
def suffix(self):
return packager.get_suffix(self.ver, "-enterprise", "-enterprise-unstable")
"""Suffix."""
if int(self.ver.split(".")[0]) >= 5:
return "-enterprise" if int(self.ver.split(".")[1]) == 0 else "-enterprise-unstable"
else:
return "-enterprise" if int(self.ver.split(".")[1]) % 2 == 0 else "-enterprise-unstable"
def move_required_contents(self):
"""Move the required contents to the current working directory.

View File

@ -47,3 +47,57 @@ class TestPackager(TestCase):
with self.subTest(name=case.name):
spec = Spec(ver=case.version)
self.assertEqual(spec.is_nightly(), case.want)
def test_community_suffix(self) -> None:
"""Test community suffix"""
@dataclass
class Case:
"""Test case data."""
name: str
version: str
want: str
cases = [
Case(
name="Old unstable",
version="4.3.0",
want="-org-unstable"
),
Case(
name="Old stable 4.2",
version="4.2.0",
want="-org"
),
Case(
name="Old stable 4.4",
version="4.4.0",
want="-org"
),
Case(
name="New stable standard",
version="8.0.0",
want="-org",
),
Case(
name="New unstable standard 8.1",
version="8.1.0",
want="-org-unstable",
),
Case(
name="New unstable standard 7.2",
version="7.2.0",
want="-org-unstable",
),
Case(
name="New stable special case",
version="8.2.0",
want="-org",
),
]
for case in cases:
with self.subTest(name=case.name):
spec = Spec(ver=case.version)
self.assertEqual(spec.suffix(), case.want)