Skip to content

Commit a4ac87a

Browse files
test: allow testing brew builds experiment
1 parent 8cb6043 commit a4ac87a

4 files changed

Lines changed: 147 additions & 21 deletions

File tree

files/rhel-10-2.repo

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[RHEL-10.2-NIGHTLY-BaseOS]
2+
name=baseos
3+
baseurl=http://REPLACE_ME_HERE/rhel-10/nightly/RHEL-10/latest-RHEL-10.2/compose/BaseOS/$basearch/os
4+
enabled=1
5+
# Nightly compose builds are not GPG-signed; gpgcheck=0 is intentional.
6+
gpgcheck=0
7+
[RHEL-10.2-NIGHTLY-AppStream]
8+
name=appstream
9+
baseurl=http://REPLACE_ME_HERE/rhel-10/nightly/RHEL-10/latest-RHEL-10.2/compose/AppStream/$basearch/os/
10+
enabled=1
11+
# Nightly compose builds are not GPG-signed; gpgcheck=0 is intentional.
12+
gpgcheck=0

test/bootc/utils.sh

Lines changed: 72 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,21 +31,73 @@ case "${ID}-${VERSION_ID}" in
3131
base_image_url="quay.io/centos-bootc/centos-bootc:stream${VERSION_ID}"
3232
boot_args="uefi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=no"
3333
;;
34+
rhel-10*)
35+
os_variant="rhel10-unknown"
36+
base_image_url="${BOOTC_BASE_IMAGE:-registry.redhat.io/rhel10/rhel-bootc:${VERSION_ID}}"
37+
boot_args="uefi,firmware.feature0.name=secure-boot,firmware.feature0.enabled=no"
38+
;;
3439
*)
3540
log_error "Unsupported distro: ${ID}-${VERSION_ID}"
3641
exit 1
3742
;;
3843
esac
3944

4045
build_bootc_container() {
41-
tee Containerfile >/dev/null <<EOF
46+
# For any RHEL host, generate a repo file pointing at the nightly compose so
47+
# that the container image can reach RHEL packages. The file is generated at
48+
# runtime (rather than kept as a static template) so it works for any RHEL
49+
# minor version (10.2, 10.3, …) without code changes.
50+
local rhel_repo_file=""
51+
if [[ "${ID}" == "rhel" ]] && [ -n "${DOWNLOAD_NODE:-}" ]; then
52+
local major_ver="${VERSION_ID%%.*}" # e.g. "10" from "10.2"
53+
rhel_repo_file="files/rhel-${VERSION_ID}.repo"
54+
mkdir -p files
55+
cat > "${rhel_repo_file}" << EOF
56+
[RHEL-${VERSION_ID}-NIGHTLY-BaseOS]
57+
name=baseos
58+
baseurl=http://${DOWNLOAD_NODE}/rhel-${major_ver}/nightly/RHEL-${major_ver}/latest-RHEL-${VERSION_ID}/compose/BaseOS/\$basearch/os
59+
enabled=1
60+
# Nightly compose builds are not GPG-signed; gpgcheck=0 is intentional.
61+
gpgcheck=0
62+
[RHEL-${VERSION_ID}-NIGHTLY-AppStream]
63+
name=appstream
64+
baseurl=http://${DOWNLOAD_NODE}/rhel-${major_ver}/nightly/RHEL-${major_ver}/latest-RHEL-${VERSION_ID}/compose/AppStream/\$basearch/os/
65+
enabled=1
66+
# Nightly compose builds are not GPG-signed; gpgcheck=0 is intentional.
67+
gpgcheck=0
68+
EOF
69+
fi
70+
71+
if [ -n "${CLIENT_RPM_URL:-}" ]; then
72+
# Install go-fdo-client from a specific brew build base path.
73+
# CLIENT_RPM_URL should point to the version/release directory of the package in brew.
74+
local url
75+
url=$(parse_brew_url "${CLIENT_RPM_URL}")
76+
tee Containerfile >/dev/null <<EOF
77+
FROM ${base_image_url}
78+
# --nogpgcheck and sslverify=false are intentional: internal brew servers
79+
# use self-signed certificates and builds may not be GPG-signed.
80+
RUN dnf install -y --nogpgcheck --setopt=sslverify=false \
81+
"${url}/${_brew_arch}/go-fdo-client-${_brew_ver}-${_brew_rel}.${_brew_arch}.rpm"
82+
EOF
83+
else
84+
tee Containerfile >/dev/null <<EOF
4285
FROM ${base_image_url}
4386
RUN dnf=\$(readlink \$(command -v dnf)); [ "\${dnf}" = "dnf5" ] || dnf=dnf ; \
4487
rpm -q --whatprovides \${dnf}'-command(copr)' &> /dev/null || \${dnf} install -y \${dnf}'-command(copr)'; \
4588
\${dnf} copr enable -y '@fedora-iot/fedora-iot'; \
4689
\${dnf} install -y go-fdo-client; \
4790
\${dnf} copr disable -y @fedora-iot/fedora-iot
4891
EOF
92+
fi
93+
94+
# Append the RHEL repo file into the container image when it was generated.
95+
if [ -n "${rhel_repo_file}" ]; then
96+
tee -a Containerfile >/dev/null << EOF
97+
COPY ${rhel_repo_file} /etc/yum.repos.d/rhel-${VERSION_ID}.repo
98+
EOF
99+
fi
100+
49101
podman build --retry=5 --retry-delay=10s -t "fdo-bootc:latest" -f Containerfile .
50102
}
51103

