@@ -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+
205208install_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,10 +214,80 @@ 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+ compose_base_url=" ${compose_base_url%/ } " # strip trailing slash to avoid double slashes in baseurl
259+ for stream in ${compose_streams} ; do
260+ local repo_name=" compose-${ID} -${VERSION_ID} -${stream} "
261+ sudo tee " /etc/yum.repos.d/${repo_name} .repo" > /dev/null << EOF
262+ [${repo_name} ]
263+ name=${repo_name}
264+ baseurl=${compose_base_url} /${stream} /${arch} /os/
265+ enabled=1
266+ gpgcheck=0
267+ sslverify=0
268+ EOF
269+ done
270+ sudo dnf install --disablerepo=* --enablerepo=" compose-*" -y " $@ "
271+ sudo rm -f /etc/yum.repos.d/compose-* .repo
272+ }
273+
214274install_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
275+ if [ -v " PACKIT_COPR_RPMS" ]; then
276+ : # pre-installed by CI
277+ elif [ -n " ${CLIENT_RPM_URL:- } " ]; then
278+ # Install from a specific brew build base path.
279+ # CLIENT_RPM_URL should point to the version/release directory of the package in brew.
280+ parse_brew_url " ${CLIENT_RPM_URL} "
281+ # --nogpgcheck and sslverify=false are intentional: internal brew servers
282+ # use self-signed certificates and builds may not be GPG-signed.
283+ sudo dnf install -y --nogpgcheck --setopt=sslverify=false \
284+ " ${_brew_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}
287+ else
288+ # If running locally install the client from the COPR repo
289+ rpm -q go-fdo-client & > /dev/null || install_from_copr go-fdo-client
290+ fi
218291 log_info " Installed Client RPM:"
219292 echo " ⚙ $( rpm -q go-fdo-client) "
220293}
@@ -223,8 +296,9 @@ uninstall_client() {
223296 # When running a test locally we remove the client package
224297 # after a successful execution.
225298 [ -v " PACKIT_COPR_RPMS" ] || {
226- sudo dnf remove -y go-fdo-client
227- sudo dnf copr remove -y @fedora-iot/fedora-iot
299+ sudo dnf remove -y ${go_fdo_client_rpms}
300+ # Only remove the COPR repo when it was used for installation
301+ [ -n " ${CLIENT_RPM_URL:- } " ] || [ -n " ${COMPOSE_BASE_URL:- } " ] || sudo dnf copr remove -y @fedora-iot/fedora-iot
228302 }
229303}
230304
@@ -240,30 +314,43 @@ run_go_fdo_client() {
240314}
241315
242316install_server () {
243- # If PACKIT_COPR_RPMS is not defined it means we are running the test
244- # locally so we will build and install the RPMs from the *committed* code
245- if [ ! -v " PACKIT_COPR_RPMS" ]; then
317+ if [ -v " PACKIT_COPR_RPMS" ]; then
318+ log_info " Expected Server RPMs:"
319+ for i in ${PACKIT_COPR_RPMS} ; do
320+ echo " ⚙ $i "
321+ done | sort
322+ elif [ -n " ${SERVER_RPM_URL:- } " ]; then
323+ # Install from a specific brew build base path.
324+ # SERVER_RPM_URL should point to the version/release directory of the package in brew.
325+ parse_brew_url " ${SERVER_RPM_URL} "
326+ # --nogpgcheck and sslverify=false are intentional: internal brew servers
327+ # use self-signed certificates and builds may not be GPG-signed.
328+ sudo dnf install -y --nogpgcheck --setopt=sslverify=false \
329+ " ${_brew_url} /${_brew_arch} /go-fdo-server-${_brew_ver} -${_brew_rel} .${_brew_arch} .rpm" \
330+ " ${_brew_url} /noarch/go-fdo-server-manufacturer-${_brew_ver} -${_brew_rel} .noarch.rpm" \
331+ " ${_brew_url} /noarch/go-fdo-server-owner-${_brew_ver} -${_brew_rel} .noarch.rpm" \
332+ " ${_brew_url} /noarch/go-fdo-server-rendezvous-${_brew_ver} -${_brew_rel} .noarch.rpm"
333+ elif [ -n " ${COMPOSE_BASE_URL:- } " ]; then
334+ install_from_compose ${go_fdo_server_rpms}
335+ else
336+ # If PACKIT_COPR_RPMS is not defined it means we are running the test
337+ # locally so we will build and install the RPMs from the *committed* code
246338 commit=" $( git rev-parse --short HEAD) "
247339 rpm -q go-fdo-server | grep -q " go-fdo-server.*git${commit} .*" || {
248340 make rpm
249341 sudo dnf install -y rpmbuild/rpms/{noarch," $( uname -m) " }/* git" ${commit} " * .rpm
250342 }
251- else
252- log_info " Expected Server RPMs:"
253- for i in ${PACKIT_COPR_RPMS} ; do
254- echo " ⚙ $i "
255- done | sort
256343 fi
257344 # Make sure the RPMS are installed
258- installed_rpms=$( rpm -q --qf " %{nvr}.%{arch} " go-fdo-server{,-{manufacturer,owner,rendezvous} })
345+ installed_rpms=$( rpm -q --qf " %{nvr}.%{arch} " ${go_fdo_server_rpms })
259346 log_info " Installed Server RPMs:"
260347 for i in ${installed_rpms} ; do
261348 echo " ⚙ $i "
262349 done | sort
263350}
264351
265352uninstall_server () {
266- [ -v " PACKIT_COPR_RPMS" ] || sudo dnf remove -y go-fdo-server{,-manufacturer,-owner,-rendezvous }
353+ [ -v " PACKIT_COPR_RPMS" ] || sudo dnf remove -y ${go_fdo_server_rpms }
267354}
268355
269356start_service_manufacturer () {
0 commit comments