[virt-tools-list] [virt-manager] [RFC PATCH 9/9] setup.py: Install and link the bash completion scripts

Cole Robinson crobinso at redhat.com
Sun Nov 18 02:24:15 UTC 2018


On 11/14/2018 03:12 AM, Lin Ma wrote:
> Signed-off-by: Lin Ma <lma at suse.com>
> ---
>   setup.py | 10 ++++++++++
>   1 file changed, 10 insertions(+)
> 
> diff --git a/setup.py b/setup.py
> index 658e6503..1c4b4340 100755
> --- a/setup.py
> +++ b/setup.py
> @@ -273,6 +273,15 @@ class my_install_data(distutils.command.install_data.install_data):
>                   "share/glib-2.0/schemas")
>               self.spawn(["glib-compile-schemas", gschema_install])
>   
> +        self.spawn(["rm", "-f", "/usr/share/bash-completion/completions/virt-install"])
> +        self.spawn(["rm", "-f", "/usr/share/bash-completion/completions/virt-clone"])
> +        self.spawn(["rm", "-f", "/usr/share/bash-completion/completions/virt-xml"])
> +        self.spawn(["rm", "-f", "/usr/share/bash-completion/completions/virt-convert"])
> +        self.spawn(["ln", "-s", "virtmanager", "/usr/share/bash-completion/completions/virt-install"])
> +        self.spawn(["ln", "-s", "virtmanager", "/usr/share/bash-completion/completions/virt-clone"])
> +        self.spawn(["ln", "-s", "virtmanager", "/usr/share/bash-completion/completions/virt-xml"])
> +        self.spawn(["ln", "-s", "virtmanager", "/usr/share/bash-completion/completions/virt-convert"])
> +
> 

I don't really like the linking and deleting here. I think my_build 
should basically copy data/bash-completion/virtmanager to 
{virt-install,virt-clone,virt-xml,virt-convert}, then the glob will do 
the right thing.

Also, bash completion install location might vary per distro. I see code 
like this in the fedpkg project for finding the install location:


def bash_completion_dir():
     (sts, output) = getstatusoutput(
         'pkg-config --variable=completionsdir bash-completion')
     return output if not sts and output else '/etc/bash_completion.d'

Thanks,
Cole

>   class my_sdist(distutils.command.sdist.sdist):
>       description = "Update virt-manager.spec; build sdist-tarball."
> @@ -663,6 +672,7 @@ distutils.core.setup(
>           ("share/virt-manager/virtinst/devices", glob.glob("virtinst/devices/*.py")),
>           ("share/virt-manager/virtinst/domain", glob.glob("virtinst/domain/*.py")),
>           ("share/virt-manager/virtconv", glob.glob("virtconv/*.py")),
> +        ("share/bash-completion/completions", glob.glob("bash-completion/virtmanager")),
>       ],
>   
>       cmdclass={
> 


- Cole




More information about the virt-tools-list mailing list