[Bash-completion-devel] Mandriva handling of bash completion

Guillaume Rousse Guillaume.Rousse at inria.fr
Mon Jan 12 22:55:45 UTC 2009


Hello guys.

I'm the mandriva maintainer for bash-completion, and I was also quite an
active contributor when Ian was maintaining the project. I'd like to
discuss the way we manage bash completion in mandriva, and submit our
own patches.

First, we (I, actually, to be honest) prefer to use individual
completion scriptlet, installed under /etc/bash_completion.d, for
various command, instead of one single giant /etc/bash_completion file.
It usually makes comparaison simpler, and also allows to ship
package-specific completion code in given package. For instance, urpmi,
strace, xen, etc... completions are distributed in urpmi, strace and xen
packages.

The main advantage being a closer fit with exact command version, for
instance: if --foo option for command bar is only present in version
X.Y, it doesn't make much sense to provide a completion function in
bash-completion package that has first to identify exact version of bar
is (maybe) installed. It also provides a nice solution for command named
identically in various distribution, but being actually different code
base, as mkinitrd. Lastly, it also allow to get rid of classical has_bar
&& () test, but I don't think that really matters.

See for instance various code currently not part of upstream
bash-completion package:

http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/bluez/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/bridge-utils/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/cfengine/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/perl-CPANPLUS/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/dkms/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/minicom/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/msynctool/current/SOURCES
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/munin/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/net-tools/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/qemu/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/quota/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/rdesktop/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/nfs-utils/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/samba/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/vncviewer/strace/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/vpnc/strace/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/xen/current/SOURCES/

The following ones are enhanced version of those currently included in
bash-completion mail file:
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/mkinitrd/current/SOURCES/
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/openssl/current/SOURCES/

Unfortunatly, this code dispersion make comparaison harder, so I wonder
if this is really a good idea. I'm open to any suggestion here, the one
coming to my mind is systematically pushing them for inclusion in
bash-completion project contrib directory, even if I continue
distributing them separatly.

Second, I'd prefer all potentially slow completion (rpm database
querying, scp remote completion) to be easily desactivable. For those
reason, we patch openssh and rpm completion to add COMP_RPM_DATABASE and
COMP_SCP_REMOTE variables. See 
bash-completion-20090108-rpm-database.patch and 
bash-completion-20090108-scp-remote.patch in our bash-completion package
sources:
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/bash-completion/current/SOURCES

We also have a slightly initialisation system, with a file
in /etc/profile.d sourcing a system-wide /etc/sysconfig/bash-completion
configuration file, then a ~/.bash-completion to set up relevant
options. This let sysadmin configure bash completion globally, or not,
while still allowing individual users to do it in the last case.

[guillaume at oberkampf bash-completion]$
cat /etc/profile.d/20bash-completion.sh 
#!/bin/sh
# system-wide activation
if [ "$PS1" ]  && [ -n "$BASH" ]; then
    # source system wide config file
	. /etc/sysconfig/bash-completion
    # source user config file if available,
    if [ -f $HOME/.bash_completion ]; then
        . $HOME/.bash_completion
    fi

    if [ -n "$ENABLE_BASH_COMPLETION" ]; then
        . /etc/bash_completion
    fi
fi

[guillaume at oberkampf bash-completion]$
cat /etc/sysconfig/bash-completion 
# bash completion global configuration

# enable bash completion
ENABLE_BASH_COMPLETION=1
# enable remote cvs completion
COMP_CVS_REMOTE=
# enable remote scp completion
COMP_SCP_REMOTE=
# enable configure arguments completion
COMP_CONFIGURE_HINTS=
# enable tar archive internal path completion
COMP_TAR_INTERNAL_PATHS=
# enable wireless uid completion
COMP_IWLIST_SCAN=
# enable installed packages completion
COMP_RPM_DATABASE=

Apart those global change, I also have simpler patches easy to
review/merge, all from our bash-completion package:
http://svn.mandriva.com/cgi-bin/viewvc.cgi/packages/cooker/bash-completion/current/SOURCES

Those patches add additional helper functions:
bash-completion-20060301-kernel-completion.patch
bash-completion-20090108-device_ids.patch

This patch makes a better command completion, allowing to specify an
offset in caller function (see our strace completion for an usage
example):
bash-completion-20090108-better-command-completion.patch

Thoses patches correct some details in rpm completion:
bash-completion-20060301-fix-old-rpmfiles-pattern.patch
bash-completion-20060301-rpm-macros.patch
bash-completion-20060301-rpm-suggests.patch

This one add support for lzma format compression, used in mandriva for
man and info pages:
bash-completion-20090108-lzma-completion.patch

This one is just a cosmetic change for perl completion, making it use
the same logic as other (if current completion is an option, else...),
whereas it's currently using the exact opposite.
bash-completion-20090108-more-standard-perl-completion.patch

Those add additional commands completion:
bash-completion-20060301-getent-completion.patch
bash-completion-20060301-bibtex.patch

Hope you'll like this additional material :)
-- 
BOFH excuse #89:

Electromagnetic energy loss




More information about the Bash-completion-devel mailing list