From 99ea70b49a6d7c8265b2d4ea657ccd8e67413377 Mon Sep 17 00:00:00 2001 From: Jiri Denemark Date: Wed, 12 Apr 2017 21:36:01 +0200 Subject: [PATCH] spec: Avoid RPM verification errors on nwfilter XMLs /etc/libvirt/nwfilter/*.xml files are installed with no UUID, which means libvirtd will automatically alter all of them once it starts. Thus RPM verification will always fail on them. Let's use a trick similar to the default network XML and store nwfilter XMLs in /usr/share. They will be copied into /etc in %post. Additionally the /etc files are marked as %ghost so that they are uninstalled if the RPM package is removed. Note that the %post script overwrites existing files with new ones on upgrade, which is what has always been happening. https://bugzilla.redhat.com/show_bug.cgi?id=1431581 https://bugzilla.redhat.com/show_bug.cgi?id=1378774 Signed-off-by: Jiri Denemark (cherry picked from commit 1d3963dba5b8fbaa1d465d642d516be530618d25) --- libvirt.spec.in | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/libvirt.spec.in b/libvirt.spec.in index 0ece3c85d5..8eb67fa2ed 100644 --- a/libvirt.spec.in +++ b/libvirt.spec.in @@ -1238,6 +1238,13 @@ cp $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu/networks/default.xml \ $RPM_BUILD_ROOT%{_datadir}/libvirt/networks/default.xml rm -f $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu/networks/default.xml rm -f $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/qemu/networks/autostart/default.xml + +# nwfilter files are installed in /usr/share/libvirt and copied to /etc in %post +# to avoid verification errors on changed files in /etc +install -d -m 0755 $RPM_BUILD_ROOT%{_datadir}/libvirt/nwfilter/ +cp -a $RPM_BUILD_ROOT%{_sysconfdir}/libvirt/nwfilter/*.xml \ + $RPM_BUILD_ROOT%{_datadir}/libvirt/nwfilter/ + # Strip auto-generated UUID - we need it generated per-install sed -i -e "//d" $RPM_BUILD_ROOT%{_datadir}/libvirt/networks/default.xml %if ! %{with_qemu} @@ -1465,6 +1472,17 @@ if test $1 -eq 1 && test ! -f %{_sysconfdir}/libvirt/qemu/networks/default.xml ; fi + +%post daemon-config-nwfilter +cp %{_datadir}/libvirt/nwfilter/*.xml %{_sysconfdir}/libvirt/nwfilter/ +# Make sure libvirt picks up the new nwfilter defininitons +%if %{with_systemd} + /bin/systemctl try-restart libvirtd.service >/dev/null 2>&1 ||: +%else + /sbin/service libvirtd condrestart > /dev/null 2>&1 || : +%endif + + %if %{with_systemd} %triggerun -- libvirt < 0.9.4 %{_bindir}/systemd-sysv-convert --save libvirtd >/dev/null 2>&1 ||: @@ -1645,7 +1663,9 @@ exit 0 %{_datadir}/libvirt/networks/default.xml %files daemon-config-nwfilter -%{_sysconfdir}/libvirt/nwfilter/*.xml +%dir %{_datadir}/libvirt/nwfilter/ +%{_datadir}/libvirt/nwfilter/*.xml +%ghost %{_sysconfdir}/libvirt/nwfilter/*.xml %files daemon-driver-interface %{_libdir}/%{name}/connection-driver/libvirt_driver_interface.so