Skip to content

Commit 6f91b3f

Browse files
ci: allow installing greenboot from compose RPMs as an alternative to Copr
Copr remains the default source for greenboot builds in CI tests. For RHEL 9.8 and RHEL 10.2 targets, when DOWNLOAD_NODE and COMPOSE_ID are both set, download pre-built greenboot RPMs from the compose instead. Assisted-by: Claude (claude-sonnet-5) Signed-off-by: Mario Cattamo <mcattamo@redhat.com>
1 parent 63b4761 commit 6f91b3f

4 files changed

Lines changed: 196 additions & 30 deletions

File tree

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#!/bin/bash
2+
# Source this file to get the download_compose_rpms helper function.
3+
4+
# download_compose_rpms <packages_url> <dest_dir>
5+
#
6+
# Downloads the latest greenboot and greenboot-default-health-checks RPMs
7+
# from the compose packages index at <packages_url> into <dest_dir>.
8+
#
9+
# The packages index page is fetched once and reused for both lookups.
10+
#
11+
# The -k (--insecure) flag is required because RHEL internal compose servers
12+
# use certificates signed by the Red Hat internal CA, which is not present
13+
# in the default system trust store on CI hosts.
14+
download_compose_rpms() {
15+
local packages_url="$1"
16+
local dest_dir="$2"
17+
18+
# The packages index page can be huge (thousands of RPMs). Silence xtrace
19+
# while we fetch/parse it so its raw HTML isn't dumped into the CI logs.
20+
{ set +x; } 2>/dev/null
21+
22+
local packages_page
23+
packages_page="$(curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
24+
"${packages_url}")"
25+
26+
local greenboot_rpm
27+
greenboot_rpm="$(echo "${packages_page}" \
28+
| grep -oE 'greenboot-[0-9][^"]*\.rpm' \
29+
| grep -vE 'debug(info|source)' \
30+
| sort -V | tail -n 1)"
31+
if [[ -z "${greenboot_rpm}" ]]; then
32+
set -x
33+
echo "ERROR: greenboot RPM not found at ${packages_url}"
34+
return 1
35+
fi
36+
echo "Selected greenboot RPM: ${greenboot_rpm}"
37+
38+
local greenboot_default_rpm
39+
greenboot_default_rpm="$(echo "${packages_page}" \
40+
| grep -oE 'greenboot-default-health-checks-[0-9][^"]*\.rpm' \
41+
| sort -V | tail -n 1)"
42+
if [[ -z "${greenboot_default_rpm}" ]]; then
43+
set -x
44+
echo "ERROR: greenboot default RPM not found at ${packages_url}"
45+
return 1
46+
fi
47+
echo "Selected greenboot-default-health-checks RPM: ${greenboot_default_rpm}"
48+
set -x
49+
50+
curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
51+
"${packages_url}${greenboot_rpm}" -o "${dest_dir}/${greenboot_rpm}"
52+
curl -kfsSL --retry 5 --retry-delay 2 --retry-all-errors \
53+
"${packages_url}${greenboot_default_rpm}" -o "${dest_dir}/${greenboot_default_rpm}"
54+
}

tests/greenboot-bootc-anaconda-iso.sh

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ EDGE_USER_PASSWORD=foobar
3838
CONSOLE_LOG=/tmp/vm-console.log
3939

