See ChangeLog. :)
authoridl0r <idl0r@gentoo.org>
Mon, 20 Jul 2009 17:52:23 +0000 (17:52 -0000)
committeridl0r <idl0r@gentoo.org>
Mon, 20 Jul 2009 17:52:23 +0000 (17:52 -0000)
svn path=/trunk/gentoolkit-dev/; revision=668

ChangeLog
Makefile
Makefile.skel [new file with mode: 0644]
README
README.Developer
makedefs.mak
release.sh [deleted file]
src/eshowkw/Makefile [new file with mode: 0644]
src/eshowkw/eshowkw [new file with mode: 0644]
src/eshowkw/eshowkw.1 [new file with mode: 0644]

index 07aeca82c4e4517076d97fa6866fbd670998d5c9..ae82ce4d63b6c8d275bb9326a44e70446f08e094 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,20 @@
+2009-07-20: Christian Ruppert <idl0r@gentoo.org>
+       * README.Developer, README: Some clean-up.
+       * Makefile, Makefile.skel, makedefs.mak: Some minor improvements. Fix
+         docdir to use gentoolkit-dev instead of gentoolkit. Add all and clean
+         targets (skeletons) to makedefs.mak. Fix test target to be
+         parallel-build compatible. Add Makefile.skel as example for new tools.
+       * src/eshowkw/eshowkw.1, src/eshowkw/eshowkw,
+         src/eshowkw/Makefile: Add new tool eshowkw, thanks to Fabian Groffen
+         <grobian@gentoo.org>
+       * release.sh: Removed, I think it is not needed anymore.
+
+2009-07-19: Christian Ruppert <idl0r@gentoo.org>
+       * src/ebump/ebump: Use svn cp instead of cp if vcs == svn, thanks to Justin
+         Lecher (jlec) <jlec@j-schmitz.net>.
+       * src/ekeyword/Makefile src/eviewcvs/Makefile: Add a clean target to remove
+         generated manpages.
+
 2009-06-03: Christian Ruppert <idl0r@gentoo.org>
        Cleanup, update ChangeLog, README, TODO.
        * src/echangelog/echangelog: Add support for bzr. Cleanup. Removed git related if statement in check
index 02d7d788f374603b7c1fd92f25d6ece85a934a2b..fdd48a7218da0e8e4d5fb274b23a5bb429ce90e8 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,54 +1,54 @@
-# Copyright 2003-2004 Karl Trygve Kalleberg <karltk@gentoo.org>
-# Copyright 2003-2004 Gentoo Technologies, Inc.
+# Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-#
-# $Header$
+# $Header: $
 
 include makedefs.mak
 
+TOOLS=ebump echangelog ego ekeyword eshowkw eviewcvs imlate
+RELEASE="gentoolkit-dev-$(VERSION)$(RELEASE_TAG)"
 
 all:
-       echo "YARMOUTH (vb.) To shout at foreigners in the belief that the louder you speak, the better they'll understand you." 
-       echo $(PYVERSION)
-       echo $(VERSION)
-       echo $(docdir)
-       echo $(bindir)
-       echo $(sbindir)
-       echo $(mandir)
-
+       @echo "YARMOUTH (vb.) To shout at foreigners in the belief that the louder you speak, the better they'll understand you." 
+       @echo "PYVERSION=$(PYVERSION)"
+       @echo "VERSION=$(VERSION)"
+       @echo "docdir=$(docdir)"
+       @echo "bindir=$(bindir)"
+       @echo "sbindir=$(sbindir)"
+       @echo "mandir=$(mandir)"
+
+# use $(TOOLS) if we have more than one test
 test:
-       make -C src/echangelog test
+       $(MAKE) -C src/echangelog test
 
 clean:
