]> xenbits.xensource.com Git - libvirt.git/commitdiff
tools: Make symlinks to vsh bash-completion script
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 24 Jan 2018 15:42:00 +0000 (16:42 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Wed, 31 Jan 2018 14:41:51 +0000 (15:41 +0100)
The bash-completion project documents that only those scripts
from $BASH_COMPLETIONS_DIR that share name with the current
command for which <TAB> was hit are loaded [1]. This means, that
vsh script we have there is not loaded. We have to create
symlinks for virsh and virt-admin.

At the same time, we have to create new RPM package because
virt-admin and client packages are independent. That means we
cannot place the vsh script in either of them. What we can do is
to have a different package that contains the completion script
and then virt-admin and client packages contain only the symlink
and require the bash-completion package.

1: https://github.com/scop/bash-completion#faq

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
libvirt.spec.in
tools/Makefile.am

index f62d7d3241250458b91885d5f90e90350352b076..1879e1f8b7d624ef7b3eed5a94d2b21cb7bbe5b1 100644 (file)
@@ -1017,6 +1017,9 @@ Requires: gnutls-utils
 # Needed for probing the power management features of the host.
 Requires: pm-utils
 %endif
+%if %{with_bash_completion}
+Requires: %{name}-bash-completion = %{version}-%{release}
+%endif
 
 %description client
 The client binaries needed to access the virtualization
@@ -1041,10 +1044,22 @@ Summary: Set of tools to control libvirt daemon
 Group: Development/Libraries
 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
+Group: Development/Libraries
+
+%description bash-completion
+Bash completion script stub.
+%endif
+
 %if %{with_wireshark}
 %package wireshark
 Summary: Wireshark dissector plugin for libvirt RPC transactions
@@ -2059,7 +2074,7 @@ exit 0
 %{_datadir}/systemtap/tapset/libvirt_functions.stp
 
 %if %{with_bash_completion}
-%{_datadir}/bash-completion/completions/vsh
+%{_datadir}/bash-completion/completions/virsh
 %endif
 
 
@@ -2111,7 +2126,14 @@ exit 0
 %files admin
 %{_mandir}/man1/virt-admin.1*
 %{_bindir}/virt-admin
+%if %{with_bash_completion}
+%{_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
index e9597cdb478d4d4e1b02bb2d95b13461aa9d5b3b..e173f56347b16303e75490ced3e95d1c1654c5c6 100644 (file)
@@ -424,9 +424,14 @@ 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) && \
+               $(LN_S) vsh virsh && \
+               $(LN_S) vsh virt-admin )
 
 uninstall-bash-completion:
-       rm -f $(DESTDIR)$(BASH_COMPLETIONS_DIR)/vsh
+       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: