blob: 3dad709aa1e83a7f0ab4faac36c416006b10ee36 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
#autoload
# Usage:
# _gentoo_repos_conf -l -> returns the list of all repos names
# _gentoo_repos_conf REPO ATTRIBUTE -> returns the VALUE associated
# with the ATTRIBUTE of the REPO
_gentoo_repos_conf() {
local v file insection section arr secname
secname=();
for file in ${EPREFIX}/usr/share/portage/config/repos.conf \
${EPREFIX}/etc/portage/repos.conf \
${EPREFIX}/etc/portage/repos.conf/*.conf; do
[[ -f ${file} ]] || continue
insection=0
declare -A arr
IFS='= '
while read -r name value; do
[[ -z ${name} || ${name} == '#'* ]] && continue
if [[ (${name} == '['*']') && (-z ${value}) ]]; then
value=${name//(\]|\[)}
name="section"
fi
arr[${name}]=${value}
if [[ ${insection} == 1 && ${name} == "section" ]]; then
break
elif [[ ${name} == "section" ]]; then
[[ ${value} == ${1} ]] && insection=1
secname+=(${value})
elif [[ ${insection} == 1 ]]; then
if [[ ${name} == ${2} ]]; then
v=${value}
fi
fi
continue
done < ${file}
done
if [[ ${1} == "-l" ]]; then
echo "${(@u)secname}"
else
echo "${v}"
fi
}
_gentoo_repos_conf "$@"
# vim: set et sw=2 ts=2 ft=zsh:
|