-       rm -rf release/*
-
-dist: dist-gentoolkit-dev
+       rm -rf release/
+       @for tool in $(TOOLS); do \
+               ( $(MAKE) -C src/$${tool} clean ) \
+       done
 
-dist-gentoolkit-dev:
+dist:
        mkdir -p release/gentoolkit-dev-$(VERSION)$(RELEASE_TAG)
-       for x in ekeyword echangelog ego ebump eviewcvs imlate; do \
-               ( cd src/$$x ; $(MAKE) distdir=release/gentoolkit-dev-$(VERSION)$(RELEASE_TAG) dist ) \
+       @for tool in $(TOOLS); do \
+               ( $(MAKE) -C src/$${tool} distdir=release/$(RELEASE) dist ) \
        done
-       cp Makefile AUTHORS README README.Developer TODO COPYING NEWS ChangeLog release/gentoolkit-dev-$(VERSION)$(RELEASE_TAG)/
-       cat makedefs.mak | \
-               sed "s/^VERSION=.*/VERSION=$(VERSION)/" | \
-               sed "s/^RELEASE_TAG=.*/RELEASE_TAG=$(RELEASE_TAG)/" | \
-               sed "s:^docdir=.*:docdir=\$$(DESTDIR)/usr/share/doc/gentoolkit-dev-\$$(VERSION)\$$(RELEASE_TAG):" \
-               > release/gentoolkit-dev-$(VERSION)$(RELEASE_TAG)/makedefs.mak
-       ( cd release ; tar zcf gentoolkit-dev-$(VERSION)$(RELEASE_TAG).tar.gz gentoolkit-dev-$(VERSION)$(RELEASE_TAG)/ )
+
+       cp Makefile AUTHORS README README.Developer TODO COPYING NEWS ChangeLog release/$(RELEASE)/
+
+       @sed -e "s/^VERSION=.*/VERSION=$(VERSION)/" \
+               -e "s/^RELEASE_TAG=.*/RELEASE_TAG=$(RELEASE_TAG)/" \
+               makedefs.mak > release/$(RELEASE)/makedefs.mak
+
+       ( cd release ; tar zcf $(RELEASE).tar.gz $(RELEASE)/ )
 
 install: install-gentoolkit-dev
 
-# FIXME: If run from the CVS tree, the documentation will be installed in
-#        $(DESTDIR)/usr/share/doc/gentoolkit-$(VERSION), not gentoolkit-dev-$(VERSION)
 install-gentoolkit-dev:
-
        install -d $(docdir)
        install -d $(bindir)
        install -d $(mandir)
 
        install -m 0644 AUTHORS ChangeLog COPYING NEWS README README.Developer TODO $(docdir)/
 
-       for x in ekeyword echangelog ego ebump eviewcvs imlate; do \
-               ( cd src/$$x ; $(MAKE) DESTDIR=$(DESTDIR) install ) \
+       @for tool in $(TOOLS); do \
+               ( $(MAKE) -C src/$${tool} DESTDIR=$(DESTDIR) install ) \
        done
diff --git a/Makefile.skel b/Makefile.skel
new file mode 100644 (file)
index 0000000..aa03f75
--- /dev/null
@@ -0,0 +1,18 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+include ../../makedefs.mak
+
+.PHONY: all
+
+all:
+
+dist:
+       mkdir -p ../../$(distdir)/src/<TOOL>/
+       cp Makefile <TOOL> <TOOL>.1 ../../$(distdir)/src/<TOOL>/
+
+install: all
+       install -m 0755 <TOOL> $(bindir)/
+       install -m 0644 <TOOL>.1 $(mandir)/
+
diff --git a/README b/README
index 7721cc3d8b6898db1e432d0f001a73f1858d15c3..992e86d3f2922a6e65c4420253967d0d254b3491 100644 (file)
--- a/README
+++ b/README
@@ -25,8 +25,9 @@ ebump          - Ebuild revision bumper
 echangelog     - update portage ChangeLogs
 ego            - 
 ekeyword       - modify package KEYWORDS
+eshowkw        - Display ebuild keywords in a graphical form
 eviewcvs       - generate viewcvs URLs
-imlate         -
+imlate         - Displays candidates for keywords for an architecture based upon a target architecture
 
 IMPROVEMENTS
 
index 6c48c84cda3830fb35b6f36b367e1a8c4d926dde..814c40bca435c26af17ff357190d94b073ae6ef9 100644 (file)
@@ -10,6 +10,9 @@ STYLE POLICY
 If you're touching any of the python scripts please don't change the indentation
 style (if it's using tabs, you should use tabs too). Especially don't mix
 spaces and tabs as that makes the code completely unreadable.
+Tabs should be default for new scripts.
+
+Each script must provide a manpage.
 
 MAKING A RELEASE
 
@@ -20,20 +23,14 @@ us a mail at tools-portage@gentoo.org if you need an immediate release.
 
 The release manager (big words;) will then do
 
-1) make VERSION=major.minor.patch RELEASE_TAG=<optional> dist-gentoolkit
-2) copy release/gentoolkit-${VERSION}-${RELEASE_TAG}.tar.gz to 
+1) make VERSION=major.minor.patch RELEASE_TAG=<optional> dist
+2) copy release/gentoolkit-dev-${VERSION}-${RELEASE_TAG}.tar.gz to 
    dev.gentoo.org/space/distfiles-local/
