]> git.apps.os.sepia.ceph.com Git - ceph.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)
committerDavid Galloway <david.galloway@ibm.com>
Thu, 31 Jul 2025 21:14:53 +0000 (17:14 -0400)
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)

src/script/build-with-container.py

index cac82c362775ac18f16f34320207558a3e033bbf..b99c3c94e77b1b48f4c8ca7280970a51abeab8a5 100755 (executable)
@@ -73,6 +73,7 @@ import glob
 import logging
 import os
 import pathlib
+import re
 import shlex
 import shutil
 import subprocess
@@ -591,12 +592,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():
@@ -608,8 +612,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(
@@ -851,6 +868,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",