Skip to content

Commit e9cf0bd

Browse files
authored
Merge pull request #35 from xcp-ng/ydi/9
Support for a v9 build-env
2 parents edb8466 + fee2790 commit e9cf0bd

File tree

9 files changed

+306
-154
lines changed

9 files changed

+306
-154
lines changed

Dockerfile-7.x

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM centos:7.2.1511
1+
ARG CENTOS_VERSION=7.2.1511
2+
3+
FROM centos:${CENTOS_VERSION}
24

35
ARG CUSTOM_BUILDER_UID=""
46
ARG CUSTOM_BUILDER_GID=""
@@ -7,11 +9,15 @@ ARG CUSTOM_BUILDER_GID=""
79
RUN rm /etc/yum.repos.d/*
810

911
# Add only the specific CentOS 7.2 repositories, because that's what XS used for the majority of packages
10-
COPY files/tmp-CentOS-Vault.repo /etc/yum.repos.d/CentOS-Vault-7.2.repo
12+
ARG CENTOS_VERSION
13+
COPY files/CentOS-Vault.repo.in /etc/yum.repos.d/CentOS-Vault-7.2.repo
14+
RUN sed -e "s/@CENTOS_VERSION@/${CENTOS_VERSION}/g" -i /etc/yum.repos.d/CentOS-Vault-7.2.repo
1115

1216
# Add our repositories
1317
# Repository file depends on the target version of XCP-ng, and is pre-processed by build.sh
14-
COPY files/tmp-xcp-ng.repo /etc/yum.repos.d/xcp-ng.repo
18+
ARG XCP_NG_BRANCH=7.6
19+
COPY files/xcp-ng.repo.7.x.in /etc/yum.repos.d/xcp-ng.repo
20+
RUN sed -e "s/@XCP_NG_BRANCH@/${XCP_NG_BRANCH}/g" -i /etc/yum.repos.d/xcp-ng.repo
1521

1622
# Fix invalid rpmdb checksum error with overlayfs, see https://github.com/docker/docker/issues/10180
1723
RUN yum install -y yum-plugin-ovl
@@ -43,6 +49,9 @@ RUN yum install -y \
4349
wget \
4450
which
4551

52+
# clean package cache to avoid download errors
53+
RUN yum clean all
54+
4655
# OCaml in XS is slightly older than in CentOS
4756
RUN sed -i "/gpgkey/a exclude=ocaml*" /etc/yum.repos.d/Cent* /etc/yum.repos.d/epel*
4857

Dockerfile-8.x

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
FROM centos:7.5.1804
1+
ARG CENTOS_VERSION=7.5.1804
2+
3+
FROM centos:${CENTOS_VERSION}
24

35
ARG CUSTOM_BUILDER_UID=""
46
ARG CUSTOM_BUILDER_GID=""
@@ -7,11 +9,15 @@ ARG CUSTOM_BUILDER_GID=""
79
RUN rm /etc/yum.repos.d/*
810

911
# Add only the specific CentOS 7.5 repositories, because that's what XS used for the majority of packages
10-
COPY files/tmp-CentOS-Vault.repo /etc/yum.repos.d/CentOS-Vault-7.5.repo
12+
ARG CENTOS_VERSION
13+
COPY files/CentOS-Vault.repo.in /etc/yum.repos.d/CentOS-Vault-7.5.repo
14+
RUN sed -e "s/@CENTOS_VERSION@/${CENTOS_VERSION}/g" -i /etc/yum.repos.d/CentOS-Vault-7.5.repo
1115

1216
# Add our repositories
1317
# Repository file depends on the target version of XCP-ng, and is pre-processed by build.sh
14-
COPY files/tmp-xcp-ng.repo /etc/yum.repos.d/xcp-ng.repo
18+
ARG XCP_NG_BRANCH=8.3
19+
COPY files/xcp-ng.repo.8.x.in /etc/yum.repos.d/xcp-ng.repo
20+
RUN sed -e "s/@XCP_NG_BRANCH@/${XCP_NG_BRANCH}/g" -i /etc/yum.repos.d/xcp-ng.repo
1521

1622
# Install GPG key
1723
RUN curl -sSf https://xcp-ng.org/RPM-GPG-KEY-xcpng -o /etc/pki/rpm-gpg/RPM-GPG-KEY-xcpng
@@ -46,6 +52,9 @@ RUN yum install -y \
4652
wget \
4753
which
4854

55+
# clean package cache to avoid download errors
56+
RUN yum clean all
57+
4958
# OCaml in XS may be older than in CentOS
5059
RUN sed -i "/gpgkey/a exclude=ocaml*" /etc/yum.repos.d/Cent* /etc/yum.repos.d/epel*
5160

Dockerfile-9.x

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
FROM ghcr.io/almalinux/10-base:10.0
2+
3+
ARG CUSTOM_BUILDER_UID=""
4+
ARG CUSTOM_BUILDER_GID=""
5+
6+
# Add our repositories
7+
# temporary bootstrap repository
8+
COPY files/xcp-ng-8.99.repo /etc/yum.repos.d/xcp-ng.repo
9+
# Almalinux 10 devel
10+
COPY files/Alma10-devel.repo /etc/yum.repos.d/
11+
12+
# Install GPG key
13+
RUN curl -sSf https://xcp-ng.org/RPM-GPG-KEY-xcpng -o /etc/pki/rpm-gpg/RPM-GPG-KEY-xcpng
14+
15+
# Update
16+
RUN dnf update -y
17+
18+
# Common build requirements
19+
RUN dnf install -y \
20+
gcc \
21+
gcc-c++ \
22+
git \
23+
make \
24+
rpm-build \
25+
redhat-rpm-config \
26+
python3-rpm \
27+
sudo \
28+
dnf-plugins-core \
29+
epel-release
30+
31+
# EPEL: needs epel-release installed first
32+
RUN dnf install -y \
33+
epel-rpm-macros \
34+
almalinux-git-utils
35+
36+
# Niceties
37+
RUN dnf install -y \
38+
bash-completion \
39+
vim \
40+
wget \
41+
which
42+
43+
# clean package cache to avoid download errors
44+
RUN yum clean all
45+
46+
# -release*, to be commented out to boostrap the build-env until it gets built
47+
# 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
51+
52+
# enable repositories commonly required to build
53+
RUN dnf config-manager --enable crb
54+
55+
# workaround sudo not working (e.g. in podman 4.9.3 in Ubuntu 24.04)
56+
RUN chmod 0400 /etc/shadow
57+
58+
# Set up the builder user
59+
RUN bash -c ' \
60+
OPTS=(); \
61+
if [ -n "${CUSTOM_BUILDER_UID}" ]; then \
62+
OPTS+=("-u" "${CUSTOM_BUILDER_UID}"); \
63+
fi; \
64+
if [ -n "${CUSTOM_BUILDER_GID}" ]; then \
65+
OPTS+=("-g" "${CUSTOM_BUILDER_GID}"); \
66+
if ! getent group "${CUSTOM_BUILDER_GID}" >/dev/null; then \
67+
groupadd -g "${CUSTOM_BUILDER_GID}" builder; \
68+
fi; \
69+
fi; \
70+
useradd "${OPTS[@]}" builder; \
71+
' \
72+
&& echo "builder:builder" | chpasswd \
73+
&& echo "builder ALL=(ALL:ALL) NOPASSWD: ALL" >> /etc/sudoers
74+
75+
RUN mkdir -p /usr/local/bin
76+
COPY files/init-container.sh /usr/local/bin/init-container.sh
77+
78+
# FIXME: check it we really need any of this
79+
# COPY files/rpmmacros /home/builder/.rpmmacros

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,29 @@ git clone https://github.com/xcp-ng-rpms/xapi.git
126126
* `--rm` destroys the container on exit. Helps preventing containers from using too much space on disk. You can still reclaim space afterwards by running `docker container prune` and `docker image prune`
127127
* `-v` / `--volume` (see *Mounting repos from outside the container* below)
128128
129+
**Refreshing fuzzy patches**
130+
131+
In XCP-ng 9.0, `rpmbuild` rejects fuzzy patches. The easiest-known
132+
way to get them refreshed is to let `quilt` do the job, but that's not
133+
fully automated.
134+
135+
1. modify the specfile to add `-Squilt` to `%autosetup` or
136+
`%autopatch` in the `%prep` block; add `BuildRequires: quilt`
137+
2. let quilt apply them in a 8.3 buildenv (`quilt` in 8.3 is only in EPEL) and get you a shell:
138+
```
139+
xcpng/build-env/run.py --rm -b 8.3 -l . --rpmbuild-stage=p -n --enablerepo=epel
140+
```
141+
3. ask `quilt` to refresh all your patches (alternatively just the one you want)
142+
```
143+
$ cd rpmbuild/BUILD/$dir
144+
$ quilt pop -a --refresh
145+
$ cp patches/* ../../SOURCES/
146+
```
147+
4. carefully pick up the bits you need
148+
149+
Note: unfortunately `rpmbuild` (in 8.3 at least) does not add all
150+
patches in `patches/series` upfront, so in case of real conflict this
151+
has to be redone from step 2 each time.
129152

130153
## Building packages manually
131154

build.sh

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,50 @@
11
#!/usr/bin/env bash
2-
32
set -e
43

5-
if [ -z "$1" ]; then
6-
echo "Usage: $0 {version}"
7-
echo "... where {version} is a 'x.y' version such as 8.0."
8-
exit
9-
fi
4+
die() {
5+
echo >&2
6+
echo >&2 "ERROR: $*"
7+
echo >&2
8+
exit 1
9+
}
10+
11+
die_usage() {
12+
usage >&2
13+
die "$*"
14+
}
15+
16+
usage() {
17+
cat <<EOF
18+
Usage: $0 [--platform PF] <version>
19+
... where <version> is a 'x.y' version such as 8.0.
20+
21+
--platform override the default platform for the build container.
22+
EOF
23+
}
24+
25+
PLATFORM=
26+
while [ $# -ge 1 ]; do
27+
case "$1" in
28+
--help|-h)
29+
usage
30+
exit 0
31+
;;
32+
--platform)
33+
[ $# -ge 2 ] || die_usage "$1 needs an argument"
34+
PLATFORM="$2"
35+
shift
36+
;;
37+
-*)
38+
die_usage "unknown flag '$1'"
39+
;;
40+
*)
41+
break
42+
;;
43+
esac
44+
shift
45+
done
46+
47+
[ -n "$1" ] || die_usage "version parameter missing"
1048

1149
RUNNER=""
1250
if [ -n "$XCPNG_OCI_RUNNER" ]; then
@@ -29,31 +67,28 @@ cd $(dirname "$0")
2967

3068
CUSTOM_ARGS=()
3169

70+
ALMA_VERSION=
71+
CENTOS_VERSION=
3272
case "$1" in
33-
7.*)
34-
REPO_FILE=files/xcp-ng.repo.7.x.in
35-
DOCKERFILE=Dockerfile-7.x
36-
CENTOS_VERSION=7.2.1511
73+
9.*)
74+
DOCKERFILE=Dockerfile-9.x
75+
ALMA_VERSION=10.0
76+
: ${PLATFORM:=linux/amd64/v2}
3777
;;
3878
8.*)
39-
REPO_FILE=files/xcp-ng.repo.8.x.in
4079
DOCKERFILE=Dockerfile-8.x
41-
CENTOS_VERSION=7.5.1804
80+
: ${PLATFORM:=linux/amd64}
81+
;;
82+
7.*)
83+
DOCKERFILE=Dockerfile-7.x
84+
: ${PLATFORM:=linux/amd64}
4285
;;
4386
*)
4487
echo >&2 "Unsupported release '$1'"
4588
exit 1
4689
;;
4790
esac
4891

49-
sed -e "s/@XCP_NG_BRANCH@/${1}/g" "$REPO_FILE" > files/tmp-xcp-ng.repo
50-
sed -e "s/@CENTOS_VERSION@/${CENTOS_VERSION}/g" files/CentOS-Vault.repo.in > files/tmp-CentOS-Vault.repo
51-
52-
# Support using docker on other archs (e.g. arm64 for Apple Silicon), building for amd64
53-
if [ "$(uname -m)" != "x86_64" ]; then
54-
CUSTOM_ARGS+=( "--platform" "linux/amd64" )
55-
fi
56-
5792
CUSTOM_UID="$(id -u)"
5893
CUSTOM_GID="$(id -g)"
5994

@@ -74,10 +109,9 @@ CUSTOM_ARGS+=( "--build-arg" "CUSTOM_BUILDER_UID=${CUSTOM_UID}" )
74109
CUSTOM_ARGS+=( "--build-arg" "CUSTOM_BUILDER_GID=${CUSTOM_GID}" )
75110

76111
"$RUNNER" build \
112+
--platform "$PLATFORM" \
77113
"${CUSTOM_ARGS[@]}" \
78-
-t xcp-ng/xcp-ng-build-env:${1} \
114+
-t ghcr.io/xcp-ng/xcp-ng-build-env:${1} \
115+
--build-arg XCP_NG_BRANCH=${1} \
79116
--ulimit nofile=1024 \
80117
-f $DOCKERFILE .
81-
82-
rm -f files/tmp-xcp-ng.repo
83-
rm -f files/tmp-CentOS-Vault.repo

files/Alma10-devel.repo

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[alma10-devel]
2+
name=Almalinux 10 devel
3+
baseurl=https://repo.almalinux.org/almalinux/10/devel/$basearch/os/
4+
enabled=1
5+
gpgcheck=1

0 commit comments

Comments
 (0)