-3) make a new ebuild, app-portage/gentoolkit/gentoolkit-${VERSION}.ebuild
+3) make a new ebuild, app-portage/gentoolkit-dev/gentoolkit-dev-${VERSION}.ebuild
    with a SRC_URI that points to 
-   mirror://gentoo/gentoolkit-${VERSION}-${RELEASE_TAG}.tar.gz
+   mirror://gentoo/gentoolkit-dev-${VERSION}-${RELEASE_TAG}.tar.gz
    (just use one of the previous ebuilds)
 
-The process is similar for gentoolkit-dev:
-
-1) make dist-gentoolkit-dev
-2) copy dist/gentoolkit-dev-${VERSION}-${RELEASE_TAG}.tar.gz to emu
-3) update app-portage/gentoolkit-dev
-
 Important!
 1) _ALWAYS_ make sure you don't "overwrite" a previous release. Your
    new VERSION must be newer than any previous released version. If you
@@ -42,24 +39,11 @@ Important!
    it right;)
 
 
-MAKING A RELEASE WITH release.sh
-
-If you have added your system details at the top of the release.sh script,
-you can make a release in the following fashion:
-
-(NOTE! This only works for -dev at the moment)
-
-1) Add a notice in the ChangeLog about the release you are making.
-2) Do VERSION="x.y.z" ./release.sh dev
-3) Test the package: ACCEPT_KEYWORDS="~arch" emerge gentoolkit-dev
-4) Do a repoman ci -m "Released x.y.z" in your 
-   CVS/app-portage/gentoolkit-dev directory.
-
-
 Currently, the following people have "release access":
 
- - genone@gentoo.org
+ - zmedico@gentoo.org
  - fuzzyray@gentoo.org
+ - idl0r@gentoo.org
 
-If you want a new release, ping either of us. If you want to get 
+If you want a new release, ping either one of us. If you want to get 
 "release access", talk to fuzzyray@gentoo.org
index efbc8ce333b66c8eb243fa60dae36b6f7eb8f73f..2ec1e3eb528593890bdef00909c4a25be084c4b2 100644 (file)
@@ -1,20 +1,21 @@
-# Copyright 2003 Karl Trygve Kalleberg <karltk@gentoo.org>
-# Copyright 2003 Gentoo Technologies, Inc.
+# Copyright 1999-2009 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-#
-# $Header$
+# $Header: $
 
 # Override this on command line when making a release, ie 'dist'
-
 VERSION=9.9.9
 RELEASE_TAG=
+
 # python-config is not installed on all arches Bug #113386
-#PYVERSION="`python-config | sed 's/-l//' | sed 's/ -lm.*//'`"
 PYVERSION="`LC_COLLATE=C; python -V 2>&1 | tr '[:upper:]' '[:lower:]' | sed -e 's/ //g;s/\([0-9]\.[0-9]\)\.[0-9]/\1/'`"
 DESTDIR=
 
-docdir=$(DESTDIR)/usr/share/doc/gentoolkit-$(VERSION)$(RELEASE_TAG)
+docdir=$(DESTDIR)/usr/share/doc/gentoolkit-dev-$(VERSION)$(RELEASE_TAG)
 bindir=$(DESTDIR)/usr/bin
 sbindir=$(DESTDIR)/usr/sbin
 mandir=$(DESTDIR)/usr/share/man/man1
 sysconfdir=$(DESTDIR)/etc
+
+# skeletons
+all:
+clean:
diff --git a/release.sh b/release.sh
deleted file mode 100755 (executable)
index 22313b4..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-#! /bin/bash
-
-case $(whoami) in
-    karltk)
-       publish_path=dev.gentoo.org:public_html/projects/gentoolkit/releases
-       publish_public_path="http://dev.gentoo.org/~karltk/projects/gentoolkit/releases"
-       portdir=/home/karltk/source/oss/gentoo/gentoo-x86/
-       export ECHANGELOG_USER="Karl Trygve Kalleberg <karltk@gentoo.org>"
-       ;;
-
-    port001)
-       publish_path=dev.gentoo.org:public_html/distfiles/gentoolkit/releases
-       publish_public_path="http://dev.gentoo.org/~port001/distfiles/gentoolkit/releases"
-       portdir=/home/port001/Gentoo/gentoo-x86/
-       export ECHANGELOG_USER="Ian Leitch <port001@gentoo.org>"
-       ;;
-
-    genone)
-       publish_path=dev:public_html/distfiles/
-       publish_public_path="http://dev.gentoo.org/~genone/distfiles/"
-       portdir=/home/gentoo/cvs/gentoo-x86/
-       export ECHANGELOG_USER="Marius Mauch <genone@gentoo.org>"
-       ;;
-
-    agriffis)
-       publish_path=gentoo:public_html/dist/
-       publish_public_path="http://dev.gentoo.org/~agriffis/dist/"
-       portdir=/home/agriffis/portage/
-       ;;
-
-    *)
-       echo "!!! Don't know who $(whoami) is, can't release"
-       exit 1
-       ;;
-esac
-
-function most-recent-ebuild() {
-       # FIXME: actually pick the most recent one
-       ls gentoolkit-dev-*.ebuild | tail -n 1
-}
-
-function release-dev() {
-
-       echo "* Building .tar.bz"
-       make VERSION=${VERSION} RELEASE_TAG=${RELEASE_TAG} dist-gentoolkit-dev > /dev/null || exit
-
-       echo "* Uploading .tar.bz"
-       scp release/gentoolkit-dev-${VERSION}${RELEASE_TAG}.tar.gz ${publish_path} || exit
-
-       
-       echo "* Generating new ebuild"
-
-       local ebuild="gentoolkit-dev-${VERSION}${RELEASE_TAG}.ebuild"
-
-       cd ${portdir}/app-portage/gentoolkit-dev || exit
-       cp $(most-recent-ebuild) ${ebuild}
-       ekeyword ~all ${ebuild}
-       sed -i -e "s|SRC_URI=.*|SRC_URI=\"${publish_public_path}/\$\{\P\}.tar.gz\"|" ${ebuild}
-
-       echo "* Generating digest"
-       ebuild ${ebuild} digest || exit
-       cvs add ${ebuild} || exit
-       echangelog "New upstream release"
-       echo '* Everything ready. You should:'
-       echo '  1) ACCEPT_KEYWORDS="~x86" sudo emerge =gentoolkit-dev-${VERSION}${RELEASE_TAG}'
-       echo '  2) repoman ci -m "New upstream release" from `pwd`'
-}
-
-
-if [ -z "${VERSION}" ] ; then
-       echo "!!! You must set the VERSION env var"
-       exit 1
-fi
-
-if [ -z "${RELEASE_TAG}" ] ; then
-       echo "No RELEASE_TAG found, presumably okay"
-fi
-
-
-if [ "$1" == "dev" ] ; then
-       release-dev
-elif [ "$1" == "main" ] ; then
-       echo "!!! Unsupported atm, feel free to add code;)"
-       exit 1
-else
-       echo "!!! You must select to release either 'dev' or 'main', as parameter to release.sh"
-       exit 1
-fi
-
diff --git a/src/eshowkw/Makefile b/src/eshowkw/Makefile
new file mode 100644 (file)
index 0000000..77bf1d8
--- /dev/null
@@ -0,0 +1,18 @@
+# Copyright 1999-2009 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: $
+
+include ../../makedefs.mak
+
+.PHONY: all
+
+all:
+
+dist:
+       mkdir -p ../../$(distdir)/src/eshowkw/
+       cp Makefile eshowkw eshowkw.1 ../../$(distdir)/src/eshowkw/
+
+install: all
+       install -m 0755 eshowkw $(bindir)/
+       install -m 0644 eshowkw.1 $(mandir)/
+
diff --git a/src/eshowkw/eshowkw b/src/eshowkw/eshowkw
new file mode 100644 (file)
index 0000000..c174939
--- /dev/null
@@ -0,0 +1,352 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et tw=80 :
+
+# Author:        Ciaran McCreesh <ciaranm@gentoo.org>
+# Purpose:       Display ebuild keywords in a graphical form
+# Invocation:    eshowkw [ packagename ] (defaults to current directory if no
+#                packagename is provided)
+
+shopt -s extglob
+
+PID_TO_KILL=$$
+
+die() {
+    echo "$@" 1>&2
+    kill $PID_TO_KILL
+}
+
+trap 'exit 250' 15
+
+get_portage_dir() {
+    local dir
+    if [[ -z ${portage_dir_cache} ]] ; then
+        for dir in "${HOME}/cvs/gentoo-x86" "/usr/portage" ; do
+            [[ -d ${dir}/profiles ]] && portage_dir_cache=${dir} && break
+        done
+    fi
+    [[ -z ${portage_dir_cache} ]] && portage_dir_cache=$(portageq portdir )
+    export portage_dir_cache
+    echo ${portage_dir_cache}
+}
+
+version_sort() {
+    local items= left=0
+    items=( $@ )
+
+    while [[ ${left} -lt ${#items[@]} ]] ; do
+        local lowest_idx=${left}
+        local idx=$(( ${lowest_idx} + 1 ))
+        while [[ ${idx} -lt ${#items[@]} ]] ; do
+            version_compare "${items[${lowest_idx}]}" "${items[${idx}]}"
+            [[ $? -eq 3 ]] && lowest_idx=${idx}
+            idx=$(( ${idx} + 1 ))
+        done
+        local tmp=${items[${lowest_idx}]}
+        items[${lowest_idx}]=${items[${left}]}
+        items[${left}]=${tmp}
+        left=$(( ${left} + 1 ))
+    done
+    echo ${items[@]}
+}
+
+version_compare() {
+    local ver_a=${1} ver_b=${2} parts_a parts_b cur_idx_a=0 cur_idx_b=0
+    parts_a=( $(get_all_version_components "${ver_a}" ) )
+    parts_b=( $(get_all_version_components "${ver_b}" ) )
+
+    ### compare number parts.
+    local inf_loop=0
+    while true ; do
+        # grab the current number components
+        local cur_tok_a=${parts_a[${cur_idx_a}]}
+        local cur_tok_b=${parts_b[${cur_idx_b}]}
+
+        # number?
+        if [[ -n ${cur_tok_a} ]] && [[ -z ${cur_tok_a//[[:digit:]]} ]] ; then
+            cur_idx_a=$(( ${cur_idx_a} + 1 ))
+            [[ ${parts_a[${cur_idx_a}]} == "." ]] \
+                && cur_idx_a=$(( ${cur_idx_a} + 1 ))
+        else
+            cur_tok_a=""
+        fi
+
+        if [[ -n ${cur_tok_b} ]] && [[ -z ${cur_tok_b//[[:digit:]]} ]] ; then
+            cur_idx_b=$(( ${cur_idx_b} + 1 ))
+            [[ ${parts_b[${cur_idx_b}]} == "." ]] \
+                && cur_idx_b=$(( ${cur_idx_b} + 1 ))
+        else
+            cur_tok_b=""
+        fi
+
+        # done with number components?
+        [[ -z ${cur_tok_a} ]] && [[ -z ${cur_tok_b} ]] && break
+
+        # to avoid going into octal mode, strip any leading zeros. otherwise
+        # bash will throw a hissy fit on versions like 6.3.068.
+        cur_tok_a=${cur_tok_a##+(0)}
+        cur_tok_b=${cur_tok_b##+(0)}
+
+        # if a component is blank, make it zero.
+        [[ -z ${cur_tok_a} ]] && cur_tok_a=0
+        [[ -z ${cur_tok_b} ]] && cur_tok_b=0
+
+        # compare
+        [[ ${cur_tok_a} -lt ${cur_tok_b} ]] && return 1
+        [[ ${cur_tok_a} -gt ${cur_tok_b} ]] && return 3
+    done
+
+    ### number parts equal. compare letter parts.
+    local letter_a=
+    letter_a=${parts_a[${cur_idx_a}]}
+    if [[ ${#letter_a} -eq 1 ]] && [[ -z ${letter_a/[a-z]} ]] ; then
+        cur_idx_a=$(( ${cur_idx_a} + 1 ))
+    else
+        letter_a="@"
+    fi
+
+    local letter_b=
+    letter_b=${parts_b[${cur_idx_b}]}
+    if [[ ${#letter_b} -eq 1 ]] && [[ -z ${letter_b/[a-z]} ]] ; then
+        cur_idx_b=$(( ${cur_idx_b} + 1 ))
+    else
+        letter_b="@"
+    fi
+
+    # compare
+    [[ ${letter_a} < ${letter_b} ]] && return 1
+    [[ ${letter_a} > ${letter_b} ]] && return 3
+
+    ### letter parts equal. compare suffixes in order.
+    local suffix rule part r_lt r_gt
+    for rule in "alpha=1" "beta=1" "pre=1" "rc=1" "p=3" "r=3" ; do
+        suffix=${rule%%=*}
+        r_lt=${rule##*=}
+        [[ ${r_lt} -eq 1 ]] && r_gt=3 || r_gt=1
+
+        local suffix_a=
+        for part in ${parts_a[@]} ; do
+            [[ ${part#${suffix}} != ${part} ]] && \
+                [[ -z ${part##${suffix}*([[:digit:]])} ]] && \
+                suffix_a=${part#${suffix}}0
+        done
+
+        local suffix_b=
+        for part in ${parts_b[@]} ; do
+            [[ ${part#${suffix}} != ${part} ]] && \
+                [[ -z ${part##${suffix}*([[:digit:]])} ]] && \
+                suffix_b=${part#${suffix}}0
+        done
+
+        [[ -z ${suffix_a} ]] && [[ -z ${suffix_b} ]] && continue
+
+        [[ -z ${suffix_a} ]] && return ${r_gt}
+        [[ -z ${suffix_b} ]] && return ${r_lt}
+
+        # avoid octal problems
+        suffix_a=${suffix_a##+(0)} ; suffix_a=${suffix_a:-0}
+        suffix_b=${suffix_b##+(0)} ; suffix_b=${suffix_b:-0}
+
+        [[ ${suffix_a} -lt ${suffix_b} ]] && return 1
+        [[ ${suffix_a} -gt ${suffix_b} ]] && return 3
+    done
+
+    ### no differences.
+    return 2
+}
+
+get_all_version_components() {
+    local ver_str=${1} result result_idx=0
+    result=( )
+
+    while [[ -n "$ver_str" ]] ; do
+        case "${ver_str:0:1}" in
+            # number: parse whilst we have a number
+            [[:digit:]])
+                result[$result_idx]="${ver_str%%[^[:digit:]]*}"
+                ver_str="${ver_str##+([[:digit:]])}"
+                result_idx=$(($result_idx + 1))
+                ;;
+
+            # separator: single character
+            [-_.])
+                result[$result_idx]="${ver_str:0:1}"
+                ver_str="${ver_str:1}"
+                result_idx=$(($result_idx + 1))
+                ;;
+
+            # letter: grab the letters plus any following numbers
+            [[:alpha:]])
+                local not_match="${ver_str##+([[:alpha:]])*([[:digit:]])}"
+                result[$result_idx]=${ver_str:0:$((${#ver_str} - ${#not_match}))}
+                ver_str="${not_match}"
+                result_idx=$(($result_idx + 1))
+                ;;
+
+            # huh?
+            *)
+                result[$result_idx]="${ver_str:0:1}"
+                ver_str="${ver_str:1}"
+                result_idx=$(($result_idx + 1))
+                ;;
+        esac
+    done
+
+    echo ${result[@]}
+}
+
+get_package_dir() {
+    if [[ -z ${1} ]] ; then
+        pwd
+        return 0
+    fi
+
+    if [[ -d ${1} ]] ; then
+        readlink -f ${1}
+        return 0
+    fi
+
+    get_portage_dir 1>/dev/null
+    if [[ ${1/\/} != ${1} ]] ; then
+        local d=$(get_portage_dir )/${1}
+        if [[ -d ${d} ]] ; then
+            echo ${d}
+            return 0
+        fi
+    else
+        local d
+        d=( $(echo $(get_portage_dir )/*-*/${1} ) )
+        if [[ ${#d[@]} -gt 1 ]] ; then
+            die "${1} is ambiguous"
+        elif [[ -d ${d[0]} ]] ; then
+            echo ${d[0]}
+            return 0
+        fi
+    fi
+
+    return 1
+}
+
+repeat() {
+    local i
+    for (( i=0 ; i < ${1} ; i=$(( ${i} + 1 )) )) ; do
+        echo -n "${2}"
+    done
+}
+
+get_keywords() {
+    (
+        inherit() { :; }
+        source ${1} 2>/dev/null
+        echo ${KEYWORDS}
+    )
+}
+
+colorarch() {
+    case "${1}" in
+        amd64)
+            echo -n -e "\033[0;33m${2}\033[0;0m"
+            ;;
+        x86)
+            echo -n -e "\033[0;31m${2}\033[0;0m"
+            ;;
+        *)
+            echo -n "${2}"
+            ;;
+    esac
+}
+
+colourise() {
+    case "${1}" in
+        \*)
+            echo -n -e "\033[0;31m*\033[0;0m"
+            ;;
+        +)
+            echo -n -e "\033[0;32m+\033[0;0m"
+            ;;
+        -)
+            echo -n -e "\033[0;31m-\033[0;0m"
+            ;;
+        \~)
+            echo -n -e "\033[0;33m~\033[0;0m"
+            ;;
+        *)
+            echo -n "${1}"
+            ;;
+    esac
+}
+
+show_keyword_diagram() {
+    echo -n -e "Keywords for \033[1;34m"
+    local title=$(readlink -f $(pwd ) )
+    title=${title#$(readlink -f ../.. )/*( )}
+    echo -n "${title}"
+    echo -e "\033[0;0m:"
+    echo
+
+    local archs= arch_length=0 arch=
+    archs=( $(< $(get_portage_dir )/profiles/arch.list ) )
+    for arch in "${archs[@]}" ; do
+        [[ ${#arch} -gt ${arch_length} ]] && arch_length=${#arch}
+    done
+
+    local versions= pkgname= version_length=0 version=
+    pkgname=$(basename $(readlink -f ./ ) )
+    versions=( $(for e in $(echo *.ebuild ) ; do \
+            [[ -f ${e} ]] && echo ${e} | sed -e 's/\.ebuild$//g' \
+                    -e "s/^${pkgname}-//g" ; \
+            done ) )
+    versions=( $(version_sort ${versions[@]} ) )
+    for version in "${versions[@]}" ; do
+        [[ ${#version} -gt ${version_length} ]] && version_length=${#version}
+    done
+
+    local i=0 archletter=
+    for (( i = 0 ; i < ${arch_length} ; i=$(( ${i} + 1 )) )) ; do
+        repeat ${version_length} " "
+        echo -n " | "
+        for arch in "${archs[@]}" ; do
+            archletter="${arch:${i}:1}"
+            echo -n "$(colorarch "${arch}" "${archletter:- }" ) "
+        done
+        echo
+    done
+
+    repeat ${version_length} "-"
+    echo -n "-+"
+    repeat ${#archs[@]} "--"
+    echo
+
+    for version in "${versions[@]}" ; do
+        echo -n "${version}"
+        repeat $(( ${version_length} - ${#version} )) " "
+        echo -n " | "
+
+        local keyword keywords
+        keywords=( $(get_keywords "${pkgname}-${version}.ebuild" ) )
+        for arch in "${archs[@]}" ; do
+            local display=" "
+            [[ ${keywords[@]/-\*} != ${keywords[@]} ]] && display="*"
+            for keyword in "${keywords[@]}" ; do
+                [[ ${arch} == "${keyword#[~-]}" ]] && \
+                    display=${keyword:0:1} && \
+                    break;
+            done
+            [[ -z ${display#[~ *-]} ]] || display="+"
+            echo -n "$(colourise "${display}" ) "
+        done
+
+        echo
+    done
+}
+
+main() {
+    local dir=$(get_package_dir "${1}" )
+    [[ -z ${dir} ]] && die "Couldn't find '${1}'"
+    cd ${dir}
+    [[ $(echo *.ebuild ) != "*.ebuild" ]] || die "No ebuilds in ${dir}"
+    show_keyword_diagram
+    true
+}
+
+main "$@"
+
diff --git a/src/eshowkw/eshowkw.1 b/src/eshowkw/eshowkw.1
new file mode 100644 (file)
index 0000000..8d08048
--- /dev/null
@@ -0,0 +1,14 @@
+.TH "eshowkw" "1" "Ciaran McCreesh" "gentoolkit-dev"
+.SH "NAME"
+.LP 
+eshowkw \- Displays ebuild keywords in a graphical form.
+.SH "SYNTAX"
+.LP 
+eshowkw [ packagename ] (defaults to current directory if no packagename is provided)
+
+
+.SH "AUTHORS"
+.LP 
+Ciaran McCreesh <ciaranm@gentoo.org>
+.SH "BUGS"
+Please report any bugs to http://bugs.gentoo.org