source: projects/vbootstrap/tags/0.0.48/vbuilder-bash-completion.sh @ 5364

Revision 5364, 2.5 KB checked in by munepi, 12 years ago (diff)

updated vbootstrap.sh.in:

  • specify a location to fetch base packages;

updated vbuilder.sh.in:

  • added --fetch-url, --profile options
Line 
1[ -z "$BASH_VERSION" ] && return
2
3_filedir()
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.
14}
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.
25    options="--profile --version --arch --category --fetch-url --dist-upgrade --unionfs --target --with-compat32 --rpmbuild-define --rpmbuild-with --rpmbuild-without --sign --no-install --login --bootstrap-dir --unionfs-dir --cache-dir --built-rpms-dir --debug"
26    actions="clean build build-rpm install-rpm remove-rpm"
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
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            ;;
37        --version)
38            local running="VineSeed 6.0 5.2 4.2"
39            COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
40            ;;
41
42        --arch)
43            local running="i386 ppc x86_64 arm"
44            COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
45            ;;
46
47        --category)
48            local running="main proposed-updates,main plus,main nonfree,plus,main test,nonfree,plus,main test,plus,main test,main"
49            COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
50            ;;
51
52        --target)
53            local running="$(cat /usr/lib/rpm/rpmrc | grep arch_canon: | sed -e "s/arch_canon:[[:blank:]]*\(.*\):.*/\1/") noarch"
54            COMPREPLY=( $(compgen -W "${running}" -- "${cur}") )
55            ;;
56
57        --bootstrap-dir|--unionfs-dir|--cache-dir|--built-rpms-dir)
58            if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then
59                _filedir ''
60            fi
61            ;;
62
63        build-rpm)
64            if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then
65                _filedir 'src.rpm'
66            fi
67            ;;
68
69        install-rpm|remove-rpm)
70            if [ $COMP_CWORD -eq 1 -o "${COMPREPLY+set}" != "set" ]; then
71                _filedir 'rpm'
72            fi
73            ;;
74
75        *)
76            COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
77            #return 0
78            ;;
79    esac
80
81    if [[ "${cur}" == -* ]] ; then
82        COMPREPLY=($(compgen -W "${opts}" -- "${cur}"))
83        #return 0
84    fi
85
86}
87
88complete -o filenames -o nospace -F _vbuilder vbuilder
89
90### end of file
Note: See TracBrowser for help on using the repository browser.