1 |
commit: 2b6c19533a92911f4b006ff55326b24ff543a114 |
2 |
Author: Tim Harder <radhermit <AT> gentoo <DOT> org> |
3 |
AuthorDate: Mon Dec 1 00:47:07 2014 +0000 |
4 |
Commit: Tim Harder <radhermit <AT> gentoo <DOT> org> |
5 |
CommitDate: Mon Dec 1 07:33:39 2014 +0000 |
6 |
URL: http://sources.gentoo.org/gitweb/?p=proj/zsh-completion.git;a=commit;h=2b6c1953 |
7 |
|
8 |
_portage_utils: sync portdir/reposconf changes from _gentoo_packages |
9 |
|
10 |
This should probably be maintained only in one place so this isn't |
11 |
necessary in the future. |
12 |
|
13 |
--- |
14 |
src/_portage_utils | 61 ++++++++++++++++++++++++++---------------------------- |
15 |
1 file changed, 29 insertions(+), 32 deletions(-) |
16 |
|
17 |
diff --git a/src/_portage_utils b/src/_portage_utils |
18 |
index dbb45d6..4638258 100644 |
19 |
--- a/src/_portage_utils |
20 |
+++ b/src/_portage_utils |
21 |
@@ -7,7 +7,7 @@ _portdir() { |
22 |
local mainreponame mainrepopath overlayname overlaypath |
23 |
|
24 |
if [[ -e /usr/share/portage/config/repos.conf ]]; then |
25 |
- if [[ ${1} == -o ]]; then |
26 |
+ if [[ ${1} == "-o" ]]; then |
27 |
for overlayname in $(_parsereposconf -l); do |
28 |
overlaypath+=($(_parsereposconf ${overlayname} location)) |
29 |
done |
30 |
@@ -15,12 +15,9 @@ _portdir() { |
31 |
source /etc/make.conf 2>/dev/null |
32 |
source /etc/portage/make.conf 2>/dev/null |
33 |
|
34 |
- overlaypath+=(${PORTDIR_OVERLAY}) |
35 |
+ overlaypath+=(${(@)PORTDIR_OVERLAY}) |
36 |
|
37 |
- # strip out duplicates |
38 |
- overlaypath=($(printf "%s\n" "${overlaypath[@]}" | sort -u)) |
39 |
- |
40 |
- echo "${overlaypath[@]}" |
41 |
+ echo "${(@u)overlaypath}" |
42 |
else |
43 |
mainreponame=$(_parsereposconf DEFAULT main-repo) |
44 |
mainrepopath=$(_parsereposconf ${mainreponame} location) |
45 |
@@ -32,16 +29,16 @@ _portdir() { |
46 |
source /etc/make.conf 2>/dev/null |
47 |
source /etc/portage/make.conf 2>/dev/null |
48 |
|
49 |
- echo "${PORTDIR}" |
50 |
- |
51 |
- if [[ ${1} == -o ]]; then⋅ |
52 |
- echo "${PORTDIR_OVERLAY}" |
53 |
- fi⋅⋅⋅ |
54 |
+ if [[ ${1} == "-o" ]]; then |
55 |
+ echo "${(@u)PORTDIR_OVERLAY}" |
56 |
+ else |
57 |
+ echo "${PORTDIR}" |
58 |
+ fi |
59 |
fi |
60 |
} |
61 |
|
62 |
_parsereposconf() { |
63 |
- local f insection line section v value var |
64 |
+ local v f insection section arr |
65 |
|
66 |
for f in /usr/share/portage/config/repos.conf \ |
67 |
/etc/portage/repos.conf \ |
68 |
@@ -49,34 +46,34 @@ _parsereposconf() { |
69 |
|
70 |
[[ -f ${f} ]] || continue |
71 |
insection=0 |
72 |
+ declare -A arr |
73 |
+ IFS='= ' |
74 |
+ |
75 |
+ while read -r name value; do |
76 |
+ [[ -z ${name} || ${name} == '#'* ]] && continue |
77 |
|
78 |
- while read -r line; do |
79 |
- # skip comments and blank lines |
80 |
- [[ -z ${line} || ${line} == '#'* ]] && continue |
81 |
+ if [[ (${name} == '['*']') && (-z ${value}) ]]; then |
82 |
+ value=${name//(\]|\[)} |
83 |
+ name="section" |
84 |
+ fi |
85 |
+ arr[${name}]=${value} |
86 |
|
87 |
- if [[ ${insection} == 1 && ${line} == '['*']' ]]; then |
88 |
- # End of the section we were interested in so stop |
89 |
- secname+=(${line//[(\[|\])]/}) # record name for -l |
90 |
+ if [[ ${insection} == 1 && ${name} == "section" ]]; then |
91 |
break |
92 |
- elif [[ ${line} == '['*']' ]]; then |
93 |
- # Entering a new section, check if it's the one we want |
94 |
- section=${line//[(\[|\])]/} |
95 |
- [[ ${section} == "${1}" ]] && insection=1 |
96 |
- secname+=(${section}) # record name for -l |
97 |
+ elif [[ ${name} == "section" ]]; then |
98 |
+ [[ ${value} == ${1} ]] && insection=1 |
99 |
+ secname+=(${value}) |
100 |
elif [[ ${insection} == 1 ]]; then |
101 |
- # We're in the section we want, grab the values |
102 |
- var=${line%%=*} |
103 |
- var=${var// /} |
104 |
- value=${line#*=} |
105 |
- value=${value# } |
106 |
- [[ ${var} == ${2} ]] && v=${value} |
107 |
+ if [[ ${name} == ${2} ]]; then |
108 |
+ v=${value} |
109 |
+ fi |
110 |
fi |
111 |
continue |
112 |
- done < "${f}" |
113 |
+ done < ${f} |
114 |
done |
115 |
|
116 |
- if [[ ${1} == -l ]]; then |
117 |
- echo "${secname[@]}" |
118 |
+ if [[ ${1} == "-l" ]]; then |
119 |
+ echo "${(@)secname}" |
120 |
else |
121 |
echo "${v}" |
122 |
fi |