Skip to content

Commit 1cab0b8

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 <yann.dirson@vates.tech>
1 parent e6736be commit 1cab0b8

File tree

3 files changed

+38
-5
lines changed

3 files changed

+38
-5
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"
@@ -85,9 +96,16 @@ case "$1" in
8596
;;
8697
esac
8798

99+
if [ $BOOTSTRAP = 0 ]; then
100+
TAG=${1}
101+
else
102+
TAG=${1}-bootstrap
103+
CUSTOM_ARGS+=( "--build-arg" "BOOTSTRAP=1" )
104+
fi
105+
88106
"$RUNNER" build \
89107
--platform "$PLATFORM" \
90-
-t ghcr.io/xcp-ng/xcp-ng-build-env:${1} \
108+
-t ghcr.io/xcp-ng/xcp-ng-build-env:${TAG} \
91109
--build-arg XCP_NG_BRANCH=${1} \
92110
--ulimit nofile=1024 \
93111
-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")
@@ -234,8 +236,12 @@ def container(args):
234236
# no argument
235237
pass
236238

239+
tag = args.container_version
240+
if args.bootstrap:
241+
tag += "-bootstrap"
242+
237243
# exec "docker run"
238-
docker_args += [f"{CONTAINER_PREFIX}:{args.container_version}",
244+
docker_args += [f"{CONTAINER_PREFIX}:{tag}",
239245
"/usr/local/bin/init-container.sh"]
240246
print("Launching docker with args %s" % docker_args, file=sys.stderr)
241247
return subprocess.call(docker_args)

src/xcp_ng_dev/files/Dockerfile-9.x

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

3+
ARG BOOTSTRAP=0
4+
35
# Add our repositories
46
# temporary bootstrap repository
57
COPY files/xcp-ng-8.99.repo /etc/yum.repos.d/xcp-ng.repo
@@ -9,6 +11,11 @@ COPY files/Alma10-devel.repo /etc/yum.repos.d/
911
# Install GPG key
1012
RUN curl -sSf https://xcp-ng.org/RPM-GPG-KEY-xcpng -o /etc/pki/rpm-gpg/RPM-GPG-KEY-xcpng
1113

14+
# dnf config-manager not available yet?
15+
RUN if [ "${BOOTSTRAP}" = 1 ]; then \
16+
sed -i -e 's/^enabled=1$/enabled=0/' /etc/yum.repos.d/xcp-ng.repo; \
17+
fi
18+
1219
# Update
1320
RUN dnf update -y \
1421
# Common build requirements
@@ -35,9 +42,11 @@ RUN dnf update -y \
3542
which \
3643
# -release*, to be commented out to boostrap the build-env until it gets built
3744
# FIXME: isn't it already pulled as almalinux-release when available?
38-
&& dnf install -y \
45+
&& if [ "${BOOTSTRAP}" = 0 ]; then \
46+
dnf install -y \
3947
xcp-ng-release \
40-
xcp-ng-release-presets \
48+
xcp-ng-release-presets; \
49+
fi \
4150
# clean package cache to avoid download errors
4251
&& yum clean all
4352

0 commit comments

Comments
 (0)