Skip to content

Commit 4904026

Browse files
committed
Add support for bootstrapping the release package
To build release package, we need a pure-upstream buildenv (and incidently, an older xcp-ng-release currently becomes uninstallable every time upstream updates almalinux-release, breaking existing containers. Signed-off-by: Yann Dirson <[email protected]>
1 parent 5aaed74 commit 4904026

File tree

3 files changed

+38
-7
lines changed

3 files changed

+38
-7
lines changed

src/xcp_ng_dev/build.sh

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ usage() {
2020
Usage: $SELF_NAME [--platform PF] <version>
2121
... where <version> is a 'x.y' version such as 8.0.
2222
23-
--platform override the default platform for the build container.
23+
--platform override the default platform for the build container.
24+
--bootstrap generate a bootstrap image, needed to build xcp-ng-release.
2425
EOF
2526
}
2627

2728
PLATFORM=
29+
BOOTSTRAP=0
2830
while [ $# -ge 1 ]; do
2931
case "$1" in
3032
--help|-h)
@@ -36,6 +38,9 @@ while [ $# -ge 1 ]; do
3638
PLATFORM="$2"
3739
shift
3840
;;
41+
--bootstrap)
42+
BOOTSTRAP=1
43+
;;
3944
-*)
4045
die_usage "unknown flag '$1'"
4146
;;
@@ -48,6 +53,12 @@ done
4853

4954
[ -n "$1" ] || die_usage "version parameter missing"
5055

56+
case "$1" in
57+
8.*)
58+
[ $BOOTSTRAP = 0 ] || die "--bootstrap is only supported for XCP-ng 9.0 and newer"
59+
;;
60+
esac
61+
5162
RUNNER=""
5263
if [ -n "$XCPNG_OCI_RUNNER" ]; then
5364
RUNNER="$XCPNG_OCI_RUNNER"
@@ -110,10 +121,17 @@ fi
110121
CUSTOM_ARGS+=( "--build-arg" "CUSTOM_BUILDER_UID=${CUSTOM_UID}" )
111122
CUSTOM_ARGS+=( "--build-arg" "CUSTOM_BUILDER_GID=${CUSTOM_GID}" )
112123

124+
if [ $BOOTSTRAP = 0 ]; then
125+
TAG=${1}
126+
else
127+
TAG=${1}-bootstrap
128+
CUSTOM_ARGS+=( "--build-arg" "BOOTSTRAP=1" )
129+
fi
130+
113131
"$RUNNER" build \
114132
--platform "$PLATFORM" \
115133
"${CUSTOM_ARGS[@]}" \
116-
-t ghcr.io/xcp-ng/xcp-ng-build-env:${1} \
134+
-t ghcr.io/xcp-ng/xcp-ng-build-env:${TAG} \
117135
--build-arg XCP_NG_BRANCH=${1} \
118136
--ulimit nofile=1024 \
119137
-f $DOCKERFILE .

src/xcp_ng_dev/cli.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ def add_common_args(parser):
5656
'If both --enablerepo and --disablerepo are set, --disablerepo will be applied first')
5757
group.add_argument('--no-update', action='store_true',
5858
help='do not run "yum update" on container start, use it as it was at build time')
59+
group.add_argument('--bootstrap', action='store_true',
60+
help='use a bootstrap build-env, able to build xc-ng-release')
5961

6062
def add_container_args(parser):
6163
group = parser.add_argument_group("container arguments")
@@ -228,8 +230,12 @@ def container(args):
228230
# no argument
229231
pass
230232

233+
tag = args.container_version
234+
if args.bootstrap:
235+
tag += "-bootstrap"
236+
231237
# exec "docker run"
232-
docker_args += [f"{CONTAINER_PREFIX}:{args.container_version}",
238+
docker_args += [f"{CONTAINER_PREFIX}:{tag}",
233239
"/usr/local/bin/init-container.sh"]
234240
print("Launching docker with args %s" % docker_args, file=sys.stderr)
235241
return subprocess.call(docker_args)

src/xcp_ng_dev/files/Dockerfile-9.x

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FROM ghcr.io/almalinux/10-base:10.0
22

33
ARG CUSTOM_BUILDER_UID=""
44
ARG CUSTOM_BUILDER_GID=""
5+
ARG BOOTSTRAP=0
56

67
# Add our repositories
78
# temporary bootstrap repository
@@ -12,6 +13,11 @@ COPY files/Alma10-devel.repo /etc/yum.repos.d/
1213
# Install GPG key
1314
RUN curl -sSf https://xcp-ng.org/RPM-GPG-KEY-xcpng -o /etc/pki/rpm-gpg/RPM-GPG-KEY-xcpng
1415

16+
# dnf config-manager not available yet?
17+
RUN if [ "${BOOTSTRAP}" = 1 ]; then \
18+
sed -i -e 's/^enabled=1$/enabled=0/' /etc/yum.repos.d/xcp-ng.repo; \
19+
fi
20+
1521
# Update
1622
RUN dnf update -y
1723

@@ -43,11 +49,12 @@ RUN dnf install -y \
4349
# clean package cache to avoid download errors
4450
RUN yum clean all
4551

46-
# -release*, to be commented out to boostrap the build-env until it gets built
4752
# FIXME: isn't it already pulled as almalinux-release when available?
48-
RUN dnf install -y \
49-
xcp-ng-release \
50-
xcp-ng-release-presets
53+
RUN if [ "${BOOTSTRAP}" = 0 ]; then \
54+
dnf install -y \
55+
xcp-ng-release \
56+
xcp-ng-release-presets ; \
57+
fi
5158
5259
# enable repositories commonly required to build
5360
RUN dnf config-manager --enable crb

0 commit comments

Comments
 (0)