@@ -99,19 +151,33 @@ echo "admin ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/admin' "${new_ks_file}"
99151
}
100152

101153
install_server() {
102-
if [ ! -v "PACKIT_COPR_RPMS" ]; then
154+
if [ -v "PACKIT_COPR_RPMS" ]; then
155+
echo " - Expected RPMs: ${PACKIT_COPR_RPMS}"
156+
elif [ -n "${SERVER_RPM_URL:-}" ]; then
157+
# Install from a specific brew build base path.
158+
# SERVER_RPM_URL should point to the version/release directory of the package in brew.
159+
local url
160+
url=$(parse_brew_url "${SERVER_RPM_URL}")
161+
# --nogpgcheck and sslverify=false are intentional: internal brew servers
162+
# use self-signed certificates and builds may not be GPG-signed.
163+
sudo dnf install -y --nogpgcheck --setopt=sslverify=false \
164+
"${url}/${_brew_arch}/go-fdo-server-${_brew_ver}-${_brew_rel}.${_brew_arch}.rpm" \
165+
"${url}/noarch/go-fdo-server-manufacturer-${_brew_ver}-${_brew_rel}.noarch.rpm" \
166+
"${url}/noarch/go-fdo-server-owner-${_brew_ver}-${_brew_rel}.noarch.rpm" \
167+
"${url}/noarch/go-fdo-server-rendezvous-${_brew_ver}-${_brew_rel}.noarch.rpm"
168+
else
103169
sudo dnf install -y golang make
104170
commit="$(git rev-parse --short HEAD)"
105171
rpm -q go-fdo-server | grep -q "go-fdo-server.*git${commit}.*" || {
106172
make rpm
107173
sudo dnf install -y rpmbuild/rpms/{noarch,"$(uname -m)"}/*git"${commit}"*.rpm
108174
}
109-
else
110-
echo " - Expected RPMs: ${PACKIT_COPR_RPMS}"
111175
fi
112-
# Make sure the RPMS are installed
113176
installed_rpms=$(rpm -q --qf "%{nvr}.%{arch} " go-fdo-server{,-{manufacturer,owner,rendezvous}})
114-
echo " - Installed RPMs: ${installed_rpms}"
177+
log_info "Installed Go FDO Server RPMs:"
178+
for i in ${installed_rpms}; do
179+
echo "$i"
180+
done
115181
}
116182

117183
install_client() {

test/ci/utils.sh

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -396,13 +396,40 @@ stop_services() {
396396
done
397397
}
398398

399+
# Parse a brew build base URL into its components.
400+
# The URL must point to the version/release directory of the package in brew.
401+
# Sets _brew_ver, _brew_rel, _brew_arch and returns the trailing-slash-stripped
402+
# URL on stdout so callers can capture it with: local url; url=$(parse_brew_url …)
403+
parse_brew_url() {
404+
local url="${1%/}" # strip any trailing slash to prevent empty basename
405+
_brew_ver=$(basename "$(dirname "${url}")")
406+
_brew_rel=$(basename "${url}")
407+
_brew_arch=$(uname -m)
408+
echo "${url}"
409+
}
410+
399411
install_client() {
400-
go install github.com/fido-device-onboard/go-fdo-client@main
412+
if [ -n "${CLIENT_RPM_URL:-}" ]; then
413+
# Install from a specific brew build base path.
414+
# CLIENT_RPM_URL should point to the version/release directory of the package in brew.
415+
local url
416+
url=$(parse_brew_url "${CLIENT_RPM_URL}")
417+
# --nogpgcheck and sslverify=false are intentional: internal brew servers
418+
# use self-signed certificates and builds may not be GPG-signed.
419+
sudo dnf install -y --nogpgcheck --setopt=sslverify=false \
420+
"${url}/${_brew_arch}/go-fdo-client-${_brew_ver}-${_brew_rel}.${_brew_arch}.rpm"
421+
else
422+
go install github.com/fido-device-onboard/go-fdo-client@main
423+
fi
401424
}
402425

403426
uninstall_client() {
404427
log_info "Uninstalling client"
405-
rm -vf "$(go env GOPATH)/bin/go-fdo-client"
428+
if [ -n "${CLIENT_RPM_URL:-}" ]; then
429+
sudo dnf remove -y go-fdo-client
430+
else
431+
rm -vf "$(go env GOPATH)/bin/go-fdo-client"
432+
fi
406433
}
407434

408435
install_server() {

test/rpm/utils.sh

Lines changed: 34 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -212,9 +212,21 @@ install_from_copr() {
212212
}
213213

214214
install_client() {
215-
# If PACKIT_COPR_RPMS is not defined it means we are running the test
216-
# locally so we will install the client from the copr repo
217-
[ -v "PACKIT_COPR_RPMS" ] || rpm -q go-fdo-client &>/dev/null || install_from_copr go-fdo-client
215+
if [ -v "PACKIT_COPR_RPMS" ]; then
216+
: # pre-installed by CI
217+
elif [ -n "${CLIENT_RPM_URL:-}" ]; then
218+
# Install from a specific brew build base path.
219+
# CLIENT_RPM_URL should point to the version/release directory of the package in brew.
220+
local url
221+
url=$(parse_brew_url "${CLIENT_RPM_URL}")
222+
# --nogpgcheck and sslverify=false are intentional: internal brew servers
223+
# use self-signed certificates and builds may not be GPG-signed.
224+
sudo dnf install -y --nogpgcheck --setopt=sslverify=false \
225+
"${url}/${_brew_arch}/go-fdo-client-${_brew_ver}-${_brew_rel}.${_brew_arch}.rpm"
226+
else
227+
# If running locally install the client from the COPR repo
228+
rpm -q go-fdo-client &>/dev/null || install_from_copr go-fdo-client
229+
fi
218230
log_info "Installed Client RPM:"
219231
echo "$(rpm -q go-fdo-client)"
220232
}
@@ -224,26 +236,34 @@ uninstall_client() {
224236
# after a successful execution.
225237
[ -v "PACKIT_COPR_RPMS" ] || {
226238
sudo dnf remove -y go-fdo-client
227-
sudo dnf copr remove -y @fedora-iot/fedora-iot
239+
# 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
228241
}
229242
}
230243

231244
install_server() {
232-
# If PACKIT_COPR_RPMS is not defined it means we are running the test
233-
# locally so we will build and install the RPMs from the *committed* code
234-
if [ ! -v "PACKIT_COPR_RPMS" ]; then
245+
if [ -v "PACKIT_COPR_RPMS" ]; then
246+
: # pre-installed by CI
247+
elif [ -n "${SERVER_RPM_URL:-}" ]; then
248+
# Install from a specific brew build base path.
249+
# SERVER_RPM_URL should point to the version/release directory of the package in brew.
250+
local url
251+
url=$(parse_brew_url "${SERVER_RPM_URL}")
252+
# --nogpgcheck and sslverify=false are intentional: internal brew servers
253+
# use self-signed certificates and builds may not be GPG-signed.
254+
sudo dnf install -y --nogpgcheck --setopt=sslverify=false \
255+
"${url}/${_brew_arch}/go-fdo-server-${_brew_ver}-${_brew_rel}.${_brew_arch}.rpm" \
256+
"${url}/noarch/go-fdo-server-manufacturer-${_brew_ver}-${_brew_rel}.noarch.rpm" \
257+
"${url}/noarch/go-fdo-server-owner-${_brew_ver}-${_brew_rel}.noarch.rpm" \
258+
"${url}/noarch/go-fdo-server-rendezvous-${_brew_ver}-${_brew_rel}.noarch.rpm"
259+
else
260+
# Running locally — build and install RPMs from the committed code
235261
commit="$(git rev-parse --short HEAD)"
236262
rpm -q go-fdo-server | grep -q "go-fdo-server.*git${commit}.*" || {
237263
make rpm
238264
sudo dnf install -y rpmbuild/rpms/{noarch,"$(uname -m)"}/*git"${commit}"*.rpm
239265
}
240-
else
241-
log_info "Expected Server RPMs:"
242-
for i in ${PACKIT_COPR_RPMS}; do
243-
echo "$i"
244-
done | sort
245266
fi
246-
# Make sure the RPMS are installed
247267
installed_rpms=$(rpm -q --qf "%{nvr}.%{arch} " go-fdo-server{,-{manufacturer,owner,rendezvous}})
248268
log_info "Installed Server RPMs:"
249269
for i in ${installed_rpms}; do
@@ -255,6 +275,7 @@ uninstall_server() {
255275
[ -v "PACKIT_COPR_RPMS" ] || sudo dnf remove -y go-fdo-server{,-manufacturer,-owner,-rendezvous}
256276
}
257277

278+
258279
start_service_manufacturer() {
259280
sudo systemctl start go-fdo-server-manufacturer
260281
}

0 commit comments

Comments
 (0)