]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
meson: src/network: install default network xml
authorPavel Hrdina <phrdina@redhat.com>
Thu, 23 Jul 2020 11:00:08 +0000 (13:00 +0200)
committerPavel Hrdina <phrdina@redhat.com>
Mon, 3 Aug 2020 07:27:05 +0000 (09:27 +0200)
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
scripts/meson-install-symlink.py [new file with mode: 0644]
scripts/meson.build
src/network/Makefile.inc.am
src/network/default.xml.in [moved from src/network/default.xml with 100% similarity]
src/network/meson.build

diff --git a/scripts/meson-install-symlink.py b/scripts/meson-install-symlink.py
new file mode 100644 (file)
index 0000000..e385070
--- /dev/null
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+
+import os
+import sys
+
+destdir = os.environ.get('DESTDIR', os.sep)
+dirname = sys.argv[1]
+target = sys.argv[2]
+link = sys.argv[3]
+
+workdir = os.path.join(destdir, dirname.strip(os.sep))
+
+os.makedirs(workdir, exist_ok=True)
+os.chdir(workdir)
+os.symlink(target, link)
index bd641236a21737b2dd68f86a94b1bbeff401443a..e1ecda2a0c79d923b68dcf5ce65ef845bcd6dd45 100644 (file)
@@ -21,6 +21,7 @@ scripts = [
   'meson-gen-def.py',
   'meson-gen-sym.py',
   'meson-install-dirs.py',
+  'meson-install-symlink.py',
   'meson-python.sh',
   'mock-noinline.py',
   'prohibit-duplicate-header.py',
index 8482f924a15fed18fbc68266cc15433fcc876536..c19b1f995293096e014909c1b12c04a68cc410f2 100644 (file)
@@ -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
index cc8739e53c543abfad03711fd972ac30a28e8aa9..e0b50a707c3cf6bcabac44b94438529b627cda45 100644 (file)
@@ -82,4 +82,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(
+    meson_python_prog.path(), python3_prog.path(), meson_install_symlink_prog.path(),
+    confdir / 'qemu' / 'networks' / 'autostart',
+    '../default.xml', 'default.xml',
+  )
 endif