From cab68b75fdf70d400f301e21472cda3a00fa1ccf Mon Sep 17 00:00:00 2001 From: Alexander Sulfrian Date: Wed, 29 Oct 2008 03:59:02 +0100 Subject: gentoo specific alias --- bashrc/dist/gentoo/common.sh | 1 + bashrc/dist/gentoo/portdir.sh | 62 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+) create mode 100644 bashrc/dist/gentoo/common.sh create mode 100644 bashrc/dist/gentoo/portdir.sh (limited to 'bashrc/dist/gentoo') 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 +} -- cgit v1.2.3