bash-completion.sh
author Kristian H?gsberg <krh@redhat.com>
Mon Jun 09 12:47:37 2008 -0400 (2008-06-09)
changeset 230 c1e2aed8dd07
parent 187 6ff03223ce4c
child 226 6d9713bfc346
permissions -rw-r--r--
Rewrite depsolver to use a series of passes over all packages.

The big change is that we follow one step of the depedency chain for
each package to resolve in each iteration, and repeat until there are
no more possible moves. In contrast the old depsolver would try to
follow the dependency chain completely for one package at a time.

This new approach is simpler and faster, and at the same time more
roboust. Instead of knowing how one newly installed package may
affect other packages (obsoleting, pulling in new packages etc), the
new algorithm just looks at the total list of requires, provides,
obsoletes and conflicts after installing new packages.
krh@53
     1
__razor_commands () {
krh@54
     2
    local IFS=$'\n'
krh@187
     3
    COMPREPLY=($(IFS=: compgen -S' ' -W "list-requires:list-provides:list-files:list-file-packages:list-package-files:what-requires:what-provides:import-yum:import-rpmdb:validate:update:diff:install:init:download" -- $1))
krh@53
     4
}
krh@53
     5
krh@53
     6
__razor_packages () {
krh@54
     7
    local IFS=$'\n'
krh@54
     8
krh@187
     9
    COMPREPLY=($(./razor list --only-names "$1*" | while read p; do echo "$p "; done))
krh@187
    10
}
krh@187
    11
krh@187
    12
__razor_upstream_packages () {
krh@187
    13
    local IFS=$'\n'
krh@187
    14
krh@187
    15
    COMPREPLY=($(RAZOR_REPO=rawhide.repo ./razor list --only-names "$1*" | while read p; do echo "$p "; done))
krh@53
    16
}
krh@53
    17
krh@53
    18
__razor_files() {
krh@54
    19
    COMPREPLY=($(./razor list-files "$1*"))
krh@53
    20
}
krh@53
    21
krh@53
    22
__razor_requires() {
krh@53
    23
    COMPREPLY=($(compgen -W "$(./razor list-requires)" -- $1))
krh@53
    24
}
krh@53
    25
krh@53
    26
__razor_provides() {
krh@53
    27
    COMPREPLY=($(compgen -W "$(./razor list-provides)" -- $1))
krh@53
    28
}
krh@53
    29
krh@53
    30
__razor() {
krh@53
    31
    local cur="${COMP_WORDS[COMP_CWORD]}"
krh@53
    32
krh@53
    33
    if [ $COMP_CWORD = 1 ]; then
krh@53
    34
	__razor_commands $cur
krh@53
    35
    else
krh@53
    36
	case "${COMP_WORDS[1]}" in
krh@56
    37
	    list-requires|list-provides|list-package-files)
krh@56
    38
		__razor_packages $cur ;;
krh@53
    39
	    list-files|list-file-packages) __razor_files $cur ;;
krh@53
    40
	    what-requires) __razor_requires $cur ;;
krh@53
    41
	    what-provides) __razor_provides $cur ;;
krh@194
    42
	    install|download) __razor_upstream_packages $cur ;;
krh@53
    43
	esac
krh@53
    44
    fi
krh@53
    45
}
krh@53
    46
krh@54
    47
complete -o nospace -F __razor razor