4040
COPR_CHROOT=""
41+
42+
# RPM acquisition mode:
43+
# If DOWNLOAD_NODE and COMPOSE_ID are both set -> download from compose
44+
# Otherwise -> install greenboot from Copr (default)
45+
USE_COMPOSE_RPMS=false
46+
if [[ -n "${DOWNLOAD_NODE:-}" && -n "${COMPOSE_ID:-}" ]]; then
47+
USE_COMPOSE_RPMS=true
48+
fi
49+
GREENBOOT_PACKAGES_URL=""
50+
4151
case "${ID}-${VERSION_ID}" in
4252
"fedora-44")
4353
OS_VARIANT="fedora-unknown"
@@ -65,6 +75,9 @@ case "${ID}-${VERSION_ID}" in
6575
BOOT_ARGS="uefi"
6676
COPR_CHROOT="centos-stream-9-${ARCH}"
6777
sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-8.repo
78+
if [[ "${USE_COMPOSE_RPMS}" == true ]]; then
79+
GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-9/composes/RHEL-9/${COMPOSE_ID}/compose/AppStream/x86_64/os/Packages/"
80+
fi
6881
;;
6982
"rhel-10.2")
7083
OS_VARIANT="rhel10-unknown"
@@ -73,6 +86,9 @@ case "${ID}-${VERSION_ID}" in
7386
BOOT_ARGS="uefi"
7487
COPR_CHROOT="centos-stream-10-${ARCH}"
7588
sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-10-2.repo
89+
if [[ "${USE_COMPOSE_RPMS}" == true ]]; then
90+
GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-10/composes/RHEL-10/${COMPOSE_ID}/compose/AppStream/x86_64/os/Packages/"
91+
fi
7692
;;
7793
*)
7894
echo "unsupported distro: ${ID}-${VERSION_ID}"
@@ -201,6 +217,19 @@ greenprint "Copying test assets"
201217
cp testing_assets/failing_binary tests/
202218
)
203219

220+
###########################################################
221+
##
222+
## Optionally download greenboot rpm packages from compose
223+
##
224+
###########################################################
225+
if [[ "${USE_COMPOSE_RPMS}" == true && -n "${GREENBOOT_PACKAGES_URL}" ]]; then
226+
greenprint "Downloading greenboot RPMs from compose"
227+
rm -f greenboot-*.rpm
228+
# source: tests/common/download-compose-rpms.sh
229+
source "$(dirname "${BASH_SOURCE[0]}")/common/download-compose-rpms.sh"
230+
download_compose_rpms "${GREENBOOT_PACKAGES_URL}" "."
231+
fi
232+
204233
###########################################################
205234
##
206235
## Build bootc container with greenboot installed
@@ -213,23 +242,35 @@ tee Containerfile > /dev/null << EOF
213242
FROM ${BASE_IMAGE_URL}
214243
EOF
215244

216-
if [[ "${ID}-${VERSION_ID}" == "rhel-9.8" ]]; then
217-
tee -a Containerfile >> /dev/null << EOF
245+
if [[ "${USE_COMPOSE_RPMS}" == true && -n "${GREENBOOT_PACKAGES_URL}" ]]; then
246+
tee -a Containerfile > /dev/null << EOF
247+
COPY greenboot-*.rpm /tmp/
248+
RUN dnf install -y /tmp/greenboot-*.rpm && \
249+
rm -f /tmp/greenboot-*.rpm && \
250+
systemctl enable greenboot-healthcheck.service
251+
EOF
252+
else
253+
if [[ "${ID}-${VERSION_ID}" == "rhel-9.8" ]]; then
254+
tee -a Containerfile > /dev/null << EOF
218255
COPY files/rhel-9-8.repo /etc/yum.repos.d/rhel-9-8.repo
219256
EOF
220-
fi
257+
fi
221258

222-
if [[ "${ID}-${VERSION_ID}" == "rhel-10.2" ]]; then
223-
tee -a Containerfile >> /dev/null << EOF
259+
if [[ "${ID}-${VERSION_ID}" == "rhel-10.2" ]]; then
260+
tee -a Containerfile > /dev/null << EOF
224261
COPY files/rhel-10-2.repo /etc/yum.repos.d/rhel-10-2.repo
225262
EOF
226-
fi
263+
fi
227264

