From 47526c00ac06480a3cebb3b4a73380433c866951 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 --- container/files/init-container.sh | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/container/files/init-container.sh b/container/files/init-container.sh index 27f8ef0..c052a7f 100755 --- a/container/files/init-container.sh +++ b/container/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 c709fcde42bae101e4ac54bd7ea2068ed3a4ae18 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 --- container/files/init-container.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/container/files/init-container.sh b/container/files/init-container.sh index c052a7f..0432713 100755 --- a/container/files/init-container.sh +++ b/container/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 3cf61112f6e32ab6b4aa59616e512bc6b52c8f85 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). We also have a need for a buildenv where xcp-ng-release has taken the place of upstream's almalinux-release. This is done by introducing "buildenv variants", the pre-existing one being dubbed "build", and the new ones "bootstrap" and "isarpm" (current name of the bitbake layer needing it). Signed-off-by: Yann Dirson --- container/Dockerfile-9.x | 16 +++++++++++++--- container/build.sh | 38 ++++++++++++++++++++++++++++++++++++-- src/xcp_ng_dev/cli.py | 12 +++++++++++- 3 files changed, 60 insertions(+), 6 deletions(-) diff --git a/container/Dockerfile-9.x b/container/Dockerfile-9.x index be318d0..aa9178c 100644 --- a/container/Dockerfile-9.x +++ b/container/Dockerfile-9.x @@ -1,14 +1,23 @@ FROM ghcr.io/almalinux/10-base:10.0 +ARG VARIANT=build + # Add our repositories # temporary bootstrap repository +# FIXME: if [ ${VARIANT} = build ] COPY files/xcp-ng-8.99.repo /etc/yum.repos.d/xcp-ng.repo + # Almalinux 10 devel 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 [ ${VARIANT} != build ]; 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 @@ -33,11 +42,12 @@ RUN dnf update -y \ vim \ wget \ 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 [ ${VARIANT} != bootstrap ]; 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 diff --git a/container/build.sh b/container/build.sh index 5e9324c..9b1ef00 100755 --- a/container/build.sh +++ b/container/build.sh @@ -20,11 +20,15 @@ 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. +--isarpm (internal) generate an image suitable for the ISARPM build system. EOF } PLATFORM= +EXTRA_ARGS=() +VARIANT=build while [ $# -ge 1 ]; do case "$1" in --help|-h) @@ -36,6 +40,12 @@ while [ $# -ge 1 ]; do PLATFORM="$2" shift ;; + --bootstrap) + VARIANT=bootstrap + ;; + --isarpm) + VARIANT=isarpm + ;; -*) die_usage "unknown flag '$1'" ;; @@ -48,6 +58,12 @@ done [ -n "$1" ] || die_usage "version parameter missing" +case "$1" in + 8.*) + [ $VARIANT = build ] || die "--variant is only supported for XCP-ng 9.0 and newer" + ;; +esac + RUNNER="" if [ -n "$XCPNG_OCI_RUNNER" ]; then RUNNER="$XCPNG_OCI_RUNNER" @@ -85,9 +101,27 @@ case "$1" in ;; esac +case $VARIANT in + build) + TAG=${1} + ;; + bootstrap) + TAG=${1}-bootstrap + EXTRA_ARGS+=( "--build-arg" "VARIANT=bootstrap" ) + ;; + isarpm) + TAG=${1}-isarpm + EXTRA_ARGS+=( "--build-arg" "VARIANT=isarpm" ) + ;; + *) + echo >&2 "Unsupported --variant '$VARIANT'" + ;; +esac + "$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 \ + "${EXTRA_ARGS[@]}" \ -f $DOCKERFILE . diff --git a/src/xcp_ng_dev/cli.py b/src/xcp_ng_dev/cli.py index 6b0d072..db0e74e 100755 --- a/src/xcp_ng_dev/cli.py +++ b/src/xcp_ng_dev/cli.py @@ -55,6 +55,10 @@ 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') + group.add_argument('--isarpm', action='store_true', + help='(internal) use a build-env suitable for the ISARPM build system') def add_container_args(parser): group = parser.add_argument_group("container arguments") @@ -233,8 +237,14 @@ def container(args): # no argument pass + tag = args.container_version + if args.bootstrap: + tag += "-bootstrap" + if args.isarpm: + tag += "-isarpm" + # 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)