Skip to content

Commit aa88912

Browse files
ci: add compose repository support for RPM and bootc tests
Signed-off-by: Mario Cattamo <mcattamo@redhat.com>
1 parent a4ac87a commit aa88912

2 files changed

Lines changed: 98 additions & 5 deletions

File tree

test/bootc/utils.sh

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,14 @@ baseurl=http://${DOWNLOAD_NODE}/rhel-${major_ver}/nightly/RHEL-${major_ver}/late
5959
enabled=1
6060
# Nightly compose builds are not GPG-signed; gpgcheck=0 is intentional.
6161
gpgcheck=0
62+
sslverify=0
6263
[RHEL-${VERSION_ID}-NIGHTLY-AppStream]
6364
name=appstream
6465
baseurl=http://${DOWNLOAD_NODE}/rhel-${major_ver}/nightly/RHEL-${major_ver}/latest-RHEL-${VERSION_ID}/compose/AppStream/\$basearch/os/
6566
enabled=1
6667
# Nightly compose builds are not GPG-signed; gpgcheck=0 is intentional.
6768
gpgcheck=0
69+
sslverify=0
6870
EOF
6971
fi
7072

@@ -79,6 +81,32 @@ FROM ${base_image_url}
7981
# use self-signed certificates and builds may not be GPG-signed.
8082
RUN dnf install -y --nogpgcheck --setopt=sslverify=false \
8183
"${url}/${_brew_arch}/go-fdo-client-${_brew_ver}-${_brew_rel}.${_brew_arch}.rpm"
84+
EOF
85+
elif [ -n "${COMPOSE_BASE_URL:-}" ]; then
86+
# Install go-fdo-client from a compose repository.
87+
# Generate per-stream repo files, copy them into the image, install, then remove them.
88+
local compose_streams="${COMPOSE_STREAMS:-BaseOS AppStream}"
89+
local arch
90+
arch=$(uname -m)
91+
mkdir -p files
92+
local repo_args=""
93+
for stream in ${compose_streams}; do
94+
local repo_name="compose-${ID}-${VERSION_ID}-${stream}"
95+
local repo_file="files/${repo_name}.repo"
96+
cat > "${repo_file}" <<EOF
97+
[${repo_name}]
98+
name=${repo_name}
99+
baseurl=${COMPOSE_BASE_URL}/${stream}/${arch}/os/
100+
enabled=1
101+
gpgcheck=0
102+
sslverify=0
103+
EOF
104+
repo_args+="COPY ${repo_file} /etc/yum.repos.d/${repo_name}.repo"$'\n'
105+
done
106+
tee Containerfile >/dev/null <<EOF
107+
FROM ${base_image_url}
108+
${repo_args}RUN dnf install -y --disablerepo='*' --enablerepo='compose-*' go-fdo-client && \
109+
rm -f /etc/yum.repos.d/compose-*.repo
82110
EOF
83111
else
84112
tee Containerfile >/dev/null <<EOF
@@ -165,6 +193,8 @@ install_server() {
165193
"${url}/noarch/go-fdo-server-manufacturer-${_brew_ver}-${_brew_rel}.noarch.rpm" \
166194
"${url}/noarch/go-fdo-server-owner-${_brew_ver}-${_brew_rel}.noarch.rpm" \
167195
"${url}/noarch/go-fdo-server-rendezvous-${_brew_ver}-${_brew_rel}.noarch.rpm"
196+
elif [ -n "${COMPOSE_BASE_URL:-}" ]; then
197+
install_from_compose ${go_fdo_server_rpms}
168198
else
169199
sudo dnf install -y golang make
170200
commit="$(git rev-parse --short HEAD)"
@@ -173,7 +203,7 @@ install_server() {
173203
sudo dnf install -y rpmbuild/rpms/{noarch,"$(uname -m)"}/*git"${commit}"*.rpm
174204
}
175205
fi
176-
installed_rpms=$(rpm -q --qf "%{nvr}.%{arch} " go-fdo-server{,-{manufacturer,owner,rendezvous}})
206+
installed_rpms=$(rpm -q --qf "%{nvr}.%{arch} " ${go_fdo_server_rpms})
177207
log_info "Installed Go FDO Server RPMs:"
178208
for i in ${installed_rpms}; do
179209
echo "$i"

test/rpm/utils.sh

Lines changed: 67 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,9 @@ configure_service_owner() {
202202
sudo chown -R ${rpm_owner_user}:${rpm_server_group} ${rpm_owner_home_dir}
203203
}
204204

205+
go_fdo_server_rpms="go-fdo-server go-fdo-server-manufacturer go-fdo-server-owner go-fdo-server-rendezvous"
206+
go_fdo_client_rpms="go-fdo-client"
207+
205208
install_from_copr() {
206209
rpm -q --whatprovides 'dnf-command(copr)' &>/dev/null || sudo dnf install -y 'dnf-command(copr)'
207210
dnf copr list | grep 'fedora-iot/fedora-iot' || sudo dnf copr enable -y @fedora-iot/fedora-iot
@@ -211,6 +214,62 @@ install_from_copr() {
211214
sudo dnf copr disable -y @fedora-iot/fedora-iot
212215
}
213216

217+
# Install RPM packages from a compose repository.
218+
#
219+
# The compose base URL is read from COMPOSE_BASE_URL. For Fedora and CentOS a
220+
# reasonable default is computed from /etc/os-release; for RHEL the variable is
221+
# mandatory. COMPOSE_STREAMS optionally overrides the space-separated list of
222+
# stream names (repo sub-directories) to enable.
223+
install_from_compose() {
224+
# shellcheck source=/dev/null
225+
source /etc/os-release
226+
local compose_host compose_id compose_base_url compose_streams
227+
case "${ID}-${VERSION_ID}" in
228+
fedora-rawhide)
229+
compose_host="http://kojipkgs.fedoraproject.org"
230+
compose_id="latest-Fedora-${VERSION_ID^}"
231+
compose_streams="${COMPOSE_STREAMS:-Everything}"
232+
compose_base_url="${COMPOSE_BASE_URL:-${compose_host}/compose/${VERSION_ID}/${compose_id}/compose}"
233+
;;
234+
fedora-*)
235+
compose_host="http://kojipkgs.fedoraproject.org"
236+
compose_streams="${COMPOSE_STREAMS:-Everything}"
237+
compose_base_url="${COMPOSE_BASE_URL:-${compose_host}/compose/updates/f${VERSION_ID}-updates/compose}"
238+
;;
239+
centos-*)
240+
compose_host="https://composes.stream.centos.org"
241+
compose_id="latest-CentOS-Stream"
242+
compose_streams="${COMPOSE_STREAMS:-BaseOS AppStream}"
243+
compose_base_url="${COMPOSE_BASE_URL:-${compose_host}/stream-${VERSION_ID}/production/${compose_id}/compose}"
244+
;;
245+
rhel-*)
246+
compose_base_url="${COMPOSE_BASE_URL:-}"
247+
[ -n "${compose_base_url}" ] || log_error "COMPOSE_BASE_URL must be set for RHEL (e.g. 'http://download.host/.../latest-RHEL-Compose/compose/')"
248+
compose_streams="${COMPOSE_STREAMS:-BaseOS AppStream}"
249+
[ -n "${compose_streams}" ] || log_error "COMPOSE_STREAMS must be set for RHEL (default='BaseOS AppStream')"
250+
;;
251+
*)
252+
log_error "install_from_compose: unsupported OS '${ID}-${VERSION_ID}'"
253+
;;
254+
esac
255+
256+
local arch
257+
arch=$(uname -m)
258+
for stream in ${compose_streams}; do
259+
local repo_name="compose-${ID}-${VERSION_ID}-${stream}"
260+
sudo tee "/etc/yum.repos.d/${repo_name}.repo" >/dev/null <<EOF
261+
[${repo_name}]
262+
name=${repo_name}
263+
baseurl=${compose_base_url}/${stream}/${arch}/os/
264+
enabled=1
265+
gpgcheck=0
266+
sslverify=0
267+
EOF
268+
done
269+
sudo dnf install --disablerepo=* --enablerepo="compose-*" -y "$@"
270+
sudo rm -f /etc/yum.repos.d/compose-*.repo
271+
}
272+
214273
install_client() {
215274
if [ -v "PACKIT_COPR_RPMS" ]; then
216275
: # pre-installed by CI
@@ -223,6 +282,8 @@ install_client() {
223282
# use self-signed certificates and builds may not be GPG-signed.
224283
sudo dnf install -y --nogpgcheck --setopt=sslverify=false \
225284
"${url}/${_brew_arch}/go-fdo-client-${_brew_ver}-${_brew_rel}.${_brew_arch}.rpm"
285+
elif [ -n "${COMPOSE_BASE_URL:-}" ]; then
286+
install_from_compose ${go_fdo_client_rpms}
226287
else
227288
# If running locally install the client from the COPR repo
228289
rpm -q go-fdo-client &>/dev/null || install_from_copr go-fdo-client
@@ -235,9 +296,9 @@ uninstall_client() {
235296
# When running a test locally we remove the client package
236297
# after a successful execution.
237298
[ -v "PACKIT_COPR_RPMS" ] || {
238-
sudo dnf remove -y go-fdo-client
299+
sudo dnf remove -y ${go_fdo_client_rpms}
239300
# Only remove the COPR repo when it was used for installation
240-
[ -n "${CLIENT_RPM_URL:-}" ] || sudo dnf copr remove -y @fedora-iot/fedora-iot
301+
[ -n "${CLIENT_RPM_URL:-}" ] || [ -n "${COMPOSE_BASE_URL:-}" ] || sudo dnf copr remove -y @fedora-iot/fedora-iot
241302
}
242303
}
243304

@@ -256,6 +317,8 @@ install_server() {
256317
"${url}/noarch/go-fdo-server-manufacturer-${_brew_ver}-${_brew_rel}.noarch.rpm" \
257318
"${url}/noarch/go-fdo-server-owner-${_brew_ver}-${_brew_rel}.noarch.rpm" \
258319
"${url}/noarch/go-fdo-server-rendezvous-${_brew_ver}-${_brew_rel}.noarch.rpm"
320+
elif [ -n "${COMPOSE_BASE_URL:-}" ]; then
321+
install_from_compose ${go_fdo_server_rpms}
259322
else
260323
# Running locally — build and install RPMs from the committed code
261324
commit="$(git rev-parse --short HEAD)"
@@ -264,15 +327,15 @@ install_server() {
264327
sudo dnf install -y rpmbuild/rpms/{noarch,"$(uname -m)"}/*git"${commit}"*.rpm
265328
}
266329
fi
267-
installed_rpms=$(rpm -q --qf "%{nvr}.%{arch} " go-fdo-server{,-{manufacturer,owner,rendezvous}})
330+
installed_rpms=$(rpm -q --qf "%{nvr}.%{arch} " ${go_fdo_server_rpms})
268331
log_info "Installed Server RPMs:"
269332
for i in ${installed_rpms}; do
270333
echo "$i"
271334
done | sort
272335
}
273336

274337
uninstall_server() {
275-
[ -v "PACKIT_COPR_RPMS" ] || sudo dnf remove -y go-fdo-server{,-manufacturer,-owner,-rendezvous}
338+
[ -v "PACKIT_COPR_RPMS" ] || sudo dnf remove -y ${go_fdo_server_rpms}
276339
}
277340

278341

0 commit comments

Comments
 (0)