228-
tee -a Containerfile >> /dev/null << EOF
265+
tee -a Containerfile > /dev/null << EOF
229266
RUN (dnf install -y 'dnf5-command(copr)' || dnf install -y 'dnf-command(copr)') && \
230267
dnf copr enable -y packit/fedora-iot-greenboot-rs-${PR_NUMBER} ${COPR_CHROOT} && \
231268
dnf install -y greenboot greenboot-default-health-checks && \
232269
systemctl enable greenboot-healthcheck.service
270+
EOF
271+
fi
272+
273+
tee -a Containerfile > /dev/null << EOF
233274
RUN sed -i "s/GREENBOOT_MAX_BOOT_ATTEMPTS=3/GREENBOOT_MAX_BOOT_ATTEMPTS=5/g" /etc/greenboot/greenboot.conf
234275
RUN sed -i 's#DISABLED_HEALTHCHECKS=()#DISABLED_HEALTHCHECKS=("01_repository_dns_check.sh" "not_exit.sh")#g' /etc/greenboot/greenboot.conf
235276

tests/greenboot-bootc-qcow2.sh

Lines changed: 48 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,16 @@ EDGE_USER_PASSWORD=foobar
3838
CONSOLE_LOG=/tmp/vm-console.log
3939

4040
COPR_CHROOT=""
41+
42+
# RPM acquisition mode:
43+
# If DOWNLOAD_NODE and COMPOSE_ID are both set -> download from compose
44+
# Otherwise -> install greenboot from Copr (default)
45+
USE_COMPOSE_RPMS=false
46+
if [[ -n "${DOWNLOAD_NODE:-}" && -n "${COMPOSE_ID:-}" ]]; then
47+
USE_COMPOSE_RPMS=true
48+
fi
49+
GREENBOOT_PACKAGES_URL=""
50+
4151
case "${ID}-${VERSION_ID}" in
4252
"fedora-44")
4353
OS_VARIANT="fedora-unknown"
@@ -65,6 +75,9 @@ case "${ID}-${VERSION_ID}" in
6575
BOOT_ARGS="uefi"
6676
COPR_CHROOT="centos-stream-9-${ARCH}"
6777
sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-8.repo
78+
if [[ "${USE_COMPOSE_RPMS}" == true ]]; then
79+
GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-9/composes/RHEL-9/${COMPOSE_ID}/compose/AppStream/x86_64/os/Packages/"
80+
fi
6881
;;
6982
"rhel-10.2")
7083
OS_VARIANT="rhel10-unknown"
@@ -73,6 +86,9 @@ case "${ID}-${VERSION_ID}" in
7386
BOOT_ARGS="uefi"
7487
COPR_CHROOT="centos-stream-10-${ARCH}"
7588
sed -i "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-10-2.repo
89+
if [[ "${USE_COMPOSE_RPMS}" == true ]]; then
90+
GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-10/composes/RHEL-10/${COMPOSE_ID}/compose/AppStream/x86_64/os/Packages/"
91+
fi
7692
;;
7793
*)
7894
echo "unsupported distro: ${ID}-${VERSION_ID}"
@@ -201,6 +217,19 @@ greenprint "Copying test assets"
201217
cp testing_assets/failing_binary tests/
202218
)
203219

220+
###########################################################
221+
##
222+
## Optionally download greenboot rpm packages from compose
223+
##
224+
###########################################################
225+
if [[ "${USE_COMPOSE_RPMS}" == true && -n "${GREENBOOT_PACKAGES_URL}" ]]; then
226+
greenprint "Downloading greenboot RPMs from compose"
227+
rm -f greenboot-*.rpm
228+
# source: tests/common/download-compose-rpms.sh
229+
source "$(dirname "${BASH_SOURCE[0]}")/common/download-compose-rpms.sh"
230+
download_compose_rpms "${GREENBOOT_PACKAGES_URL}" "."
231+
fi
232+
204233
###########################################################
205234
##
206235
## Build bootc container with greenboot installed
@@ -213,23 +242,35 @@ tee Containerfile > /dev/null << EOF
213242
FROM ${BASE_IMAGE_URL}
214243
EOF
215244

