summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Harder <radhermit@gentoo.org>2014-11-30 16:47:07 -0800
committerTim Harder <radhermit@gentoo.org>2014-11-30 23:33:39 -0800
commit2b6c19533a92911f4b006ff55326b24ff543a114 (patch)
treec678945ecf3f2f77f6cee7da2ce81652dcb6c807
parent_portage: add --keep-going as an install time argument (diff)
downloadzsh-completion-2b6c19533a92911f4b006ff55326b24ff543a114.tar.gz
zsh-completion-2b6c19533a92911f4b006ff55326b24ff543a114.tar.bz2
zsh-completion-2b6c19533a92911f4b006ff55326b24ff543a114.zip
_portage_utils: sync portdir/reposconf changes from _gentoo_packages
This should probably be maintained only in one place so this isn't necessary in the future.
-rw-r--r--src/_portage_utils61
1 files changed, 29 insertions, 32 deletions
diff --git a/src/_portage_utils b/src/_portage_utils
index dbb45d6..4638258 100644
--- a/src/_portage_utils
+++ b/src/_portage_utils
@@ -7,7 +7,7 @@ _portdir() {
local mainreponame mainrepopath overlayname overlaypath
if [[ -e /usr/share/portage/config/repos.conf ]]; then
- if [[ ${1} == -o ]]; then
+ if [[ ${1} == "-o" ]]; then
for overlayname in $(_parsereposconf -l); do
overlaypath+=($(_parsereposconf ${overlayname} location))
done
@@ -15,12 +15,9 @@ _portdir() {
source /etc/make.conf 2>/dev/null
source /etc/portage/make.conf 2>/dev/null
- overlaypath+=(${PORTDIR_OVERLAY})
+ overlaypath+=(${(@)PORTDIR_OVERLAY})
- # strip out duplicates
- overlaypath=($(printf "%s\n" "${overlaypath[@]}" | sort -u))
-
- echo "${overlaypath[@]}"
+ echo "${(@u)overlaypath}"
else
mainreponame=$(_parsereposconf DEFAULT main-repo)
mainrepopath=$(_parsereposconf ${mainreponame} location)
@@ -32,16 +29,16 @@ _portdir() {
source /etc/make.conf 2>/dev/null
source /etc/portage/make.conf 2>/dev/null
- echo "${PORTDIR}"
-
- if [[ ${1} == -o ]]; then⋅
- echo "${PORTDIR_OVERLAY}"
- fi⋅⋅⋅
+ if [[ ${1} == "-o" ]]; then
+ echo "${(@u)PORTDIR_OVERLAY}"
+ else
+ echo "${PORTDIR}"
+ fi
fi
}
_parsereposconf() {
- local f insection line section v value var
+ local v f insection section arr
for f in /usr/share/portage/config/repos.conf \
/etc/portage/repos.conf \
@@ -49,34 +46,34 @@ _parsereposconf() {
[[ -f ${f} ]] || continue
insection=0
+ declare -A arr
+ IFS='= '
+
+ while read -r name value; do
+ [[ -z ${name} || ${name} == '#'* ]] && continue
- while read -r line; do
- # skip comments and blank lines
- [[ -z ${line} || ${line} == '#'* ]] && continue
+ if [[ (${name} == '['*']') && (-z ${value}) ]]; then
+ value=${name//(\]|\[)}
+ name="section"
+ fi
+ arr[${name}]=${value}
- if [[ ${insection} == 1 && ${line} == '['*']' ]]; then
- # End of the section we were interested in so stop
- secname+=(${line//[(\[|\])]/}) # record name for -l
+ if [[ ${insection} == 1 && ${name} == "section" ]]; then
break
- elif [[ ${line} == '['*']' ]]; then
- # Entering a new section, check if it's the one we want
- section=${line//[(\[|\])]/}
- [[ ${section} == "${1}" ]] && insection=1
- secname+=(${section}) # record name for -l
+ elif [[ ${name} == "section" ]]; then
+ [[ ${value} == ${1} ]] && insection=1
+ secname+=(${value})
elif [[ ${insection} == 1 ]]; then
- # We're in the section we want, grab the values
- var=${line%%=*}
- var=${var// /}
- value=${line#*=}
- value=${value# }
- [[ ${var} == ${2} ]] && v=${value}
+ if [[ ${name} == ${2} ]]; then
+ v=${value}
+ fi
fi
continue
- done < "${f}"
+ done < ${f}
done
- if [[ ${1} == -l ]]; then
- echo "${secname[@]}"
+ if [[ ${1} == "-l" ]]; then
+ echo "${(@)secname}"
else
echo "${v}"
fi