Skip to content

Commit 3d863d3

Browse files
authored
Merge pull request ceph#65919 from phlogistonjohn/jjm-bwc-variants
build-with-container: build image variants
2 parents 63d4612 + 04d8e67 commit 3d863d3

File tree

3 files changed

+40
-9
lines changed

3 files changed

+40
-9
lines changed

Dockerfile.build

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ COPY \
1717

1818

1919
FROM $DISTRO
20-
ENV FOR_MAKE_CHECK=1
2120
ARG DISTRO
2221
ARG CEPH_CTR_SRC=/usr/local/src/ceph
2322
ARG CLEAN_DNF=yes
2423
ARG CEPH_BASE_BRANCH=main
2524
ARG SCCACHE_VERSION=v0.8.2
2625
ARG SCCACHE_REPO=https://github.com/mozilla/sccache
2726
ARG WITH_CRIMSON=true
27+
ARG FOR_MAKE_CHECK=1
2828
COPY --from=bootstrap ${CEPH_CTR_SRC} ${CEPH_CTR_SRC}
2929
# Note that we do not use ENV for the following. This is because we do not
3030
# want them permamently stored in the container's layer.
@@ -33,6 +33,7 @@ RUN DISTRO=$DISTRO \
3333
CLEAN_DNF=$CLEAN_DNF \
3434
CEPH_CTR_SRC=${CEPH_CTR_SRC} \
3535
WITH_CRIMSON=${WITH_CRIMSON} \
36+
FOR_MAKE_CHECK=${FOR_MAKE_CHECK} \
3637
bash -x ${CEPH_CTR_SRC}/buildcontainer-setup.sh
3738
RUN \
3839
SCCACHE_URL="${SCCACHE_REPO}/releases/download/${SCCACHE_VERSION}/sccache-${SCCACHE_VERSION}-$(uname -m)-unknown-linux-musl.tar.gz"; \

install-deps.sh

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -320,13 +320,22 @@ function preload_wheels_for_tox() {
320320
}
321321

322322
for_make_check=false
323-
if tty -s; then
323+
if [ "$FOR_MAKE_CHECK" ]; then
324+
case "$FOR_MAKE_CHECK" in
325+
true|1|yes)
326+
for_make_check=true
327+
;;
328+
false|0|no)
329+
for_make_check=false
330+
;;
331+
*)
332+
echo "error: unexpected FOR_MAKE_CHECK value: ${FOR_MAKE_CHECK}"
333+
exit 2
334+
;;
335+
esac
336+
elif tty -s; then
324337
# interactive
325338
for_make_check=true
326-
elif [ $FOR_MAKE_CHECK ]; then
327-
for_make_check=true
328-
else
329-
for_make_check=false
330339
fi
331340

332341
if [ x$(uname)x = xFreeBSDx ]; then

src/script/build-with-container.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,9 @@ def _run(cmd, *args, **kwargs):
237237
return subprocess.run(cmd, *args, **kwargs)
238238

239239

240-
def _container_cmd(ctx, args, *, workdir=None, interactive=False):
240+
def _container_cmd(
241+
ctx, args, *, workdir=None, interactive=False, extra_args=None
242+
):
241243
rm_container = not ctx.cli.keep_container
242244
cmd = [
243245
ctx.container_engine,
@@ -277,8 +279,8 @@ def _container_cmd(ctx, args, *, workdir=None, interactive=False):
277279
)
278280
cmd.append(f"-eCCACHE_DIR={ccdir}")
279281
cmd.append(f"-eCCACHE_BASEDIR={ctx.cli.homedir}")
280-
for extra_arg in ctx.cli.extra or []:
281-
cmd.append(extra_arg)
282+
cmd.extend(extra_args or [])
283+
cmd.extend(ctx.cli.extra or [])
282284
if ctx.npm_cache_dir:
283285
# use :z so that other builds can use the cache
284286
cmd.extend([
@@ -367,6 +369,11 @@ def hint(cls):
367369
return ", ".join(s.value for s in cls)
368370

369371

372+
class ImageVariant(StrEnum):
373+
DEFAULT = 'default' # build everything + make check
374+
PACKAGES = 'packages' # test deps. ignored, only for packages
375+
376+
370377
class Context:
371378
"""Command context."""
372379

@@ -409,6 +416,8 @@ def target_tag(self):
409416
branch = _git_current_branch(self).replace("/", "-")
410417
except subprocess.CalledProcessError:
411418
branch = "UNKNOWN"
419+
if self.cli.image_variant is not ImageVariant.DEFAULT:
420+
suffix = f".{self.cli.image_variant}{suffix}"
412421
return f"{branch}.{self.cli.distro}{suffix}"
413422

414423
def base_branch(self):
@@ -614,6 +623,8 @@ def build_container(ctx):
614623
f"--volume={ctx.dnf_cache_dir}:/var/cache/dnf:Z",
615624
"--build-arg=CLEAN_DNF=no",
616625
]
626+
if ctx.cli.image_variant is ImageVariant.PACKAGES:
627+
cmd.append("--build-arg=FOR_MAKE_CHECK=false")
617628
if ctx.cli.build_args:
618629
cmd.extend([f"--build-arg={v}" for v in ctx.cli.build_args])
619630
cmd += ["-f", ctx.cli.containerfile, ctx.cli.containerdir]
@@ -726,6 +737,9 @@ def bc_build_tests(ctx):
726737
"-c",
727738
f"cd {ctx.cli.homedir} && source ./src/script/run-make.sh && build tests",
728739
],
740+
# for compatibility with earlier versions that baked this env var
741+
# into the build images
742+
extra_args=['-eFOR_MAKE_CHECK=1'],
729743
)
730744
with ctx.user_command():
731745
_run(cmd, check=True, ctx=ctx)
@@ -1078,6 +1092,13 @@ def parse_cli(build_step_names):
10781092
help="Specify a set of valid image sources. "
10791093
f"May be a comma separated list of {ImageSource.hint()}",
10801094
)
1095+
g_image.add_argument(
1096+
"--image-variant",
1097+
type=ImageVariant,
1098+
choices=sorted(v.value for v in ImageVariant),
1099+
default=ImageVariant.DEFAULT.value,
1100+
help="Specify the variant of the build image desired.",
1101+
)
10811102
g_image.add_argument(
10821103
"--base-image",
10831104
help=(

0 commit comments

Comments
 (0)