Switch over to using meson for building the virsh / virt-admin
tools and supporting files.
Signed-off-by: Daniel P. Berrangé <berrange(a)redhat.com>
---
libvirt.spec.in | 20 +----
m4/virt-bash-completion.m4 | 70 ----------------
meson.build | 7 ++
meson_options.txt | 1 +
tools/Makefile.am | 123 ++-------------------------
tools/bash-completion/meson.build | 19 +++++
tools/meson.build | 134 ++++++++++++++++++++++++++++++
7 files changed, 167 insertions(+), 207 deletions(-)
delete mode 100644 m4/virt-bash-completion.m4
create mode 100644 tools/bash-completion/meson.build
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 9e33504e01..e8bcbf4fda 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -884,9 +884,6 @@ Requires: ncurses
Requires: gettext
# Needed by virt-pki-validate script.
Requires: gnutls-utils
-%if %{with_bash_completion}
-Requires: %{name}-bash-completion = %{version}-%{release}
-%endif
%description client
The client binaries needed to access the virtualization
@@ -899,6 +896,7 @@ Requires: cyrus-sasl
# Needed by default sasl.conf - no onerous extra deps, since
# 100's of other things on a system already pull in krb5-libs
Requires: cyrus-sasl-gssapi
+Obsoletes: %{name}-bash-completion <= 5.8.0
%description libs
Shared libraries for accessing the libvirt daemon.
@@ -907,21 +905,10 @@ Shared libraries for accessing the libvirt daemon.
Summary: Set of tools to control libvirt daemon
Requires: %{name}-libs = %{version}-%{release}
Requires: readline
-%if %{with_bash_completion}
-Requires: %{name}-bash-completion = %{version}-%{release}
-%endif
%description admin
The client side utilities to control the libvirt daemon.
-%if %{with_bash_completion}
-%package bash-completion
-Summary: Bash completion script
-
-%description bash-completion
-Bash completion script stub.
-%endif
-
%if %{with_wireshark}
%package wireshark
Summary: Wireshark dissector plugin for libvirt RPC transactions
@@ -1937,11 +1924,6 @@ exit 0
%{_datadir}/bash-completion/completions/virt-admin
%endif
-%if %{with_bash_completion}
-%files bash-completion
-%{_datadir}/bash-completion/completions/vsh
-%endif
-
%if %{with_wireshark}
%files wireshark
%{wireshark_plugindir}/libvirt.so
diff --git a/m4/virt-bash-completion.m4 b/m4/virt-bash-completion.m4
deleted file mode 100644
index c8342176f8..0000000000
--- a/m4/virt-bash-completion.m4
+++ /dev/null
@@ -1,70 +0,0 @@
-dnl Bash completion support
-dnl
-dnl Copyright (C) 2017 Red Hat, Inc.
-dnl
-dnl This library is free software; you can redistribute it and/or
-dnl modify it under the terms of the GNU Lesser General Public
-dnl License as published by the Free Software Foundation; either
-dnl version 2.1 of the License, or (at your option) any later version.
-dnl
-dnl This library is distributed in the hope that it will be useful,
-dnl but WITHOUT ANY WARRANTY; without even the implied warranty of
-dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-dnl Lesser General Public License for more details.
-dnl
-dnl You should have received a copy of the GNU Lesser General Public
-dnl License along with this library. If not, see
-dnl <
http://www.gnu.org/licenses/>.
-dnl
-dnl Inspired by libguestfs code.
-dnl
-
-AC_DEFUN([LIBVIRT_ARG_BASH_COMPLETION],[
- LIBVIRT_ARG_WITH_FEATURE([BASH_COMPLETION], [bash-completion], [check], [2.0])
- LIBVIRT_ARG_WITH([BASH_COMPLETIONS_DIR],
- [directory containing bash completions scripts],
- [check])
-])
-
-AC_DEFUN([LIBVIRT_CHECK_BASH_COMPLETION], [
- AC_REQUIRE([LIBVIRT_CHECK_READLINE])
-
- if test "x$with_readline" != "xyes" ; then
- if test "x$with_bash_completion" = "xyes" ; then
- AC_MSG_ERROR([readline is required for bash completion support])
- else
- with_bash_completion=no
- fi
- fi
-
- LIBVIRT_CHECK_PKG([BASH_COMPLETION], [bash-completion], [2.0])
-
- if test "x$with_bash_completion" = "xyes" ; then
- if test "x$with_bash_completions_dir" = "xcheck"; then
- AC_MSG_CHECKING([for bash-completions directory])
- BASH_COMPLETIONS_DIR="$($PKG_CONFIG --variable=completionsdir
bash-completion)"
- AC_MSG_RESULT([$BASH_COMPLETIONS_DIR])
-
- dnl Replace bash completions's exec_prefix with our own.
- dnl Note that ${exec_prefix} is kept verbatim at this point in time,
- dnl and will only be expanded later, when make is called: this makes
- dnl it possible to override such prefix at compilation or installation
- dnl time
- bash_completions_prefix="$($PKG_CONFIG --variable=prefix
bash-completion)"
- if test "x$bash_completions_prefix" = "x" ; then
- bash_completions_prefix="/usr"
- fi
-
-
BASH_COMPLETIONS_DIR='${exec_prefix}'"${BASH_COMPLETIONS_DIR#$bash_completions_prefix}"
- elif test "x$with_bash_completions_dir" = "xno" || test
"x$with_bash_completions_dir" = "xyes"; then
- AC_MSG_ERROR([bash-completions-dir must be used only with valid path])
- else
- BASH_COMPLETIONS_DIR=$with_bash_completions_dir
- fi
- AC_SUBST([BASH_COMPLETIONS_DIR])
- fi
-])
-
-AC_DEFUN([LIBVIRT_RESULT_BASH_COMPLETION],[
- LIBVIRT_RESULT_LIB([BASH_COMPLETION])
-])
diff --git a/meson.build b/meson.build
index bda0ee0373..0178750c88 100644
--- a/meson.build
+++ b/meson.build
@@ -38,9 +38,16 @@ meson.add_dist_script('build-aux' / 'dist.py',
meson.source_root(), meson.build_
yajl_min_version = '>= 2.0.3'
libxml_min_version = '>= 2.9.1'
+readline_min_version = '>= 7.0'
+bash_completion_min_version = '>= 2.0'
+threads_dep = dependency('threads')
yajl_dep = dependency('yajl', version: yajl_min_version)
libxml_dep = dependency('libxml-2.0', version: libxml_min_version)
+readline_dep = dependency('readline', version: readline_min_version)
+bash_completion_dep = dependency('bash-completion', version:
bash_completion_min_version)
+
+bash_completion_dir =
bash_completion_dep.get_pkgconfig_variable('completionsdir', define_variable:
['prefix', prefix])
subdir('src')
subdir('examples')
diff --git a/meson_options.txt b/meson_options.txt
index d092f30ba7..6f7392a9e3 100644
--- a/meson_options.txt
+++ b/meson_options.txt
@@ -24,3 +24,4 @@ option('with-driver-storage', type: 'boolean', value:
true, description: 'Enable
option('with-tools-host-validate', type: 'boolean', value: true,
description: 'Enable virt-host-validate tool')
option('with-tools-login-shell', type: 'boolean', value: true,
description: 'Enable virt-login-shell tool')
+option('with-tools-bash-completion', type: 'boolean', value: true,
description: 'Enable bash completion')
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 94146632cb..6578295392 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -52,19 +52,16 @@ ICON_FILES = \
virsh_win_icon.rc
PODFILES = \
- virt-admin.pod \
virt-pki-validate.pod \
virt-sanlock-cleanup.pod \
virt-xml-validate.pod \
- virsh.pod \
$(NULL)
MANINFILES = \
- virt-admin.1.in \
+
virt-pki-validate.1.in \
virt-sanlock-cleanup.8.in \
virt-xml-validate.1.in \
- virsh.1.in \
$(NULL)
EXTRA_DIST = \
@@ -74,8 +71,6 @@ EXTRA_DIST = \
virt-pki-validate.in \
virt-sanlock-cleanup.in \
libvirt-guests.sysconf \
- virsh-edit.c \
- bash-completion/vsh \
libvirt_recover_xattrs.sh \
$(PODFILES) \
$(MANINFILES) \
@@ -90,13 +85,10 @@ confdir = $(sysconfdir)/libvirt
conf_DATA =
bin_SCRIPTS = virt-xml-validate virt-pki-validate
-bin_PROGRAMS = virsh virt-admin
libexec_SCRIPTS = libvirt-guests.sh
man1_MANS = \
virt-pki-validate.1 \
- virt-xml-validate.1 \
- virsh.1 \
- virt-admin.1
+ virt-xml-validate.1
if WITH_SANLOCK
sbin_SCRIPTS = virt-sanlock-cleanup
@@ -119,90 +111,7 @@ virt-sanlock-cleanup: virt-sanlock-cleanup.in Makefile
-e 's|[@]localstatedir@|$(localstatedir)|' < $< > $@ \
|| (rm $@ && exit 1) && chmod +x $@
-noinst_LTLIBRARIES = libvirt_shell.la
-libvirt_shell_la_CFLAGS = \
- $(AM_CFLAGS) \
- $(READLINE_CFLAGS) \
- $(NULL)
-libvirt_shell_la_LDFLAGS = \
- $(AM_LDFLAGS) \
- $(PIE_LDFLAGS) \
- $(COVERAGE_LDFLAGS) \
- $(NULL)
-libvirt_shell_la_LIBADD = \
- ../src/libvirt.la \
- $(LIBXML_LIBS) \
- $(READLINE_LIBS) \
- ../gnulib/lib/libgnu.la \
- $(NULL)
-libvirt_shell_la_SOURCES = \
- vsh.c vsh.h \
- vsh-table.c vsh-table.h
-
-
-virsh_SOURCES = \
- virsh.c virsh.h \
- virsh-checkpoint.c virsh-checkpoint.h \
- virsh-completer.c virsh-completer.h \
- virsh-completer-domain.c virsh-completer-domain.h \
- virsh-completer-checkpoint.c virsh-completer-checkpoint.h \
- virsh-completer-host.c virsh-completer-host.h \
- virsh-completer-interface.c virsh-completer-interface.h \
- virsh-completer-network.c virsh-completer-network.h \
- virsh-completer-nodedev.c virsh-completer-nodedev.h \
- virsh-completer-nwfilter.c virsh-completer-nwfilter.h \
- virsh-completer-pool.c virsh-completer-pool.h \
- virsh-completer-secret.c virsh-completer-secret.h \
- virsh-completer-snapshot.c virsh-completer-snapshot.h \
- virsh-completer-volume.c virsh-completer-volume.h \
- virsh-console.c virsh-console.h \
- virsh-domain.c virsh-domain.h \
- virsh-domain-monitor.c virsh-domain-monitor.h \
- virsh-host.c virsh-host.h \
- virsh-interface.c virsh-interface.h \
- virsh-network.c virsh-network.h \
- virsh-nodedev.c virsh-nodedev.h \
- virsh-nwfilter.c virsh-nwfilter.h \
- virsh-pool.c virsh-pool.h \
- virsh-secret.c virsh-secret.h \
- virsh-snapshot.c virsh-snapshot.h \
- virsh-util.c virsh-util.h \
- virsh-volume.c virsh-volume.h \
- $(NULL)
-
-virsh_LDFLAGS = \
- $(AM_LDFLAGS) \
- $(PIE_LDFLAGS) \
- $(COVERAGE_LDFLAGS) \
- $(NULL)
-virsh_LDADD = \
- $(STATIC_BINARIES) \
- ../src/libvirt-lxc.la \
- ../src/libvirt-qemu.la \
- libvirt_shell.la
-virsh_CFLAGS = \
- $(AM_CFLAGS) \
- $(READLINE_CFLAGS)
-
-virt_admin_SOURCES = \
- virt-admin.c virt-admin.h \
- virt-admin-completer.c virt-admin-completer.h \
- $(NULL)
-
-virt_admin_LDFLAGS = \
- $(AM_LDFLAGS) \
- $(COVERAGE_LDFLAGS) \
- $(STATIC_BINARIES) \
- $(PIE_LDFLAGS) \
- $(NULL)
-virt_admin_LDADD = \
- ../src/libvirt-admin.la \
- libvirt_shell.la \
- $(LIBXML_LIBS) \
- $(NULL)
-virt_admin_CFLAGS = \
- $(AM_CFLAGS) \
- $(READLINE_CFLAGS)
+
BUILT_SOURCES =
if WITH_WIN_ICON
@@ -267,11 +176,9 @@ POD2MAN = pod2man -c "Virtualization Support" -r
"$(PACKAGE)-$(VERSION)"
< $< > $@-t && \
mv $@-t $@
-install-data-local: install-systemd \
- install-bash-completion
+install-data-local: install-systemd
-uninstall-local: uninstall-systemd \
- uninstall-bash-completion
+uninstall-local: uninstall-systemd
install-sysconfig:
$(MKDIR_P) $(DESTDIR)$(sysconfdir)/sysconfig
@@ -330,26 +237,6 @@ libvirt-guests.service: libvirt-guests.service.in
$(top_builddir)/config.status
mv $@-t $@
-if WITH_BASH_COMPLETION
-install-bash-completion:
- $(MKDIR_P) "$(DESTDIR)$(BASH_COMPLETIONS_DIR)"
- $(INSTALL_SCRIPT) $(srcdir)/bash-completion/vsh \
- "$(DESTDIR)$(BASH_COMPLETIONS_DIR)/vsh"
- ( cd $(DESTDIR)$(BASH_COMPLETIONS_DIR) && \
- rm -f virsh virt-admin && \
- $(LN_S) vsh virsh && \
- $(LN_S) vsh virt-admin )
-
-uninstall-bash-completion:
- rm -f $(DESTDIR)$(BASH_COMPLETIONS_DIR)/vsh \
- $(DESTDIR)$(BASH_COMPLETIONS_DIR)/virsh \
- $(DESTDIR)$(BASH_COMPLETIONS_DIR)/virt-admin
- rmdir $(DESTDIR)$(BASH_COMPLETIONS_DIR) ||:
-else ! WITH_BASH_COMPLETION
-install-bash-completion:
-uninstall-bash-completion:
-endif ! WITH_BASH_COMPLETION
-
EXTRA_DIST += wireshark/util/genxdrstub.pl
diff --git a/tools/bash-completion/meson.build b/tools/bash-completion/meson.build
new file mode 100644
index 0000000000..8994b22cef
--- /dev/null
+++ b/tools/bash-completion/meson.build
@@ -0,0 +1,19 @@
+
+with_tools_bash_completion = get_option('with-tools-bash-completion')
+if host_machine.system() == 'windows'
+ with_tools_bash_completion = false
+endif
+
+if with_tools_bash_completion
+ install_data(
+ 'vsh',
+ rename: 'virsh',
+ install_dir: bash_completion_dir,
+ )
+
+ install_data(
+ 'vsh',
+ rename: 'virt-admin',
+ install_dir: bash_completion_dir,
+ )
+endif
diff --git a/tools/meson.build b/tools/meson.build
index 6349dec2fb..f0d0ac90e6 100644
--- a/tools/meson.build
+++ b/tools/meson.build
@@ -116,3 +116,137 @@ if with_tools_login_shell
install_dir : join_paths(get_option('mandir'), 'man1')
)
endif
+
+libvirt_shell_src = [
+ 'vsh.c',
+ 'vsh.h',
+ 'vsh-table.c',
+ 'vsh-table.h',
+]
+libvirt_shell_inc = common_inc_dir
+libvirt_shell_libs = [libvirt_dep, readline_dep, libxml_dep, gnulib_dep]
+libvirt_shell = static_library(
+ 'virt-shell',
+ libvirt_shell_src,
+ include_directories: libvirt_shell_inc,
+ dependencies: libvirt_shell_libs,
+)
+libvirt_shell_dep = declare_dependency(
+ link_with: libvirt_shell,
+)
+
+
+virsh_src = [
+ 'virsh.c',
+ 'virsh.h',
+ 'virsh-checkpoint.c',
+ 'virsh-checkpoint.h',
+ 'virsh-completer.c',
+ 'virsh-completer.h',
+ 'virsh-completer-domain.c',
+ 'virsh-completer-domain.h',
+ 'virsh-completer-checkpoint.c',
+ 'virsh-completer-checkpoint.h',
+ 'virsh-completer-host.c',
+ 'virsh-completer-host.h',
+ 'virsh-completer-interface.c',
+ 'virsh-completer-interface.h',
+ 'virsh-completer-network.c',
+ 'virsh-completer-network.h',
+ 'virsh-completer-nodedev.c',
+ 'virsh-completer-nodedev.h',
+ 'virsh-completer-nwfilter.c',
+ 'virsh-completer-nwfilter.h',
+ 'virsh-completer-pool.c',
+ 'virsh-completer-pool.h',
+ 'virsh-completer-secret.c',
+ 'virsh-completer-secret.h',
+ 'virsh-completer-snapshot.c',
+ 'virsh-completer-snapshot.h',
+ 'virsh-completer-volume.c',
+ 'virsh-completer-volume.h',
+ 'virsh-console.c',
+ 'virsh-console.h',
+ 'virsh-domain.c',
+ 'virsh-domain.h',
+ 'virsh-domain-monitor.c',
+ 'virsh-domain-monitor.h',
+ 'virsh-host.c',
+ 'virsh-host.h',
+ 'virsh-interface.c',
+ 'virsh-interface.h',
+ 'virsh-network.c',
+ 'virsh-network.h',
+ 'virsh-nodedev.c',
+ 'virsh-nodedev.h',
+ 'virsh-nwfilter.c',
+ 'virsh-nwfilter.h',
+ 'virsh-pool.c',
+ 'virsh-pool.h',
+ 'virsh-secret.c',
+ 'virsh-secret.h',
+ 'virsh-snapshot.c',
+ 'virsh-snapshot.h',
+ 'virsh-util.c',
+ 'virsh-util.h',
+ 'virsh-volume.c',
+ 'virsh-volume.h',
+]
+virsh_inc = common_inc_dir
+virsh_libs = [libvirt_shell_dep, libvirt_qemu_dep, libvirt_lxc_dep, libxml_dep,
threads_dep, gnulib_dep]
+
+virsh = executable(
+ 'virsh',
+ install: true,
+ sources: virsh_src,
+ include_directories: virsh_inc,
+ dependencies: virsh_libs,
+)
+virsh_man = custom_target(
+ 'virsh_man',
+ output : 'virsh.1',
+ input : 'virsh.pod',
+ command : [
+ pod2man,
+ '--section=1',
+ '--center=Virtualization Support',
+ '--release=libvirt @0(a)'.format(meson.project_version()),
+ '@INPUT@', '@OUTPUT@'
+ ],
+ install : true,
+ install_dir : join_paths(get_option('mandir'), 'man1')
+)
+
+
+virt_admin_src = [
+ 'virt-admin.c',
+ 'virt-admin.h',
+ 'virt-admin-completer.c',
+ 'virt-admin-completer.h'
+]
+virt_admin_inc = common_inc_dir
+virt_admin_libs = [libvirt_shell_dep, libvirt_admin_dep, libxml_dep, threads_dep,
gnulib_dep]
+
+virt_admin = executable(
+ 'virt-admin',
+ install: true,
+ sources: virt_admin_src,
+ include_directories: virt_admin_inc,
+ dependencies: virt_admin_libs,
+)
+virt_admin_man = custom_target(
+ 'virt_admin_man',
+ output : 'virt-admin.1',
+ input : 'virt-admin.pod',
+ command : [
+ pod2man,
+ '--section=1',
+ '--center=Virtualization Support',
+ '--release=libvirt @0(a)'.format(meson.project_version()),
+ '@INPUT@', '@OUTPUT@'
+ ],
+ install : true,
+ install_dir : join_paths(get_option('mandir'), 'man1')
+)
+
+subdir('bash-completion')
--
2.21.0