[PATCH 7/7] spec: stop trying to find unused network during deamon-network-config %post

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Since the default network now has autoaddr='yes', there is no need to
waste time during %post install looking for an unused network and
modifying the config of the default virtual network.

(It would be even simpler to just install the files directly to /etc
rather than installing to the examples and then copying to /etc, but
if we did that then someone who had manually net-undefined the default
network would keep getting it reinstalled every time there was an
update to libvirt-daemon-config-network. Of course these days someone
who wants to do that can simply dnf rm daemon-config-network if they
didn't want the stock default network config, but nobody will be
expecting that they have to do that, leading to hundreds of bug
reports about "I deleted the default network and it comes back every
time I update my packages!")

Signed-off-by: Laine Stump <laine@xxxxxxxxxx>
---
 libvirt.spec.in | 36 +++++-------------------------------
 1 file changed, 5 insertions(+), 31 deletions(-)

diff --git a/libvirt.spec.in b/libvirt.spec.in
index 51cecfa598..cb62e0dcdb 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1949,38 +1949,12 @@ exit 0
 %libvirt_systemd_config_pre virtnetworkd
 
 %post daemon-config-network
+# Installing during %post via cp rather than directly as a part of the package manifest
+# prevents us from reinstalling on update in cases where the user has net-undefined
+# the default network (and so doesn't *want* it to be reinstalled)
 if test $1 -eq 1 && test ! -f %{_sysconfdir}/libvirt/qemu/networks/default.xml ; then
-    # see if the network used by default network creates a conflict,
-    # and try to resolve it
-    # NB: 192.168.122.0/24 is used in the default.xml template file;
-    # do not modify any of those values here without also modifying
-    # them in the template.
-    orig_sub=122
-    sub=${orig_sub}
-    nl='
-'
-    routes="${nl}$(ip route show | cut -d' ' -f1)${nl}"
-    case ${routes} in
-      *"${nl}192.168.${orig_sub}.0/24${nl}"*)
-        # there was a match, so we need to look for an unused subnet
-        for new_sub in $(seq 124 254); do
-          case ${routes} in
-          *"${nl}192.168.${new_sub}.0/24${nl}"*)
-            ;;
-          *)
-            sub=$new_sub
-            break;
-            ;;
-          esac
-        done
-        ;;
-      *)
-        ;;
-    esac
-
-    sed -e "s/${orig_sub}/${sub}/g" \
-         < %{_datadir}/libvirt/networks/default.xml \
-         > %{_sysconfdir}/libvirt/qemu/networks/default.xml
+    cp %{_datadir}/libvirt/networks/default.xml \
+       %{_sysconfdir}/libvirt/qemu/networks/default.xml
     ln -s ../default.xml %{_sysconfdir}/libvirt/qemu/networks/autostart/default.xml
     # libvirt saves this file with mode 0600
     chmod 0600 %{_sysconfdir}/libvirt/qemu/networks/default.xml
-- 
2.45.2




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux