Skip to content

Commit

Permalink
meson: src/network: install default network xml
Browse files Browse the repository at this point in the history
Signed-off-by: Pavel Hrdina <[email protected]>
Reviewed-by: Peter Krempa <[email protected]>
Reviewed-by: Neal Gompa <[email protected]>
  • Loading branch information
phrdina committed Aug 3, 2020
1 parent f7ca387 commit c957791
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 20 deletions.
15 changes: 15 additions & 0 deletions scripts/meson-install-symlink.py
Original file line number Diff line number Diff line change
@@ -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)
1 change: 1 addition & 0 deletions scripts/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
20 changes: 0 additions & 20 deletions src/network/Makefile.inc.am
Original file line number Diff line number Diff line change
Expand Up @@ -7,34 +7,14 @@ 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 \
$(DESTDIR)$(prefix)/lib/firewalld/zones/libvirt.xml
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
Expand Down
File renamed without changes.
32 changes: 32 additions & 0 deletions src/network/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit c957791

Please sign in to comment.