[484] | 1 | [ -z "$BASH_VERSION" ] && return |
---|
| 2 | |
---|
[5573] | 3 | _vbootstrap_filedir() |
---|
[484] | 4 | { |
---|
| 5 | local IFS=$'\t\n' xspec #glob |
---|
| 6 | |
---|
| 7 | #glob=$(set +o|grep noglob) # save glob setting. |
---|
| 8 | #set -f # disable pathname expansion (globbing) |
---|
| 9 | |
---|
| 10 | xspec=${1:+"!*.$1"} # set only if glob passed in as $1 |
---|
| 11 | COMPREPLY=( ${COMPREPLY[@]:-} $( compgen -f -X "$xspec" -- "$cur" ) \ |
---|
| 12 | $( compgen -d -- "$cur" ) ) |
---|
| 13 | #eval "$glob" # restore glob setting. |
---|
[5573] | 14 | } # _vbootstrap_filedir() |
---|
[484] | 15 | |
---|
| 16 | _vbuilder() |
---|
| 17 | { |
---|
| 18 | local opts cur prev first |
---|
| 19 | COMPREPLY=() |
---|
| 20 | cur="${COMP_WORDS[COMP_CWORD]}" |
---|
| 21 | prev="${COMP_WORDS[COMP_CWORD-1]}" |
---|
| 22 | first="${COMP_WORDS[1]}" |
---|
| 23 | |
---|
| 24 | ## The basic options we'll complete. |
---|
[5511] | 25 | options="--profile --version --arch --category --fetch-url --dist-upgrade --unionfs --target --no-build-essential --with-compat32 --rpmbuild-define --rpmbuild-with --rpmbuild-without --sign --no-install --login --bootstrap-dir --unionfs-dir --cache-dir --built-rpms-dir --debug" |
---|
[3826] | 26 | actions="clean build build-rpm install-rpm remove-rpm" |
---|
[484] | 27 | opts="$options $actions" |
---|
| 28 | |
---|
| 29 | _arch=$(rpm --eval %_arch) |
---|
| 30 | |
---|
| 31 | ## Complete the arguments to some of the basic commands. |
---|
| 32 | case "${prev}" in |
---|
[5364] | 33 | --profile) |
---|
| 34 | local running=$(ls /etc/vbootstrap/profile.d/*.conf | sed -e "s|/etc/vbootstrap/profile.d/||g" -e "s|\.conf||g") |
---|
| 35 | COMPREPLY=( $(compgen -W "${running}" -- "${cur}") ) |
---|
| 36 | ;; |
---|
[5452] | 37 | |
---|
[484] | 38 | --version) |
---|
[6665] | 39 | local running="VineSeed 6 5.2 4.2" |
---|
[484] | 40 | COMPREPLY=( $(compgen -W "${running}" -- "${cur}") ) |
---|
| 41 | ;; |
---|
| 42 | |
---|
| 43 | --arch) |
---|
[2718] | 44 | local running="i386 ppc x86_64 arm" |
---|
[484] | 45 | COMPREPLY=( $(compgen -W "${running}" -- "${cur}") ) |
---|
| 46 | ;; |
---|
| 47 | |
---|
[794] | 48 | --category) |
---|
[800] | 49 | local running="main proposed-updates,main plus,main nonfree,plus,main test,nonfree,plus,main test,plus,main test,main" |
---|
[794] | 50 | COMPREPLY=( $(compgen -W "${running}" -- "${cur}") ) |
---|
| 51 | ;; |
---|
| 52 | |
---|
[484] | 53 | --target) |
---|
[3826] | 54 | local running="$(cat /usr/lib/rpm/rpmrc | grep arch_canon: | sed -e "s/arch_canon:[[:blank:]]*\(.*\):.*/\1/") noarch" |
---|
[484] | 55 | COMPREPLY=( $(compgen -W "${running}" -- "${cur}") ) |
---|
| 56 | ;; |
---|
| 57 | |
---|
[2718] | 58 | --bootstrap-dir|--unionfs-dir|--cache-dir|--built-rpms-dir) |
---|
| 59 | if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then |
---|
[5573] | 60 | _vbootstrap_filedir '' |
---|
[2718] | 61 | fi |
---|
| 62 | ;; |
---|
| 63 | |
---|
[3676] | 64 | build-rpm) |
---|
[484] | 65 | if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then |
---|
[5573] | 66 | _vbootstrap_filedir 'src.rpm' |
---|
[484] | 67 | fi |
---|
| 68 | ;; |
---|
| 69 | |
---|
[3676] | 70 | install-rpm|remove-rpm) |
---|
[484] | 71 | if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then |
---|
[5573] | 72 | _vbootstrap_filedir 'rpm' |
---|
[484] | 73 | fi |
---|
| 74 | ;; |
---|
| 75 | |
---|
| 76 | *) |
---|
| 77 | COMPREPLY=($(compgen -W "${opts}" -- "${cur}")) |
---|
| 78 | #return 0 |
---|
| 79 | ;; |
---|
| 80 | esac |
---|
| 81 | |
---|
| 82 | if [[ "${cur}" == -* ]] ; then |
---|
| 83 | COMPREPLY=($(compgen -W "${opts}" -- "${cur}")) |
---|
| 84 | #return 0 |
---|
| 85 | fi |
---|
| 86 | |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | complete -o filenames -o nospace -F _vbuilder vbuilder |
---|
| 90 | |
---|
| 91 | ### end of file |
---|