summaryrefslogtreecommitdiffstats
path: root/bashrc/dist
diff options
context:
space:
mode:
Diffstat (limited to 'bashrc/dist')
-rw-r--r--bashrc/dist/gentoo/common.sh1
-rw-r--r--bashrc/dist/gentoo/portdir.sh62
2 files changed, 63 insertions, 0 deletions
diff --git a/bashrc/dist/gentoo/common.sh b/bashrc/dist/gentoo/common.sh
new file mode 100644
index 0000000..904c440
--- /dev/null
+++ b/bashrc/dist/gentoo/common.sh
@@ -0,0 +1 @@
+_load dist portdir
diff --git a/bashrc/dist/gentoo/portdir.sh b/bashrc/dist/gentoo/portdir.sh
new file mode 100644
index 0000000..c10347a
--- /dev/null
+++ b/bashrc/dist/gentoo/portdir.sh
@@ -0,0 +1,62 @@
+# portdir goodies
+eportdir() {
+ if [[ -n "${PORTDIR_CACHE}" ]]; then
+ echo "${PORTDIR_CACHE}"
+ elif [[ -d /usr/portage ]]; then
+ PORTDIR_CACHE="/usr/portage"
+ eportdir
+ else
+ PORTDIR_CACHE="$(portageq portdir)"
+ eportdir
+ fi
+}
+
+echo1() { echo "$1"; }
+
+efind() {
+ local d cat pkg
+ d=$(eportdir)
+
+ case $1 in
+ *-*/*)
+ pkg=${1##*/}
+ cat=${1%/*}
+ ;;
+
+ ?*)
+ pkg=${1}
+ cat=$(echo1 ${d}/*-*/${pkg}/*.ebuild)
+ [[ -f $cat ]] || cat=$(echo1 ${d}/*-*/${pkg}*/*.ebuild)
+ [[ -f $cat ]] || cat=$(echo1 ${d}/*-*/*${pkg}/*.ebuild)
+ [[ -f $cat ]] || cat=$(echo1 ${d}/*-*/*${pkg}*/*.ebuild)
+ if [[ ! -f $cat ]]; then
+ return 1
+ fi
+ pkg=${cat%/*}
+ pkg=${pkg##*/}
+ cat=${cat#${d}/}
+ cat=${cat%%/*}
+ ;;
+ esac
+
+ echo ${cat}/${pkg}
+}
+
+ecd() {
+ local pc d
+ pc=$(efind $@)
+ d=$(eportdir)
+ [[ $pc == "" ]] && return 1
+ cd ${d}/${pc}
+}
+
+usedesc() {
+ local d
+ d=$(eportdir)
+
+ echo "global:"
+ grep "$1 - " ${d}/profiles/use.desc
+
+ echo "local:"
+ grep ":$1 - " ${d}/profiles/use.local.desc
+}