summaryrefslogtreecommitdiff
path: root/gentoo
diff options
context:
space:
mode:
Diffstat (limited to 'gentoo')
-rw-r--r--gentoo144
1 files changed, 72 insertions, 72 deletions
diff --git a/gentoo b/gentoo
index f262fcc..5266731 100644
--- a/gentoo
+++ b/gentoo
@@ -23,83 +23,83 @@
# This would be a hell of a lot simpler if we used portageq, but also about
# 500 times slower.
_portdir() {
- if [[ -e @GENTOO_PORTAGE_EPREFIX@/usr/share/portage/config/repos.conf ]]; then
- if [[ ${1} == '-o' ]]; then
- for overlayname in $(_parsereposconf -l); do
- overlaypath+=($(_parsereposconf ${overlayname} location))
- done
-
- source @GENTOO_PORTAGE_EPREFIX@/etc/make.conf 2>/dev/null
- source @GENTOO_PORTAGE_EPREFIX@/etc/portage/make.conf 2>/dev/null
-
- overlaypath+=(${PORTDIR_OVERLAY})
-
- # strip out duplicates
- overlaypath=($(printf "%s\n" "${overlaypath[@]}" | sort -u))
-
- echo "${overlaypath[@]}"
- else
- mainreponame=$(_parsereposconf DEFAULT main-repo)
- mainrepopath=$(_parsereposconf ${mainreponame} location)
-
- echo "${mainrepopath}"
- fi
- else
- source @GENTOO_PORTAGE_EPREFIX@/usr/share/portage/config/make.globals 2>/dev/null
- source @GENTOO_PORTAGE_EPREFIX@/etc/make.conf 2>/dev/null
- source @GENTOO_PORTAGE_EPREFIX@/etc/portage/make.conf 2>/dev/null
-
- echo "${PORTDIR}"
-
- if [[ ${1} == '-o' ]]; then
- echo "${PORTDIR_OVERLAY}"
- fi
- fi
+ if [[ -e @GENTOO_PORTAGE_EPREFIX@/usr/share/portage/config/repos.conf ]]; then
+ if [[ ${1} == '-o' ]]; then
+ for overlayname in $(_parsereposconf -l); do
+ overlaypath+=($(_parsereposconf ${overlayname} location))
+ done
+
+ source @GENTOO_PORTAGE_EPREFIX@/etc/make.conf 2>/dev/null
+ source @GENTOO_PORTAGE_EPREFIX@/etc/portage/make.conf 2>/dev/null
+
+ overlaypath+=(${PORTDIR_OVERLAY})
+
+ # strip out duplicates
+ overlaypath=($(printf "%s\n" "${overlaypath[@]}" | sort -u))
+
+ echo "${overlaypath[@]}"
+ else
+ mainreponame=$(_parsereposconf DEFAULT main-repo)
+ mainrepopath=$(_parsereposconf ${mainreponame} location)
+
+ echo "${mainrepopath}"
+ fi
+ else
+ source @GENTOO_PORTAGE_EPREFIX@/usr/share/portage/config/make.globals 2>/dev/null
+ source @GENTOO_PORTAGE_EPREFIX@/etc/make.conf 2>/dev/null
+ source @GENTOO_PORTAGE_EPREFIX@/etc/portage/make.conf 2>/dev/null
+
+ echo "${PORTDIR}"
+
+ if [[ ${1} == '-o' ]]; then
+ echo "${PORTDIR_OVERLAY}"
+ fi
+ fi
}
# _parsereposconf [-l] <repo> <variable>
# -l lists available repos
_parsereposconf() {
- local f insection line section v value var
-
- for f in @GENTOO_PORTAGE_EPREFIX@/usr/share/portage/config/repos.conf \
- @GENTOO_PORTAGE_EPREFIX@/etc/portage/repos.conf \
- @GENTOO_PORTAGE_EPREFIX@/etc/portage/repos.conf/*.conf; do
-
- if [[ -f ${f} ]]; then
- insection=0
-
- while read line; do
- # skip comments and blank lines
- [[ -z ${line} || ${line:0:1} == "#" ]] && continue
-
- if [[ ${insection} == 1 && ${line} =~ ^\[.*\]$ ]]; then
- # End of the section we were interested in so stop
- secname+=(${line//[(\[|\])]/}) # record name for -l
- 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 [[ ${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}"
- fi
- continue
- done < "${f}"
- fi
- done
-
- if [[ ${1} == -l ]]; then
- echo "${secname[@]}"
- else
- echo "${v}"
- fi
+ local f insection line section v value var
+
+ for f in @GENTOO_PORTAGE_EPREFIX@/usr/share/portage/config/repos.conf \
+ @GENTOO_PORTAGE_EPREFIX@/etc/portage/repos.conf \
+ @GENTOO_PORTAGE_EPREFIX@/etc/portage/repos.conf/*.conf; do
+
+ if [[ -f ${f} ]]; then
+ insection=0
+
+ while read line; do
+ # skip comments and blank lines
+ [[ -z ${line} || ${line:0:1} == "#" ]] && continue
+
+ if [[ ${insection} == 1 && ${line} =~ ^\[.*\]$ ]]; then
+ # End of the section we were interested in so stop
+ secname+=(${line//[(\[|\])]/}) # record name for -l
+ 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 [[ ${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}"
+ fi
+ continue
+ done < "${f}"
+ fi
+ done
+
+ if [[ ${1} == -l ]]; then
+ echo "${secname[@]}"
+ else
+ echo "${v}"
+ fi
}
# like _pkgname but completes on package names only (no category)