From b2c279c0f1f7101788a8c432a08144c497bd9881 Mon Sep 17 00:00:00 2001 From: karltk Date: Sat, 10 Jan 2004 01:43:32 +0000 Subject: [PATCH] Added src/ego svn path=/; revision=61 --- trunk/ChangeLog | 4 +- trunk/src/ego/AUTHOR | 1 + trunk/src/ego/ChangeLog | 0 trunk/src/ego/README | 0 trunk/src/ego/TODO | 0 trunk/src/ego/ego | 86 +++++++++++++++++++++++++++++++++++++++++ 6 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 trunk/src/ego/AUTHOR create mode 100644 trunk/src/ego/ChangeLog create mode 100644 trunk/src/ego/README create mode 100644 trunk/src/ego/TODO create mode 100644 trunk/src/ego/ego diff --git a/trunk/ChangeLog b/trunk/ChangeLog index f7f6149..f353b68 100644 --- a/trunk/ChangeLog +++ b/trunk/ChangeLog @@ -1,5 +1,7 @@ +2004-01-10 Karl Trygve Kalleberg + * Added src/ego -2003-01-07 Karl Trygve Kalleberg +2004-01-07 Karl Trygve Kalleberg * Added new build system * Added src/old-scripts, the scripts from app-portage/gentoolkit * Renamed gentool to equery diff --git a/trunk/src/ego/AUTHOR b/trunk/src/ego/AUTHOR new file mode 100644 index 0000000..36d5bfd --- /dev/null +++ b/trunk/src/ego/AUTHOR @@ -0,0 +1 @@ +Aron Griffis diff --git a/trunk/src/ego/ChangeLog b/trunk/src/ego/ChangeLog new file mode 100644 index 0000000..e69de29 diff --git a/trunk/src/ego/README b/trunk/src/ego/README new file mode 100644 index 0000000..e69de29 diff --git a/trunk/src/ego/TODO b/trunk/src/ego/TODO new file mode 100644 index 0000000..e69de29 diff --git a/trunk/src/ego/ego b/trunk/src/ego/ego new file mode 100644 index 0000000..f1691f2 --- /dev/null +++ b/trunk/src/ego/ego @@ -0,0 +1,86 @@ +echo1() { + echo "$1" +} + +ego() { + local portdir tmpdir category pkg target + + # This is WAY faster than portageq: + # portdir=$(portageq portdir) + # tmpdir=$(portageq envvar PORTAGE_TMPDIR)/portage + eval $( + . /etc/make.globals + . /etc/make.conf + export PORTDIR PORTAGE_TMPDIR + export | sed -n ' + s/^declare -x PORTDIR=/portdir=/p + s/^declare -x PORTAGE_TMPDIR=\(.*\)/tmpdir=\1\/portage/p' + ) + + case $1 in + *-*/*) + pkg=${1##*/} + category=${1%/*} + ;; + + ?*) + pkg=$1 + # require an ebuild so that we can block deprecated packages + # such as dev-libs/rep-gtk + category=$(echo1 $portdir/*-*/$pkg/*.ebuild) + [[ -f $category ]] || category=$(echo1 $portdir/*-*/$pkg*/*.ebuild) + [[ -f $category ]] || category=$(echo1 $portdir/*-*/*$pkg/*.ebuild) + [[ -f $category ]] || category=$(echo1 $portdir/*-*/*$pkg*/*.ebuild) + if [[ ! -f $category ]]; then + echo "Can't find $pkg in $portdir" >&2 + return 1 + fi + pkg=${category%/*} + pkg=${pkg##*/} + category=${category#$portdir/} + category=${category%%/*} + ;; + + *) + # Check if we're under $portdir first + pkg=${PWD##*/} + category=${PWD%/*} + category=${category##*/} + if [[ ! -d $portdir/$category/$pkg ]]; then + # Next check if we're in PORTAGE_TMPDIR + if [[ $PWD = $tmpdir/* ]]; then + pkg=${PWD#$tmpdir/} + pkg=${pkg%%/*} + pkg=${pkg%%-[0-9]*} # not really a valid assumption + category=$(echo1 $portdir/*-*/$pkg/*.ebuild) + if [[ ! -f $category ]]; then + echo "Can't find $pkg in $portdir" >&2 + return 1 + fi + category=${category#$portdir/} + category=${category%%/*} + else + echo "syntax: ego [pkgname]" >&2 + echo "or simply ego from a dir under $portdir or $tmpdir" >&2 + return 1 + fi + fi + ;; + esac + + # go to tmpdir or portdir? + if [[ $PWD/ = */$category/$pkg/* ]]; then + [[ -n $tmpdir ]] || tmpdir=$(portageq envvar PORTAGE_TMPDIR)/portage + target=$(command ls -1td $tmpdir/$pkg-* 2>/dev/null | head -n 1) + if [[ -z $target ]]; then + echo "No matches found for $tmpdir/$pkg-*" >&2 + return 1 + fi + cd $target/work/$pkg* 2>/dev/null || + cd $target/work 2>/dev/null || + cd $target + else + cd $portdir/$category/$pkg + fi +} + -- 2.26.2