Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions src/xcp_ng_dev/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ usage() {
Usage: $SELF_NAME [--platform PF] <version>
... where <version> 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)
Expand All @@ -36,6 +38,9 @@ while [ $# -ge 1 ]; do
PLATFORM="$2"
shift
;;
--bootstrap)
BOOTSTRAP=1
;;
-*)
die_usage "unknown flag '$1'"
;;
Expand All @@ -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"
Expand Down Expand Up @@ -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 .
8 changes: 7 additions & 1 deletion src/xcp_ng_dev/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 11 additions & 2 deletions src/xcp_ng_dev/files/Dockerfile-9.x
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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

Expand Down
29 changes: 19 additions & 10 deletions src/xcp_ng_dev/files/init-container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
(
Expand All @@ -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

Expand All @@ -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"
Expand Down Expand Up @@ -86,10 +95,10 @@ 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 ;;
*) echo >&2 "ERROR: unknown release, cannot know package manager"; exit 1 ;;
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.*|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
Expand Down