Skip to content

Commit b60d761

Browse files
authored
Merge pull request ceph#62016 from zmc/bwc-for-pipeline
build-with-container: Updates to support ceph-dev-pipeline
2 parents 9c44d9d + fd75679 commit b60d761

File tree

3 files changed

+49
-5
lines changed

3 files changed

+49
-5
lines changed

Dockerfile.build

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ ARG DISTRO
2222
ARG CEPH_CTR_SRC=/usr/local/src/ceph
2323
ARG CLEAN_DNF=yes
2424
ARG CEPH_BASE_BRANCH=main
25+
ARG SCCACHE_VERSION=0.8.2
2526
COPY --from=bootstrap ${CEPH_CTR_SRC} ${CEPH_CTR_SRC}
2627
# Note that we do not use ENV for the following. This is because we do not
2728
# want them permamently stored in the container's layer.
@@ -30,3 +31,6 @@ RUN DISTRO=$DISTRO \
3031
CLEAN_DNF=$CLEAN_DNF \
3132
CEPH_CTR_SRC=${CEPH_CTR_SRC} \
3233
bash -x ${CEPH_CTR_SRC}/buildcontainer-setup.sh
34+
RUN \
35+
SCCACHE_URL="https://github.com/mozilla/sccache/releases/download/v${SCCACHE_VERSION}/sccache-v${SCCACHE_VERSION}-$(uname -m)-unknown-linux-musl.tar.gz"; \
36+
curl -L $SCCACHE_URL | tar --no-anchored --strip-components=1 -C /usr/local/bin/ -xzf - sccache

make-srpm.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
# rpmbuild --rebuild /tmp/ceph/ceph-<version>-0.el7.centos.src.rpm
88
#
99

10-
./make-dist $1
10+
test -f "ceph-$1.tar.bz2" || ./make-dist $1
1111
rpmbuild -D"_sourcedir `pwd`" -D"_specdir `pwd`" -D"_srcrpmdir `pwd`" -bs ceph.spec

src/script/build-with-container.py

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
import logging
7474
import os
7575
import pathlib
76+
import re
7677
import shlex
7778
import shutil
7879
import subprocess
@@ -179,6 +180,8 @@ def _container_cmd(ctx, args, *, workdir=None, interactive=False):
179180
cmd.append("--pids-limit=-1")
180181
if ctx.map_user:
181182
cmd.append("--user=0")
183+
if ctx.cli.env_file:
184+
cmd.append(f"--env-file={ctx.cli.env_file.absolute()}")
182185
if workdir:
183186
cmd.append(f"--workdir={workdir}")
184187
cwd = pathlib.Path(".").absolute()
@@ -580,12 +583,15 @@ def bc_run_tests(ctx):
580583
def bc_make_source_rpm(ctx):
581584
"""Build SPRMs."""
582585
ctx.build.wants(Steps.CONTAINER, ctx)
586+
make_srpm_cmd = f"cd {ctx.cli.homedir} && ./make-srpm.sh"
587+
if ctx.cli.ceph_version:
588+
make_srpm_cmd = f"{make_srpm_cmd} {ctx.cli.ceph_version}"
583589
cmd = _container_cmd(
584590
ctx,
585591
[
586592
"bash",
587593
"-c",
588-
f"cd {ctx.cli.homedir} && ./make-srpm.sh",
594+
make_srpm_cmd,
589595
],
590596
)
591597
with ctx.user_command():
@@ -597,8 +603,21 @@ def bc_build_rpm(ctx):
597603
"""Build RPMs from SRPM."""
598604
srpm_glob = "ceph*.src.rpm"
599605
if ctx.cli.rpm_match_sha:
600-
head_sha = _git_current_sha(ctx)
601-
srpm_glob = f"ceph*.g{head_sha}.*.src.rpm"
606+
if not ctx.cli.ceph_version:
607+
head_sha = _git_current_sha(ctx)
608+
srpm_glob = f"ceph*.g{head_sha}.*.src.rpm"
609+
else:
610+
# Given a tarball with a name like
611+
# ceph-19.3.0-7462-g565e5c65.tar.bz2
612+
# The SRPM name would be:
613+
# ceph-19.3.0-7462.g565e5c65.el9.src.rpm
614+
# This regex replaces the second '-' with a '.'
615+
srpm_version = re.sub(
616+
r"(\d+\.\d+\.\d+-\d+)-(.*)",
617+
r"\1.\2",
618+
ctx.cli.ceph_version
619+
)
620+
srpm_glob = f"ceph-{srpm_version}.*.src.rpm"
602621
paths = glob.glob(srpm_glob)
603622
if len(paths) > 1:
604623
raise RuntimeError(
@@ -617,12 +636,18 @@ def bc_build_rpm(ctx):
617636
topdir = (
618637
pathlib.Path(ctx.cli.homedir) / ctx.cli.build_dir / "rpmbuild"
619638
)
639+
rpmbuild_args = [
640+
'rpmbuild',
641+
'--rebuild',
642+
f'-D_topdir {topdir}',
643+
] + list(ctx.cli.rpmbuild_arg) + [str(srpm_path)]
644+
rpmbuild_cmd = ' '.join(shlex.quote(cmd) for cmd in rpmbuild_args)
620645
cmd = _container_cmd(
621646
ctx,
622647
[
623648
"bash",
624649
"-c",
625-
f"set -x; mkdir -p {topdir} && rpmbuild --rebuild -D'_topdir {topdir}' {srpm_path}",
650+
f"set -x; mkdir -p {topdir} && {rpmbuild_cmd}",
626651
],
627652
)
628653
with ctx.user_command():
@@ -836,6 +861,16 @@ def parse_cli(build_step_names):
836861
" git checkout. Use any source RPM available."
837862
),
838863
)
864+
parser.add_argument(
865+
"--rpmbuild-arg",
866+
'-R',
867+
action="append",
868+
help="Pass this extra argument to rpmbuild",
869+
)
870+
parser.add_argument(
871+
"--ceph-version",
872+
help="Rather than infer the Ceph version, use this value",
873+
)
839874
parser.add_argument(
840875
"--execute",
841876
"-e",
@@ -844,6 +879,11 @@ def parse_cli(build_step_names):
844879
choices=build_step_names,
845880
help="Execute the target build step(s)",
846881
)
882+
parser.add_argument(
883+
"--env-file",
884+
type=pathlib.Path,
885+
help="Use this environment file when building",
886+
)
847887
parser.add_argument(
848888
"--dry-run",
849889
action="store_true",

0 commit comments

Comments
 (0)