From 70fd6d1cf0c1361edf06c3131bf5744136f67c2b Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Tue, 9 Sep 2025 14:46:46 +0200 Subject: [PATCH 1/3] init-container: take os name into account, not just version This is necessary to allow bootstrap building of our release package from a plain Alma (since the non-bootstrap image cannot build before that package is built). Signed-off-by: Yann Dirson --- src/xcp_ng_dev/files/init-container.sh | 27 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/xcp_ng_dev/files/init-container.sh b/src/xcp_ng_dev/files/init-container.sh index 27f8ef0..c052a7f 100755 --- a/src/xcp_ng_dev/files/init-container.sh +++ b/src/xcp_ng_dev/files/init-container.sh @@ -9,6 +9,14 @@ if [ -n "$NO_EXIT" ]; then trap "/bin/bash --login" EXIT fi +os_name() +{ + ( + source /etc/os-release + echo "$NAME" + ) +} + os_release() { ( @@ -17,12 +25,13 @@ os_release() ) } +OS_NAME=$(os_name) OS_RELEASE=$(os_release) # get list of user repos -case "$OS_RELEASE" in - 8.2.*) XCPREL=8/8.2 ;; - 8.3.*) XCPREL=8/8.3 ;; +case "$OS_NAME,$OS_RELEASE" in + XCP-ng,8.2.*) XCPREL=8/8.2 ;; + XCP-ng,8.3.*) XCPREL=8/8.3 ;; *) echo >&2 "WARNING: unknown release, not fetching user repo definitions" ;; esac @@ -32,13 +41,13 @@ if [ -n "$XCPREL" ]; then fi # yum or dnf? -case "$OS_RELEASE" in - 8.2.*|8.3.*) +case "$OS_NAME,$OS_RELEASE" in + XCP-ng,8.2.*|XCP-ng,8.3.*) DNF=yum CFGMGR=yum-config-manager BDEP=yum-builddep ;; - 8.99.*|9.*|10.*) # FIXME 10.* actually to bootstrap Alma10 + XCP-ng,8.99.*|XCP-ng,9.*|AlmaLinux,10.*) DNF=dnf CFGMGR="dnf config-manager" BDEP="dnf builddep" @@ -86,9 +95,9 @@ if [ -n "$BUILD_LOCAL" ]; then fi echo "Found specfiles $specs" - case "$OS_RELEASE" in - 8.2.*|8.3.*) ;; # sources always available via git-lfs - 8.99.*|9.*) if [ -r sources ]; then alma_get_sources -i sources; fi ;; + case "$OS_NAME,$OS_RELEASE" in + XCP-ng,8.2.*|XCP-ng,8.3.*) ;; # sources always available via git-lfs + XCP-ng,8.99.*|XCP-ng,9.*) if [ -r sources ]; then alma_get_sources -i sources; fi ;; *) echo >&2 "ERROR: unknown release, cannot know package manager"; exit 1 ;; esac From e6736be56ff6595c939a599577d1b779f2c158db Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Tue, 9 Sep 2025 14:50:43 +0200 Subject: [PATCH 2/3] init-container: fix getting sources for Alma 10 That case had been forgotten, and the error message was wrong. Signed-off-by: Yann Dirson --- src/xcp_ng_dev/files/init-container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/xcp_ng_dev/files/init-container.sh b/src/xcp_ng_dev/files/init-container.sh index c052a7f..0432713 100755 --- a/src/xcp_ng_dev/files/init-container.sh +++ b/src/xcp_ng_dev/files/init-container.sh @@ -97,8 +97,8 @@ if [ -n "$BUILD_LOCAL" ]; then case "$OS_NAME,$OS_RELEASE" in XCP-ng,8.2.*|XCP-ng,8.3.*) ;; # sources always available via git-lfs - XCP-ng,8.99.*|XCP-ng,9.*) if [ -r sources ]; then alma_get_sources -i sources; fi ;; - *) echo >&2 "ERROR: unknown release, cannot know package manager"; exit 1 ;; + XCP-ng,8.99.*|XCP-ng,9.*|AlmaLinux,10.*) if [ -r sources ]; then alma_get_sources -i sources; fi ;; + *) echo >&2 "ERROR: unknown release, don't know how to find sources"; exit 1 ;; esac sudo $BDEP "${SPECFLAGS[@]}" -y $specs From 1cab0b869b8b379df999ee475360d6a08bd7c038 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Tue, 9 Sep 2025 13:57:07 +0200 Subject: [PATCH 3/3] 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 --- src/xcp_ng_dev/build.sh | 22 ++++++++++++++++++++-- src/xcp_ng_dev/cli.py | 8 +++++++- src/xcp_ng_dev/files/Dockerfile-9.x | 13 +++++++++++-- 3 files changed, 38 insertions(+), 5 deletions(-) diff --git a/src/xcp_ng_dev/build.sh b/src/xcp_ng_dev/build.sh index 30f64a8..decc8b1 100755 --- a/src/xcp_ng_dev/build.sh +++ b/src/xcp_ng_dev/build.sh @@ -20,11 +20,13 @@ usage() { Usage: $SELF_NAME [--platform PF] ... where is a 'x.y' version such as 8.0. ---platform override the default platform for the build container. +--platform override the default platform for the build container. +--bootstrap generate a bootstrap image, needed to build xcp-ng-release. EOF } PLATFORM= +BOOTSTRAP=0 while [ $# -ge 1 ]; do case "$1" in --help|-h) @@ -36,6 +38,9 @@ while [ $# -ge 1 ]; do PLATFORM="$2" shift ;; + --bootstrap) + BOOTSTRAP=1 + ;; -*) die_usage "unknown flag '$1'" ;; @@ -48,6 +53,12 @@ done [ -n "$1" ] || die_usage "version parameter missing" +case "$1" in + 8.*) + [ $BOOTSTRAP = 0 ] || die "--bootstrap is only supported for XCP-ng 9.0 and newer" + ;; +esac + RUNNER="" if [ -n "$XCPNG_OCI_RUNNER" ]; then RUNNER="$XCPNG_OCI_RUNNER" @@ -85,9 +96,16 @@ case "$1" in ;; esac +if [ $BOOTSTRAP = 0 ]; then + TAG=${1} +else + TAG=${1}-bootstrap + CUSTOM_ARGS+=( "--build-arg" "BOOTSTRAP=1" ) +fi + "$RUNNER" build \ --platform "$PLATFORM" \ - -t ghcr.io/xcp-ng/xcp-ng-build-env:${1} \ + -t ghcr.io/xcp-ng/xcp-ng-build-env:${TAG} \ --build-arg XCP_NG_BRANCH=${1} \ --ulimit nofile=1024 \ -f $DOCKERFILE . diff --git a/src/xcp_ng_dev/cli.py b/src/xcp_ng_dev/cli.py index 642d543..c4f5e02 100755 --- a/src/xcp_ng_dev/cli.py +++ b/src/xcp_ng_dev/cli.py @@ -56,6 +56,8 @@ def add_common_args(parser): 'If both --enablerepo and --disablerepo are set, --disablerepo will be applied first') group.add_argument('--no-update', action='store_true', help='do not run "yum update" on container start, use it as it was at build time') + group.add_argument('--bootstrap', action='store_true', + help='use a bootstrap build-env, able to build xc-ng-release') def add_container_args(parser): group = parser.add_argument_group("container arguments") @@ -234,8 +236,12 @@ def container(args): # no argument pass + tag = args.container_version + if args.bootstrap: + tag += "-bootstrap" + # exec "docker run" - docker_args += [f"{CONTAINER_PREFIX}:{args.container_version}", + docker_args += [f"{CONTAINER_PREFIX}:{tag}", "/usr/local/bin/init-container.sh"] print("Launching docker with args %s" % docker_args, file=sys.stderr) return subprocess.call(docker_args) diff --git a/src/xcp_ng_dev/files/Dockerfile-9.x b/src/xcp_ng_dev/files/Dockerfile-9.x index be318d0..d2ddc5b 100644 --- a/src/xcp_ng_dev/files/Dockerfile-9.x +++ b/src/xcp_ng_dev/files/Dockerfile-9.x @@ -1,5 +1,7 @@ FROM ghcr.io/almalinux/10-base:10.0 +ARG BOOTSTRAP=0 + # Add our repositories # temporary bootstrap repository 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/ # Install GPG key RUN curl -sSf https://xcp-ng.org/RPM-GPG-KEY-xcpng -o /etc/pki/rpm-gpg/RPM-GPG-KEY-xcpng +# dnf config-manager not available yet? +RUN if [ "${BOOTSTRAP}" = 1 ]; then \ + sed -i -e 's/^enabled=1$/enabled=0/' /etc/yum.repos.d/xcp-ng.repo; \ + fi + # Update RUN dnf update -y \ # Common build requirements @@ -35,9 +42,11 @@ RUN dnf update -y \ which \ # -release*, to be commented out to boostrap the build-env until it gets built # FIXME: isn't it already pulled as almalinux-release when available? - && dnf install -y \ + && if [ "${BOOTSTRAP}" = 0 ]; then \ + dnf install -y \ xcp-ng-release \ - xcp-ng-release-presets \ + xcp-ng-release-presets; \ + fi \ # clean package cache to avoid download errors && yum clean all