[libvirt PATCH 233/351] meson: src/network: install default network xml

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

 



Signed-off-by: Pavel Hrdina <phrdina@xxxxxxxxxx>
---
 scripts/install-symlink.sh                  |  7 +++++
 scripts/meson.build                         |  1 +
 src/network/Makefile.inc.am                 | 20 -------------
 src/network/{default.xml => default.xml.in} |  0
 src/network/meson.build                     | 32 +++++++++++++++++++++
 5 files changed, 40 insertions(+), 20 deletions(-)
 create mode 100644 scripts/install-symlink.sh
 rename src/network/{default.xml => default.xml.in} (100%)

diff --git a/scripts/install-symlink.sh b/scripts/install-symlink.sh
new file mode 100644
index 00000000000..bfd1f5ad37d
--- /dev/null
+++ b/scripts/install-symlink.sh
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+mkdir -p $DESTDIR/$1
+
+cd $DESTDIR/$1
+
+ln -f -s $2 $3
diff --git a/scripts/meson.build b/scripts/meson.build
index 8e4f16349e5..3038dfc8d21 100644
--- a/scripts/meson.build
+++ b/scripts/meson.build
@@ -21,6 +21,7 @@ scripts = [
   'hvsupport.py',
   'hyperv_wmi_generator.py',
   'install-dirs.sh',
+  'install-symlink.sh',
   'meson-python.sh',
   'mock-noinline.py',
   'prohibit-duplicate-header.py',
diff --git a/src/network/Makefile.inc.am b/src/network/Makefile.inc.am
index 8482f924a15..c19b1f99529 100644
--- a/src/network/Makefile.inc.am
+++ b/src/network/Makefile.inc.am
@@ -7,23 +7,7 @@ STATEFUL_DRIVER_SOURCE_FILES += \
 if WITH_NETWORK
 INSTALL_DATA_DIRS += network
 
-UUID=$(shell uuidgen 2>/dev/null)
-
 install-data-network:
-	$(MKDIR_P) "$(DESTDIR)$(confdir)/qemu/networks/autostart"
-	$(INSTALL_DATA) $(srcdir)/network/default.xml \
-	  $(DESTDIR)$(confdir)/qemu/networks/default.xml
-	test -z "$(UUID)" || \
-	  { sed -e "s,</name>,</name>;  <uuid>$(UUID)</uuid>," \
-	      $(DESTDIR)$(confdir)/qemu/networks/default.xml | \
-	      tr ";" "\n" > \
-	      $(DESTDIR)$(confdir)/qemu/networks/default.xml.t && \
-	    cp $(DESTDIR)$(confdir)/qemu/networks/default.xml.t \
-	      $(DESTDIR)$(confdir)/qemu/networks/default.xml && \
-	    rm $(DESTDIR)$(confdir)/qemu/networks/default.xml.t; }
-	( cd $(DESTDIR)$(confdir)/qemu/networks/autostart && \
-	  rm -f default.xml && \
-	  $(LN_S) ../default.xml default.xml )
 if WITH_FIREWALLD_ZONE
 	$(MKDIR_P) "$(DESTDIR)$(prefix)/lib/firewalld/zones"
 	$(INSTALL_DATA) $(srcdir)/network/libvirt.zone \
@@ -31,10 +15,6 @@ if WITH_FIREWALLD_ZONE
 endif WITH_FIREWALLD_ZONE
 
 uninstall-data-network:
-	rm -f $(DESTDIR)$(confdir)/qemu/networks/autostart/default.xml
-	rm -f $(DESTDIR)$(confdir)/qemu/networks/default.xml
-	rmdir "$(DESTDIR)$(confdir)/qemu/networks/autostart" || :
-	rmdir "$(DESTDIR)$(confdir)/qemu/networks" || :
 if WITH_FIREWALLD_ZONE
 	rm -f  $(DESTDIR)$(prefix)/lib/firewalld/zones/libvirt.xml
 endif WITH_FIREWALLD_ZONE
diff --git a/src/network/default.xml b/src/network/default.xml.in
similarity index 100%
rename from src/network/default.xml
rename to src/network/default.xml.in
diff --git a/src/network/meson.build b/src/network/meson.build
index c2085091bce..2ca7d268c6e 100644
--- a/src/network/meson.build
+++ b/src/network/meson.build
@@ -83,4 +83,36 @@ if conf.has('WITH_NETWORK')
     localstatedir / 'lib' / 'libvirt' / 'dnsmasq',
     runstatedir / 'libvirt' / 'network',
   ]
+
+  uuidgen_prog = find_program('uuidgen', required: false)
+
+  if uuidgen_prog.found()
+    uuid = run_command(uuidgen_prog).stdout().strip()
+
+    configure_file(
+      input: 'default.xml.in',
+      output: 'default.xml',
+      command: [
+        'sed', '-e', 's|</name>|</name>\\n  <uuid>@0@</uuid>|'.format(uuid),
+        '@INPUT@',
+      ],
+      capture: true,
+      install: true,
+      install_dir: confdir / 'qemu' / 'networks',
+    )
+  else
+    configure_file(
+      input: 'default.xml.in',
+      output: 'default.xml',
+      copy: true,
+      install: true,
+      install_dir: confdir / 'qemu' / 'networks',
+    )
+  endif
+
+  meson.add_install_script(
+    install_symlink_prog.path(),
+    confdir / 'qemu' / 'networks' / 'autostart',
+    '../default.xml', 'default.xml',
+  )
 endif
-- 
2.26.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