|
Ville Skyttä |
fc0c76 |
# -*- mode: shell-script; sh-basic-offset: 8; indent-tabs-mode: t -*-
|
|
Ville Skyttä |
fc0c76 |
# ex: ts=8 sw=8 noet filetype=sh
|
|
Ville Skyttä |
fc0c76 |
#
|
|
Ville Skyttä |
fc0c76 |
# bash completion for mock
|
|
Ville Skyttä |
4f81c2 |
|
|
Ville Skyttä |
192263 |
_mock()
|
|
Ville Skyttä |
192263 |
{
|
|
Ville Skyttä |
fc0c76 |
local cur prev plugins cfgdir
|
|
Ville Skyttä |
192263 |
|
|
Ville Skyttä |
fc0c76 |
COMPREPLY=()
|
|
Ville Skyttä |
fc0c76 |
cur=`_get_cword`
|
|
Ville Skyttä |
fc0c76 |
prev=${COMP_WORDS[COMP_CWORD-1]}
|
|
Ville Skyttä |
fc0c76 |
plugins='tmpfs root_cache yum_cache bind_mount ccache'
|
|
Ville Skyttä |
fc0c76 |
cfgdir=/etc/mock
|
|
Ville Skyttä |
c2f930 |
|
|
Ville Skyttä |
fc0c76 |
count=0
|
|
Ville Skyttä |
fc0c76 |
for i in "${COMP_WORDS[@]}" ; do
|
|
Ville Skyttä |
fc0c76 |
[ $count -eq $COMP_CWORD ] && break
|
|
Ville Skyttä |
fc0c76 |
if [[ "$i" == --configdir ]] ; then
|
|
Ville Skyttä |
fc0c76 |
cfgdir="${COMP_WORDS[((count+1))]}"
|
|
Ville Skyttä |
fc0c76 |
elif [[ "$i" == --configdir=* ]] ; then
|
|
Ville Skyttä |
fc0c76 |
cfgdir=${i/*=/}
|
|
Ville Skyttä |
fc0c76 |
fi
|
|
Ville Skyttä |
fc0c76 |
count=$((++count))
|
|
Ville Skyttä |
fc0c76 |
done
|
|
Ville Skyttä |
192263 |
|
|
Ville Skyttä |
fc0c76 |
# --name=value style option
|
|
Ville Skyttä |
fc0c76 |
if [[ "$cur" == --?*=* ]] ; then
|
|
Ville Skyttä |
fc0c76 |
prev="${cur/=*}"
|
|
Ville Skyttä |
fc0c76 |
cur="${cur#$prev=}"
|
|
Ville Skyttä |
fc0c76 |
fi
|
|
Ville Skyttä |
192263 |
|
|
Ville Skyttä |
fc0c76 |
case $prev in
|
|
Ville Skyttä |
fc0c76 |
-@(h|-help|-copy@(in|out)|-arch|D|-define|-with?(out)|-uniqueext|-rpmbuild_timeout|-sources|-cwd))
|
|
Ville Skyttä |
fc0c76 |
return 0
|
|
Ville Skyttä |
fc0c76 |
;;
|
|
Ville Skyttä |
fc0c76 |
-@(r|-root))
|
|
Ville Skyttä |
fc0c76 |
COMPREPLY=( $( command ls $cfgdir | \
|
|
Ville Skyttä |
fc0c76 |
sed -ne 's/^\('$cur'.*\)\.cfg$/\1/p') )
|
|
Ville Skyttä |
fc0c76 |
return 0
|
|
Ville Skyttä |
fc0c76 |
;;
|
|
Ville Skyttä |
fc0c76 |
--@(config|result)dir)
|
|
Ville Skyttä |
fc0c76 |
_filedir -d
|
|
Ville Skyttä |
fc0c76 |
return 0
|
|
Ville Skyttä |
fc0c76 |
;;
|
|
Ville Skyttä |
fc0c76 |
--spec)
|
|
Ville Skyttä |
fc0c76 |
_filedir spec
|
|
Ville Skyttä |
fc0c76 |
return 0
|
|
Ville Skyttä |
fc0c76 |
;;
|
|
Ville Skyttä |
fc0c76 |
--target)
|
|
Ville Skyttä |
fc0c76 |
# Yep, compatible archs, not compatible build archs
|
|
Ville Skyttä |
fc0c76 |
# (e.g. ix86 chroot builds in x86_64 mock host)
|
|
Ville Skyttä |
fc0c76 |
# This would actually depend on what the target root
|
|
Ville Skyttä |
fc0c76 |
# can be used to build for...
|
|
Ville Skyttä |
fc0c76 |
COMPREPLY=( $( compgen -W "$( command rpm --showrc | sed -ne 's/^\s*compatible\s\+archs\s*:\s*\(.*\)/\1/i p' )" -- $cur ) )
|
|
Ville Skyttä |
fc0c76 |
return 0
|
|
Ville Skyttä |
fc0c76 |
;;
|
|
Ville Skyttä |
fc0c76 |
--@(en|dis)able-plugin)
|
|
Ville Skyttä |
fc0c76 |
COMPREPLY=( $( compgen -W "$plugins" -- $cur ) )
|
|
Ville Skyttä |
fc0c76 |
return 0
|
|
Ville Skyttä |
fc0c76 |
;;
|
|
Ville Skyttä |
fc0c76 |
esac
|
|
Ville Skyttä |
31fda3 |
|
|
Ville Skyttä |
fc0c76 |
if [[ "$cur" == -* ]] ; then
|
|
Ville Skyttä |
fc0c76 |
COMPREPLY=( $( compgen -W '--version -h --help --rebuild \
|
|
Ville Skyttä |
fc0c76 |
--buildsrpm --shell --chroot --clean --init \
|
|
Ville Skyttä |
fc0c76 |
--installdeps --install --update --orphanskill \
|
|
Ville Skyttä |
fc0c76 |
--copyin --copyout -r --root --offline --no-clean \
|
|
Ville Skyttä |
fc0c76 |
--cleanup-after --no-cleanup-after --arch --target \
|
|
Ville Skyttä |
fc0c76 |
-D --define --with --without --resultdir --uniqueext \
|
|
Ville Skyttä |
fc0c76 |
--configdir --rpmbuild_timeout --unpriv --cwd --spec \
|
|
Ville Skyttä |
fc0c76 |
--sources -v --verbose -q --quiet --trace \
|
|
Ville Skyttä |
fc0c76 |
--enable-plugin --disable-plugin --print-root-path' \
|
|
Ville Skyttä |
fc0c76 |
-- $cur ) )
|
|
Ville Skyttä |
fc0c76 |
else
|
|
Ville Skyttä |
fc0c76 |
_filedir '?(no)src.rpm'
|
|
Ville Skyttä |
fc0c76 |
fi
|
|
Ville Skyttä |
192263 |
}
|
|
Ville Skyttä |
192263 |
complete -F _mock $filenames mock
|