The current setup uses a single script that is symlinked twice
and that tries to configure bash completion for both virsh and
virt-admin, even if only one of them is installed. This also
forces us to have a -bash-completion RPM package that only
contains the tiny shared file.
Rework bash completion support so that two scripts are
generated, each one tailored to a specific command.
Since the shared script no longer exists after this change,
the corresponding RPM package becomes empty.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
libvirt.spec.in | 3 ---
tools/bash-completion/meson.build | 24 ++++++++++++++----------
tools/bash-completion/{vsh => vsh.in} | 7 +++----
3 files changed, 17 insertions(+), 17 deletions(-)
rename tools/bash-completion/{vsh => vsh.in} (91%)
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 6d2206633f..76af267681 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1905,9 +1905,6 @@ exit 0
%{_datadir}/libvirt/test-screenshot.png
-%files bash-completion
-%{_datadir}/bash-completion/completions/vsh
-
%if %{with_wireshark}
%files wireshark
%{wireshark_plugindir}/libvirt.so
diff --git a/tools/bash-completion/meson.build b/tools/bash-completion/meson.build
index 8924c93adf..deda7c4f46 100644
--- a/tools/bash-completion/meson.build
+++ b/tools/bash-completion/meson.build
@@ -1,11 +1,15 @@
-install_data('vsh', install_dir: bash_completion_dir)
+completion_commands = [
+ 'virsh',
+ 'virt-admin',
+]
-meson.add_install_script(
- meson_python_prog.path(), python3_prog.path(), meson_install_symlink_prog.path(),
- bash_completion_dir, 'vsh', 'virsh',
-)
-
-meson.add_install_script(
- meson_python_prog.path(), python3_prog.path(), meson_install_symlink_prog.path(),
- bash_completion_dir, 'vsh', 'virt-admin',
-)
+foreach command : completion_commands
+ completion_conf = configuration_data()
+ completion_conf.set('command', command)
+ completion = configure_file(
+ input: 'vsh.in',
+ output: command,
+ configuration: completion_conf,
+ )
+ install_data(completion, install_dir: bash_completion_dir)
+endforeach
diff --git a/tools/bash-completion/vsh b/tools/bash-completion/vsh.in
similarity index 91%
rename from tools/bash-completion/vsh
rename to tools/bash-completion/vsh.in
index bbb25fc3eb..8dde38474f 100644
--- a/tools/bash-completion/vsh
+++ b/tools/bash-completion/vsh.in
@@ -1,8 +1,8 @@
#
-# virsh & virt-admin completion command
+# @command@ completion support
#
-_vsh_complete()
+_@command@_complete()
{
local words cword c=0 i=0 cur RO URI CMDLINE INPUT A
@@ -62,7 +62,6 @@ _vsh_complete()
__ltrim_colon_completions "$cur"
return 0
} &&
-complete -o default -o filenames -F _vsh_complete virsh &&
-complete -o default -o filenames -F _vsh_complete virt-admin
+complete -o default -o filenames -F _@command@_complete @command@
# vim: ft=sh:et:ts=4:sw=4:tw=80
--
2.26.3