From ed48018546b93922b5a9f28426200ded8d46fa36 Mon Sep 17 00:00:00 2001 From: John Mulligan Date: Wed, 27 Mar 2024 14:30:01 -0400 Subject: [PATCH] script/cpatch.py: add a --run-before argument to run commands 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 --- src/script/cpatch.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/script/cpatch.py b/src/script/cpatch.py index b22cbb4f7e6..1dfb5134795 100755 --- a/src/script/cpatch.py +++ b/src/script/cpatch.py @@ -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 -- 2.39.5