From: Zack Cerza Date: Thu, 13 Feb 2025 00:10:23 +0000 (-0700) Subject: build-with-container.py: Add --ceph-version X-Git-Tag: v20.3.0~437^2~2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=800f5c2924dfd88292fbd483b881f25d15bbc928;p=ceph.git build-with-container.py: Add --ceph-version So that we can build from an extracted tarball, as opposed to a git repo. Signed-off-by: Zack Cerza --- diff --git a/src/script/build-with-container.py b/src/script/build-with-container.py index 5f8fcd489466e..2a0cb43818eec 100755 --- a/src/script/build-with-container.py +++ b/src/script/build-with-container.py @@ -73,6 +73,7 @@ import glob import logging import os import pathlib +import re import shlex import shutil import subprocess @@ -582,12 +583,15 @@ def bc_run_tests(ctx): def bc_make_source_rpm(ctx): """Build SPRMs.""" ctx.build.wants(Steps.CONTAINER, ctx) + make_srpm_cmd = f"cd {ctx.cli.homedir} && ./make-srpm.sh" + if ctx.cli.ceph_version: + make_srpm_cmd = f"{make_srpm_cmd} {ctx.cli.ceph_version}" cmd = _container_cmd( ctx, [ "bash", "-c", - f"cd {ctx.cli.homedir} && ./make-srpm.sh", + make_srpm_cmd, ], ) with ctx.user_command(): @@ -599,8 +603,21 @@ def bc_build_rpm(ctx): """Build RPMs from SRPM.""" srpm_glob = "ceph*.src.rpm" if ctx.cli.rpm_match_sha: - head_sha = _git_current_sha(ctx) - srpm_glob = f"ceph*.g{head_sha}.*.src.rpm" + if not ctx.cli.ceph_version: + head_sha = _git_current_sha(ctx) + srpm_glob = f"ceph*.g{head_sha}.*.src.rpm" + else: + # Given a tarball with a name like + # ceph-19.3.0-7462-g565e5c65.tar.bz2 + # The SRPM name would be: + # ceph-19.3.0-7462.g565e5c65.el9.src.rpm + # This regex replaces the second '-' with a '.' + srpm_version = re.sub( + r"(\d+\.\d+\.\d+-\d+)-(.*)", + r"\1.\2", + ctx.cli.ceph_version + ) + srpm_glob = f"ceph-{srpm_version}.*.src.rpm" paths = glob.glob(srpm_glob) if len(paths) > 1: raise RuntimeError( @@ -838,6 +855,10 @@ def parse_cli(build_step_names): " git checkout. Use any source RPM available." ), ) + parser.add_argument( + "--ceph-version", + help="Rather than infer the Ceph version, use this value", + ) parser.add_argument( "--execute", "-e",