# Author: Daniel Drake # http://dev.gentoo.org/~dsd/development-platform/ source /usr/lib/portage/bin/ebuild.sh daemonize source /usr/lib/portage/bin/ebuild-functions.sh SANDBOX_ON=1 ECLASSDIR="/usr/portage/eclass" PATH="${PATH}:/usr/lib/portage/bin" # Redefine unpack with an empty function, as we will be providing the sources unset unpack unpack() { einfo "Would normally unpack: $*" } # Find an ebuild of the specified name and version, source it, and set up the # development ebuild environment. # Usage: use-ebuild use-ebuild() { S="$(pwd)" T="/tmp" PN="$1" PVR="$2" PV="${PVR%-r*}" # FIXME i'm wrong P="${PN}-${PV}" PF="${PN}-${PVR}" EBUILD="${PF}.ebuild" ecd ${PN} FILESDIR="$(pwd)/files" source ${EBUILD} cd ${S} } # From ciaranm's bashrc 2005-05-02 # change to an ebuild's directory. ecd() { local pc d pc=$(efind $*) d=$(eportdir) if [[ $pc == "" ]] ; then echo "nothing found for $*" return 1 fi cd ${d}/${pc} } # From ciaranm's bashrc 2005-05-02 # find a given ebuild. based upon code by agriffis. does some fancy prediction, # so it will find categories if necessary (eg efind sparc-dev-sources will find # sys-kernel/sparc-dev-sources, and does partial name matching). prints the # result in the form category/package . efind() { local efinddir cat pkg efinddir=$(eportdir) case $1 in *-*/*) pkg=${1##*/} cat=${1%/*} ;; ?*) pkg=${1} cat=$(echo1 ${efinddir}/*-*/${pkg}/*.ebuild) [[ -f $cat ]] || cat=$(echo1 ${efinddir}/*-*/${pkg}*/*.ebuild) [[ -f $cat ]] || cat=$(echo1 ${efinddir}/*-*/*${pkg}/*.ebuild) [[ -f $cat ]] || cat=$(echo1 ${efinddir}/*-*/*${pkg}*/*.ebuild) if [[ ! -f $cat ]]; then return 1 fi pkg=${cat%/*} pkg=${pkg##*/} cat=${cat#${efinddir}/} cat=${cat%%/*} ;; esac echo ${cat}/${pkg} } # From ciaranm's bashrc 2005-05-02 # find either a cvs co of gentoo's portage module or the portage directory, and # echo the result. eportdir() { # does fast cache magic. portageq in particular is really slow... this makes # subsequent calls to eportdir() pretty much instantaneous, as opposed to # taking several seconds. if [[ -n "${PORTDIR_CACHE}" ]] ; then echo "${PORTDIR_CACHE}" elif [[ -d ${HOME}/cvs/portage ]] ; then PORTDIR_CACHE="${HOME}/cvs/portage" eportdir elif [[ -d /usr/portage ]] ; then PORTDIR_CACHE="/usr/portage" eportdir else PORTDIR_CACHE="$(portageq portdir )" eportdir fi } # From ciaranm's bashrc 2005-05-02 echo1() { echo "$1" }