vbuilder-bash-completion.sh 2.6 KB

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