/etc/bash_completion.d/mock.bash is in mock 1.1.33-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | # bash >= 3 completion for mock(1) and mockchain(1)
_mock_root()
{
COMPREPLY+=( $( compgen -W "$( command ls ${1:-/etc/mock} 2>/dev/null | \
sed -ne 's/\.cfg$//p' )" -X site-defaults -- "$cur" ) )
}
_mock()
{
COMPREPLY=()
local cur prev cword cfgdir=/etc/mock
local -a words
if declare -F _get_comp_words_by_ref &>/dev/null ; then
_get_comp_words_by_ref cur prev words cword
else
cur=$2 prev=$3 words=("${COMP_WORDS[@]}") cword=$COMP_CWORD
fi
local word count=0
for word in "${words[@]}" ; do
[[ $count -eq $cword ]] && break
if [[ "$word" == --configdir ]] ; then
cfgdir="${words[((count+1))]}"
elif [[ "$word" == --configdir=* ]] ; then
cfgdir=${word/*=/}
fi
count=$((++count))
done
local split=false
declare -F _split_longopt &>/dev/null && _split_longopt && split=true
case "$prev" in
-h|--help|--copyin|--copyout|--arch|-D|--define|--with|--without|\
--uniqueext|--rpmbuild_timeout|--sources|--cwd|--scm-option)
return 0
;;
-r|--root)
_mock_root $cfgdir
return 0
;;
--configdir|--resultdir)
COMPREPLY=( $( compgen -d -- "$cur" ) )
return 0
;;
--spec)
COMPREPLY=( $( compgen -f -o plusdirs -X "!*.spec" -- "$cur" ) )
return 0
;;
--target)
# Yep, compatible archs, not compatible build archs
# (e.g. ix86 chroot builds in x86_64 mock host)
# This would actually depend on what the target root
# can be used to build for...
COMPREPLY=( $( compgen -W "$( command rpm --showrc | \
sed -ne 's/^\s*compatible\s\s*archs\s*:\s*\(.*\)/\1/i p' )" \
-- "$cur" ) )
return 0
;;
--enable-plugin|--disable-plugin)
COMPREPLY=( $( compgen -W "$( $1 $prev=DOES_NOT_EXIST 2>&1 | \
sed -ne "s/[',]//g" -e 's/.*[[(]\([^])]*\)[])]/\1/p' )" \
-- "$cur" ) ) #' unconfuse emacs
return 0
;;
--scrub)
COMPREPLY=( $( compgen -W "all chroot cache root-cache c-cache
yum-cache" -- "$cur" ) )
return 0
;;
--install|install)
COMPREPLY=( $( compgen -f -o plusdirs -X '!*.rpm' -X '*src.rpm' \
-- "$cur" ) )
[[ $cur != */* && $cur != [.~]* ]] && \
declare -F _yum_list &>/dev/null && _yum_list all "$cur"
return 0
;;
--remove|remove)
declare -F _yum_list &>/dev/null && _yum_list all "$cur"
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]] ; then
COMPREPLY=( $( compgen -W "--version --help --rebuild --buildsrpm
--shell --chroot --clean --scrub --init --installdeps --install
--update --remove --orphanskill --copyin --copyout --root --offline
--no-clean --cleanup-after --no-cleanup-after --arch --target
--define --with --without --resultdir --uniqueext --configdir
--rpmbuild_timeout --unpriv --cwd --spec --sources --verbose
--quiet --trace --enable-plugin --disable-plugin
--print-root-path --scm-enable --scm-option" -- "$cur" ) )
return 0
fi
COMPREPLY=( $( compgen -f -o plusdirs -X '!*.@(?(no)src.r|s)pm' \
-- "$cur" ) )
} &&
complete -F _mock -o filenames mock mock.py
_mockchain()
{
COMPREPLY=()
local cur prev cword
local -a words
if declare -F _get_comp_words_by_ref &>/dev/null ; then
_get_comp_words_by_ref cur prev words cword
else
cur=$2 prev=$3 words=("${COMP_WORDS[@]}") cword=$COMP_CWORD
fi
local split=false
declare -F _split_longopt &>/dev/null && _split_longopt && split=true
case "$prev" in
-h|--help|-a|--addrepo)
return 0
;;
-r|--root)
_mock_root
return 0
;;
-l|--localrepo)
_filedir -d
return 0
;;
--log)
_filedir
return 0
;;
esac
$split && return 0
if [[ "$cur" == -* ]] ; then
COMPREPLY=( $( compgen -W "--help --root --localrepo --continue
--addrepo --recurse --log" -- "$cur" ) )
return 0
fi
COMPREPLY=( $( compgen -f -o plusdirs -X '!*.@(?(no)src.r|s)pm' \
-- "$cur" ) )
} &&
complete -F _mockchain -o filenames mockchain mockchain.py
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh
|