]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
build-with-container.py: Add --ceph-version
authorZack Cerza <zack@cerza.org>
Thu, 13 Feb 2025 00:10:23 +0000 (17:10 -0700)
committerKamoltat Sirivadhna <ksirivad@redhat.com>
Fri, 10 Oct 2025 18:30:30 +0000 (18:30 +0000)
So that we can build from an extracted tarball, as opposed to a git repo.

Signed-off-by: Zack Cerza <zack@cerza.org>
(cherry picked from commit 800f5c2924dfd88292fbd483b881f25d15bbc928)
(cherry picked from commit b4a5187c822540c70cd206af2cc34e51d61451fd)

src/script/build-with-container.py

index b813ee9ba52eb171a016a02b0e6f24d0df72db80..ee3791170309c283b8bf8feaa6812f5dcc391168 100755 (executable)
@@ -73,6 +73,7 @@ import glob
 import logging
 import os
 import pathlib
+import re
 import shlex
 import shutil
 import subprocess
@@ -597,12 +598,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():
@@ -614,8 +618,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(
@@ -853,6 +870,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",