On 12/3/20 12:31 PM, Andrea Bolognani wrote:
On Thu, 2020-12-03 at 17:39 +0100, Michal Privoznik wrote:
On 10/26/20 10:21 AM, Nikolay Shirokovskiy wrote:
-cp %{_datadir}/libvirt/nwfilter/*.xml %{_sysconfdir}/libvirt/nwfilter/
+# keep existing filters uuid on update
+for dfile in %{_datadir}/libvirt/nwfilter/*.xml; do
+ sfile=%{_sysconfdir}/libvirt/nwfilter/`basename $dfile`
+ if [ -f "$sfile" ]; then
+ uuidstr=`sed -n '/<uuid>.*<\/uuid>/p' "$sfile"`
+ if [ ! -z "$uuidstr" ]; then
+ sed -e "s,<filter .*>,&\n$uuidstr," "$dfile" > "$sfile"
+ continue
+ fi
+ fi
+ cp "$dfile" "$sfile"
+done
I wonder if we should treat these .xml files as config files. I mean,
they can be changed by user and if they have been we should not touch
them at update no matter what. But if they haven't, then we should
replace them because they may contain new, better rules.
I've read spec file documentation here and it looks like
%config(noreplace) is doing just that:
https://rpm-packaging-guide.github.io/#more-on-macros
Would that solve the issue?
I think treating them as configuration files is exactly the opposite
of what we want to do, because they contain generated data (the
UUID) and so they will *always* be different from what was included
in the package.
I believe the only sane way to deal with them is mirror what we do
for the default network, and just leave the files in /etc alone if
they already exist: the user might miss out on improvements, but
that's still preferable to potentially wipe out local changes.
Also, we need to avoid adding things to the %post script for rpms (as we
recently discussed when Andrea posted patches _removing_ similar code
for the default network from libvirt.spec.in) - Fedora SilverBlue filed
a bugzilla report about that awhile back. Instead, we should check if a
uuid was added during the parsing of the nwfilter at libvirtd startup
time, and rewrite the config if so.
Here is a pointer to Andrea's patches:
https://www.redhat.com/archives/libvir-list/2020-November/msg01101.html
And here's a message from the discussion of V1 of those patches, where
Andrea points out some of the inconsistencies in our handling of
auto-generated uuids for various config objects:
https://www.redhat.com/archives/libvir-list/2020-November/msg00970.html