[libvirt PATCH 1/1] libvirt.spec.in: Replace %global with %define

Erik Skultety eskultet at redhat.com
Tue Sep 21 17:30:29 UTC 2021


Commit b5e8db8f14d tuned the SPEC file so that libvirt daemons restart
on package upgrade. In order to do that it added a bunch of
parametrized macros using the %global directive. This caused a problem
when running RPM builds on CentOS Stream 8 resulting in:

error: Too many levels of recursion in macro expansion. It is likely
       caused by recursive macro declaration.
error: Macro %libvirt_daemon_perform_restart failed to expand
error: line 1275: %global libvirt_daemon_perform_restart() \
       if test %libvirt_daemon_needs_restart %1 \
       then \
           /bin/systemctl try-restart %1.service >/dev/null 2>&1 || : \
       fi \
       %libvirt_daemon_finish_restart %1

There are 2 important differences between %global and %define
directives:
1) %define is local-only and does have scope - in reality though, its
   scope is apparently not really enforced because it behaves exactly
   the same way as %global
2) %define is evaluated at the of use while %global is evaluated at the
   time of definition

The latter and the fact the macro is parametrized is the reason why the
RPM builds fails on CentOS. Strangely enough this only happens on
CentOS Stream, but not Fedora (which is also the main proponent of
replacing %define with %global). Anyhow, replacing %global with %define
makes the rpmbuild to pass on both and along with package upgrades.

Signed-off-by: Erik Skultety <eskultet at redhat.com>
---
 libvirt.spec.in | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 624b0e0302..1725e5eb14 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1259,28 +1259,28 @@ mv $RPM_BUILD_ROOT%{_datadir}/systemtap/tapset/libvirt_qemu_probes.stp \
 # raising the test timeout
 VIR_TEST_DEBUG=1 %meson_test --no-suite syntax-check --timeout-multiplier 10
 
-%global libvirt_daemon_schedule_restart() mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || : \
+%define libvirt_daemon_schedule_restart() mkdir -p %{_localstatedir}/lib/rpm-state/libvirt || : \
 /bin/systemctl is-active %1.service 1>/dev/null 2>&1 && \
   touch %{_localstatedir}/lib/rpm-state/libvirt/restart-%1 || :
 
-%global libvirt_daemon_finish_restart() rm -f %{_localstatedir}/lib/rpm-state/libvirt/restart-%1 \
+%define libvirt_daemon_finish_restart() rm -f %{_localstatedir}/lib/rpm-state/libvirt/restart-%1 \
 rmdir %{_localstatedir}/lib/rpm-state/libvirt 2>/dev/null || :
 
-%global libvirt_daemon_needs_restart() -f %{_localstatedir}/lib/rpm-state/libvirt/restart-%1
+%define libvirt_daemon_needs_restart() -f %{_localstatedir}/lib/rpm-state/libvirt/restart-%1
 
-%global libvirt_daemon_perform_restart() if test %libvirt_daemon_needs_restart %1 \
+%define libvirt_daemon_perform_restart() if test %libvirt_daemon_needs_restart %1 \
 then \
   /bin/systemctl try-restart %1.service >/dev/null 2>&1 || : \
 fi \
 %libvirt_daemon_finish_restart %1
 
-%global libvirt_daemon_systemd_post() %systemd_post %1.socket %1-ro.socket %1-admin.socket %1.service
+%define libvirt_daemon_systemd_post() %systemd_post %1.socket %1-ro.socket %1-admin.socket %1.service
 
-%global libvirt_daemon_systemd_post_inet() %systemd_post %1.socket %1-ro.socket %1-admin.socket %1-tls.socket %1-tcp.socket %1.service
+%define libvirt_daemon_systemd_post_inet() %systemd_post %1.socket %1-ro.socket %1-admin.socket %1-tls.socket %1-tcp.socket %1.service
 
-%global libvirt_daemon_systemd_preun() %systemd_preun %1.service %1-ro.socket %1-admin.socket %1.socket
+%define libvirt_daemon_systemd_preun() %systemd_preun %1.service %1-ro.socket %1-admin.socket %1.socket
 
-%global libvirt_daemon_systemd_preun_inet() %systemd_preun %1.service %1-ro.socket %1-admin.socket %1-tls.socket %1-tcp.socket %1.socket
+%define libvirt_daemon_systemd_preun_inet() %systemd_preun %1.service %1-ro.socket %1-admin.socket %1-tls.socket %1-tcp.socket %1.socket
 
 %pre daemon
 # 'libvirt' group is just to allow password-less polkit access to
-- 
2.31.1




More information about the libvir-list mailing list