summaryrefslogtreecommitdiffstats
path: root/bashrc/dist/gentoo
diff options
context:
space:
mode:
authorAlexander Sulfrian <alexander@sulfrian.net>2008-10-29 03:59:02 +0100
committerAlexander Sulfrian <alexander@sulfrian.net>2008-10-29 03:59:02 +0100
commitcab68b75fdf70d400f301e21472cda3a00fa1ccf (patch)
tree190705392807df41b1fc88688dbdacd00b4862a0 /bashrc/dist/gentoo
parent5bfcbe65d605384d973ce21d1103413c13f5e07f (diff)
downloaddotfiles-cab68b75fdf70d400f301e21472cda3a00fa1ccf.tar.gz
dotfiles-cab68b75fdf70d400f301e21472cda3a00fa1ccf.tar.xz
dotfiles-cab68b75fdf70d400f301e21472cda3a00fa1ccf.zip
gentoo specific alias
Diffstat (limited to 'bashrc/dist/gentoo')
-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
+}