summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Hill <dirtyepic@gentoo.org>2012-10-11 04:48:30 (GMT)
committerRyan Hill <dirtyepic@gentoo.org>2012-10-11 05:03:47 (GMT)
commit8609efe8432a76300d7208b16c19a7305b96aa8a (patch)
tree2b1f99414f34d1653efb5d075f9a067a4a202052
parentAdd support for /etc/portage/make.conf (bug #424777). (diff)
downloadgentoo-bashcomp-8609efe8432a76300d7208b16c19a7305b96aa8a.zip
gentoo-bashcomp-8609efe8432a76300d7208b16c19a7305b96aa8a.tar.gz
gentoo-bashcomp-8609efe8432a76300d7208b16c19a7305b96aa8a.tar.bz2
Add support for md5 cache format (bug #431576).
(Based on a patch by Jacek SowiƄski) Now that the main portage tree is using the md5-cache format by default we need to be sure we're checking both locations. Also clean up some bad indentation and useless line continuations.
-rw-r--r--gentoo121
1 files changed, 70 insertions, 51 deletions
diff --git a/gentoo b/gentoo
index 82aef7a..04563dd 100644
--- a/gentoo
+++ b/gentoo
@@ -104,16 +104,20 @@ _pkgname()
))
# When we've completed most of the name, also display the version for
# possible completion.
- if [[ ${#COMPREPLY[@]} -le 1 || ${cur:${#cur}-1:1} == "-" ]] &&
- [[ ${cur} != */ ]]; then
- # The portage cache is appropriate to complete specific versions from.
- COMPREPLY=(${COMPREPLY[@]} $(\
- for pd in ${portdir} ; do \
- if [[ -d ${pd}/metadata/cache ]] ; then \
- builtin cd ${pd}/metadata/cache; \
- compgen -W "$(compgen -G "${cur}*")" -- "${cur}" ; \
- fi ; \
- done))
+ if [[ ${#COMPREPLY[@]} -le 1 || ${cur:${#cur}-1:1} == "-" ]] \
+ && [[ ${cur} != */ ]]; then
+ # Use the portage cache to complete specific versions from
+ COMPREPLY=(${COMPREPLY[@]} $(
+ for pd in ${portdir}; do
+ if [[ -d ${pd}/metadata/md5-cache ]]; then
+ builtin cd ${pd}/metadata/md5-cache
+ compgen -W "$(compgen -G "${cur}*")" -- "${cur}"
+ elif [[ -d ${pd}/metadata/cache ]]; then
+ builtin cd ${pd}/metadata/cache
+ compgen -W "$(compgen -G "${cur}*")" -- "${cur}"
+ fi
+ done
+ ))
fi
else
# 1. Collect all the categories among ${portdir}
@@ -129,14 +133,19 @@ _pkgname()
local words=$(echo -e ${w} | sort -u)
COMPREPLY=($(compgen -W "$words" -- $cur))
- if [[ ${#COMPREPLY[@]} == 1 ]]; then
- COMPREPLY=($(compgen -W "$(\
- for pd in ${portdir} ; do \
- if [[ -d ${pd}/metadata/cache ]] ; then
- builtin cd ${pd}/metadata/cache; \
- compgen -G "$COMPREPLY*" ; \
- fi ; \
- done)" -- $cur))
+
+ if [[ ${#COMPREPLY[@]} == 1 ]]; then
+ COMPREPLY=($(compgen -W "$(
+ for pd in ${portdir}; do
+ if [[ -d ${pd}/metadata/md5-cache ]]; then
+ builtin cd ${pd}/metadata/md5-cache
+ compgen -G "$COMPREPLY*"
+ elif [[ -d ${pd}/metadata/cache ]]; then
+ builtin cd ${pd}/metadata/cache
+ compgen -G "$COMPREPLY*"
+ fi
+ done
+ )" -- $cur))
fi
fi
@@ -516,29 +525,33 @@ _emerge()
COMPREPLY=( ${words} )
# Complete on the specific versions (if appropriate).
- if [[ ${#COMPREPLY[@]} -le 1 ]] ; then
- COMPREPLY=($(\
- for pd in ${portdir} ; do \
- if [[ -d ${pd}/metadata/cache ]] ; then
- builtin cd ${pd}/metadata/cache; \
- compgen ${prepend} -G "${cur}*" -- "${cur}" ; \
- else \
- builtin cd ${pd} ; \
- local cat="${cur%/*}" ; \
- local pkg="$(echo ${cur%-[0-9]*}*)" ; \
- pkg="${pkg##*/}" ; \
- for x in ${cat}/${pkg}/*.ebuild ; do \
- [[ -f "${x}" ]] || continue ; \
- x="${x/${pkg}\/}" ; \
- if [[ ${cond:0:1} == "'" ]] || \
- [[ ${cond:0:1} == '"' ]] ; then
- echo "${c}${x%*.ebuild}" ; \
+ # TODO - see if we can use _pkgname
+ if [[ ${#COMPREPLY[@]} -le 1 ]]; then
+ COMPREPLY=($(
+ for pd in ${portdir}; do
+ if [[ -d ${pd}/metadata/md5-cache ]]; then
+ builtin cd ${pd}/metadata/md5-cache
+ compgen ${prepend} -G "${cur}*" -- "${cur}"
+ elif [[ -d ${pd}/metadata/cache ]]; then
+ builtin cd ${pd}/metadata/cache
+ compgen ${prepend} -G "${cur}*" -- "${cur}"
+ else
+ builtin cd ${pd}
+ local cat="${cur%/*}"
+ local pkg="$(echo ${cur%-[0-9]*}*)"
+ pkg="${pkg##*/}"
+ for x in ${cat}/${pkg}/*.ebuild; do
+ [[ -f "${x}" ]] || continue
+ x="${x/${pkg}\/}"
+ if [[ ${cond:0:1} == "'" ]] || [[ ${cond:0:1} == '"' ]]; then
+ echo "${c}${x%*.ebuild}"
else
- echo "${x%*.ebuild}" ; \
- fi ; \
- done ; \
- fi ; \
- done))
+ echo "${x%*.ebuild}"
+ fi
+ done
+ fi
+ done
+ ))
else
COMPREPLY=($(compgen ${prepend} -W "${words}" -- $cur))
fi
@@ -585,17 +598,23 @@ _emerge()
COMPREPLY=($(compgen ${prepend} -W "${words}" -- ${cur}))
if [[ ${#COMPREPLY[@]} -le 1 ]]; then
- # Now complete on the specific versions.
- words="$(\
- for pd in ${portdir} ; do \
- if [[ -d ${pd}/metadata/cache ]] ; then \
- builtin cd ${pd}/metadata/cache; \
- for i in */${cur}*; do \
- [[ -f $i ]] && echo ${i##*/}; \
- done ; \
- fi ; \
- done)"
- COMPREPLY=($(compgen ${prepend} -W "${words}" -- "${cur}"))
+ # Now complete on the specific versions.
+ words="$(
+ for pd in ${portdir}; do
+ if [[ -d ${pd}/metadata/md5-cache ]]; then
+ builtin cd ${pd}/metadata/md5-cache
+ for i in */${cur}*; do
+ [[ -f $i ]] && echo ${i##*/}
+ done
+ elif [[ -d ${pd}/metadata/cache ]]; then
+ builtin cd ${pd}/metadata/cache
+ for i in */${cur}*; do
+ [[ -f $i ]] && echo ${i##*/}
+ done
+ fi
+ done
+ )"
+ COMPREPLY=($(compgen ${prepend} -W "${words}" -- "${cur}"))
fi
fi
return 0