216-
if [[ "${ID}-${VERSION_ID}" == "rhel-9.8" ]]; then
217-
tee -a Containerfile >> /dev/null << EOF
245+
if [[ "${USE_COMPOSE_RPMS}" == true && -n "${GREENBOOT_PACKAGES_URL}" ]]; then
246+
tee -a Containerfile > /dev/null << EOF
247+
COPY greenboot-*.rpm /tmp/
248+
RUN dnf install -y /tmp/greenboot-*.rpm && \
249+
rm -f /tmp/greenboot-*.rpm && \
250+
systemctl enable greenboot-healthcheck.service
251+
EOF
252+
else
253+
if [[ "${ID}-${VERSION_ID}" == "rhel-9.8" ]]; then
254+
tee -a Containerfile > /dev/null << EOF
218255
COPY files/rhel-9-8.repo /etc/yum.repos.d/rhel-9-8.repo
219256
EOF
220-
fi
257+
fi
221258

222-
if [[ "${ID}-${VERSION_ID}" == "rhel-10.2" ]]; then
223-
tee -a Containerfile >> /dev/null << EOF
259+
if [[ "${ID}-${VERSION_ID}" == "rhel-10.2" ]]; then
260+
tee -a Containerfile > /dev/null << EOF
224261
COPY files/rhel-10-2.repo /etc/yum.repos.d/rhel-10-2.repo
225262
EOF
226-
fi
263+
fi
227264

228-
tee -a Containerfile >> /dev/null << EOF
265+
tee -a Containerfile > /dev/null << EOF
229266
RUN (dnf install -y 'dnf5-command(copr)' || dnf install -y 'dnf-command(copr)') && \
230267
dnf copr enable -y packit/fedora-iot-greenboot-rs-${PR_NUMBER} ${COPR_CHROOT} && \
231268
dnf install -y greenboot greenboot-default-health-checks && \
232269
systemctl enable greenboot-healthcheck.service
270+
EOF
271+
fi
272+
273+
tee -a Containerfile > /dev/null << EOF
233274
RUN sed -i "s/GREENBOOT_MAX_BOOT_ATTEMPTS=3/GREENBOOT_MAX_BOOT_ATTEMPTS=5/g" /etc/greenboot/greenboot.conf
234275
RUN sed -i 's#DISABLED_HEALTHCHECKS=()#DISABLED_HEALTHCHECKS=("01_repository_dns_check.sh" "not_exit.sh")#g' /etc/greenboot/greenboot.conf
235276

tests/greenboot-ostree.sh

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,18 @@ for _ in $(seq 0 30); do
7777
sleep 10
7878
done
7979

80+
# RPM acquisition mode:
81+
# If DOWNLOAD_NODE and COMPOSE_ID are both set -> download from compose
82+
# Otherwise -> install greenboot from Copr (default)
83+
USE_COMPOSE_RPMS=false
84+
if [[ -n "${DOWNLOAD_NODE:-}" && -n "${COMPOSE_ID:-}" ]]; then
85+
USE_COMPOSE_RPMS=true
86+
fi
87+
GREENBOOT_PACKAGES_URL=""
88+
# PR_NUMBER is only needed for the Copr path; default it so `set -u` doesn't
89+
# crash when running in compose-RPM mode without it set.
90+
PR_NUMBER="${PR_NUMBER:-}"
91+
8092
# Customize repository
8193
sudo mkdir -p /etc/osbuild-composer/repositories
8294

