]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
script/build-with-container: add a common packages target
authorJohn Mulligan <jmulligan@redhat.com>
Fri, 14 Feb 2025 19:50:42 +0000 (14:50 -0500)
committerJohn Mulligan <jmulligan@redhat.com>
Thu, 6 Mar 2025 21:14:27 +0000 (16:14 -0500)
Add a `packages` target to build-with-container.py that requests a build
of packages, whatever package type is native to the distro selected.
For example `./src/script/build-with-container.py -d ubuntu22.04 -e
packages` will automatically select a deb packages build where
`./src/script/build-with-container.py -d centos9 -e packages` will
trigger rpm packages to be built. The underlying package-type specific
targets remain unchanged.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
(cherry picked from commit 37b7d509c59348ae11badd6673cb49ce9ce303fa)

src/script/build-with-container.py

index 32f4d37088f0bff58a3663e4b2b8414a9ab03ce3..f03ef013686adf92b23b5dc3e648d7c5322e560f 100755 (executable)
@@ -102,6 +102,12 @@ class DistroKind(StrEnum):
     def uses_dnf(cls):
         return {cls.CENTOS8, cls.CENTOS9, cls.CENTOS10, cls.FEDORA41}
 
+    @classmethod
+    def uses_rpmbuild(cls):
+        # right now this is the same as uses_dnf, but perhaps not always
+        # let's be specific in our interface
+        return cls.uses_dnf()  # but lazy in the implementation
+
     @classmethod
     def aliases(cls):
         return {
@@ -231,6 +237,7 @@ class Steps(StrEnum):
     SOURCE_RPM = "source-rpm"
     RPM = "rpm"
     DEBS = "debs"
+    PACKAGES = "packages"
     INTERACTIVE = "interactive"
 
 
@@ -600,6 +607,15 @@ def bc_make_debs(ctx):
         _run(cmd, check=True, ctx=ctx)
 
 
+@Builder.set(Steps.PACKAGES)
+def bc_make_packages(ctx):
+    """Build some sort of distro packages - chooses target based on distro."""
+    if ctx.cli.distro in DistroKind.uses_rpmbuild():
+        ctx.build.wants(Steps.RPM, ctx)
+    else:
+        ctx.build.wants(Steps.DEBS, ctx)
+
+
 @Builder.set(Steps.CUSTOM)
 def bc_custom(ctx):
     """Run a custom build command."""