]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
script/cpatch.py: add a --run-before argument to run commands
authorJohn Mulligan <jmulligan@redhat.com>
Wed, 27 Mar 2024 18:30:01 +0000 (14:30 -0400)
committerJohn Mulligan <jmulligan@redhat.com>
Wed, 27 Mar 2024 18:30:01 +0000 (14:30 -0400)
Add a `--run-before` command line argument to cpatch.py that allows
commands to be executed before doing any other layer generation.
This supports actions like customizing packages installed in the
image. Something that can be handy when developing new features.

Signed-off-by: John Mulligan <jmulligan@redhat.com>
src/script/cpatch.py

index b22cbb4f7e621c41149ddb96e777015ffb8f6679..1dfb51347951781c8b8924209c909b50b6a90d87 100755 (executable)
@@ -221,6 +221,10 @@ class CLIContext:
     def cephadm_build_args(self):
         return list(self._cli.cephadm_build_arg or [])
 
+    @property
+    def run_before_commands(self):
+        return list(self._cli.run_before or [])
+
     def build_components(self):
         if self._cli.components:
             return self._cli.components
@@ -315,6 +319,11 @@ class CLIContext:
             action="append",
             help="Pass additional arguments to cephadm build script.",
         )
+        parser.add_argument(
+            "--run-before",
+            action="append",
+            help="Add a RUN command before other actions"
+        )
         # selectors
         component_selections = [
             # aggregated components:
@@ -441,6 +450,8 @@ class Builder:
     def build(self):
         """Build the container image."""
         dlines = [f"FROM {self._ctx.base_image}"]
+        for cmd in self._ctx.run_before_commands:
+            dlines.append(f'RUN {cmd}')
         jcount = len(self._jobs)
         for idx, (component, job) in enumerate(self._jobs):
             num = idx + 1