@@ -101,9 +113,15 @@ case "${ID}-${VERSION_ID}" in
101113
"rhel-9.8")
102114
OSTREE_REF="rhel/9/${ARCH}/edge"
103115
OS_VARIANT="rhel9-unknown"
116+
{ set +x; } 2>/dev/null
104117
BOOT_LOCATION="http://${DOWNLOAD_NODE}/rhel-9/nightly/RHEL-9/latest-RHEL-9.8.0/compose/BaseOS/${ARCH}/os/"
105118
COPR_REPO_URL="https://download.copr.fedorainfracloud.org/results/packit/fedora-iot-greenboot-rs-${PR_NUMBER}/centos-stream-9-${ARCH}/"
106-
sed "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-8-0.json | sudo tee /etc/osbuild-composer/repositories/rhel-98.json > /dev/null;;
119+
if [[ "${USE_COMPOSE_RPMS}" == true ]]; then
120+
GREENBOOT_PACKAGES_URL="https://${DOWNLOAD_NODE}/rhel-9/composes/RHEL-9/${COMPOSE_ID}/compose/AppStream/${ARCH}/os/Packages/"
121+
fi
122+
sed "s/REPLACE_ME_HERE/${DOWNLOAD_NODE}/g" files/rhel-9-8-0.json | sudo tee /etc/osbuild-composer/repositories/rhel-98.json > /dev/null
123+
set -x
124+
;;
107125
*)
108126
echo "unsupported distro: ${ID}-${VERSION_ID}"
109127
exit 1;;
@@ -125,29 +143,41 @@ sudo systemctl enable --now httpd.service
125143
greenprint "Start osbuild-composer.socket"
126144
sudo systemctl enable --now osbuild-composer.socket
127145

128-
# Add Copr repo as osbuild-composer source for greenboot PR builds
129-
greenprint "Adding Copr source for greenboot PR #${PR_NUMBER}"
130-
sudo tee /tmp/greenboot-copr.toml > /dev/null << EOF
146+
if [[ "${USE_COMPOSE_RPMS}" == true && -n "${GREENBOOT_PACKAGES_URL}" ]]; then
147+
# Layer in a pre-built greenboot RPM from compose instead of Copr, e.g.
148+
# for RHEL targets where Copr only provides a CentOS Stream approximation.
149+
greenprint "Downloading greenboot RPMs from compose: ${GREENBOOT_PACKAGES_URL}"
150+
mkdir -p /var/www/html/packages
151+
# source: tests/common/download-compose-rpms.sh
152+
source "$(dirname "${BASH_SOURCE[0]}")/common/download-compose-rpms.sh"
153+
download_compose_rpms "${GREENBOOT_PACKAGES_URL}" "/var/www/html/packages"
154+
sudo createrepo_c /var/www/html/packages
155+
sudo restorecon -Rv /var/www/html/packages
156+
else
157+
# Add Copr repo as osbuild-composer source for greenboot PR builds
158+
greenprint "Adding Copr source for greenboot PR #${PR_NUMBER}"
159+
sudo tee /tmp/greenboot-copr.toml > /dev/null << EOF
131160
id = "greenboot-copr"
132161
name = "Packit Copr greenboot PR build"
133162
type = "yum-baseurl"
134163
url = "${COPR_REPO_URL}"
135164
check_gpg = false
136165
check_ssl = false
137166
EOF
138-
copr_added=false
139-
for _ in $(seq 0 30); do
140-
if sudo composer-cli sources add /tmp/greenboot-copr.toml; then
141-
copr_added=true
142-
break
143-
fi
144-
greenprint "Copr source not ready yet, retrying in 30s..."
145-
sleep 30
146-
done
167+
copr_added=false
168+
for _ in $(seq 0 30); do
169+
if sudo composer-cli sources add /tmp/greenboot-copr.toml; then
170+
copr_added=true
171+
break
172+
fi
173+
greenprint "Copr source not ready yet, retrying in 30s..."
174+
sleep 30
175+
done
147176

148-
if [ "$copr_added" = false ]; then
149-
echo "Failed to add Copr source after 30 attempts."
150-
exit 1
177+
if [ "$copr_added" = false ]; then
178+
echo "Failed to add Copr source after 30 attempts."
179+
exit 1
180+
fi
151181
fi
152182

153183
# Start firewalld

0 commit comments

Comments
 (0)