Skip to content

Commit e5c885f

Browse files
authored
Merge pull request ceph#56533 from phlogistonjohn/jjm-cpatch-before
cpatch: add --run-before command line option Reviewed-by: Adam King <[email protected]>
2 parents 00c58c4 + 68f90ad commit e5c885f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/script/cpatch.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ def components_selected(self):
221221
def cephadm_build_args(self):
222222
return list(self._cli.cephadm_build_arg or [])
223223

224+
@property
225+
def run_before_commands(self):
226+
return list(self._cli.run_before or [])
227+
224228
def build_components(self):
225229
if self._cli.components:
226230
return self._cli.components
@@ -315,6 +319,11 @@ def parse(cls):
315319
action="append",
316320
help="Pass additional arguments to cephadm build script.",
317321
)
322+
parser.add_argument(
323+
"--run-before",
324+
action="append",
325+
help="Add a RUN command before other actions"
326+
)
318327
# selectors
319328
component_selections = [
320329
# aggregated components:
@@ -441,6 +450,8 @@ def add(self, component):
441450
def build(self):
442451
"""Build the container image."""
443452
dlines = [f"FROM {self._ctx.base_image}"]
453+
for cmd in self._ctx.run_before_commands:
454+
dlines.append(f'RUN {cmd}')
444455
jcount = len(self._jobs)
445456
for idx, (component, job) in enumerate(self._jobs):
446457
num = idx + 1
@@ -456,8 +467,10 @@ def build(self):
456467
def _container_build(self):
457468
log.info("Building container image")
458469
cmd = [self._ctx.engine, "build", "--tag", self._ctx.target, "."]
470+
cmd.append('--net=host')
459471
if self._ctx.root_build:
460472
cmd.insert(0, "sudo")
473+
log.debug("Container build command: %r", cmd)
461474
_run(cmd, cwd=self._workdir).check_returncode()
462475

463476
def _build_tar(

0 commit comments

Comments
 (0)