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.
     1 __razor_commands () {
     2     local IFS=$'\n'
     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))
     4 }
     5 
     6 __razor_packages () {
     7     local IFS=$'\n'
     8 
     9     COMPREPLY=($(./razor list --only-names "$1*" | while read p; do echo "$p "; done))
    10 }
    11 
    12 __razor_upstream_packages () {
    13     local IFS=$'\n'
    14 
    15     COMPREPLY=($(RAZOR_REPO=rawhide.repo ./razor list --only-names "$1*" | while read p; do echo "$p "; done))
    16 }
    17 
    18 __razor_files() {
    19     COMPREPLY=($(./razor list-files "$1*"))
    20 }
    21 
    22 __razor_requires() {
    23     COMPREPLY=($(compgen -W "$(./razor list-requires)" -- $1))
    24 }
    25 
    26 __razor_provides() {
    27     COMPREPLY=($(compgen -W "$(./razor list-provides)" -- $1))
    28 }
    29 
    30 __razor() {
    31     local cur="${COMP_WORDS[COMP_CWORD]}"
    32 
    33     if [ $COMP_CWORD = 1 ]; then
    34 	__razor_commands $cur
    35     else
    36 	case "${COMP_WORDS[1]}" in
    37 	    list-requires|list-provides|list-package-files)
    38 		__razor_packages $cur ;;
    39 	    list-files|list-file-packages) __razor_files $cur ;;
    40 	    what-requires) __razor_requires $cur ;;
    41 	    what-provides) __razor_provides $cur ;;
    42 	    install|download) __razor_upstream_packages $cur ;;
    43 	esac
    44     fi
    45 }
    46 
    47 complete -o nospace -F __razor razor