diff options
author | Karl Trygve Kalleberg <karltk@gentoo.org> | 2005-02-13 01:22:44 +0000 |
---|---|---|
committer | Karl Trygve Kalleberg <karltk@gentoo.org> | 2005-02-13 01:22:44 +0000 |
commit | 8717630a95014611745feee5841411a6456699d5 (patch) | |
tree | 962b5d273fedbab8751f8ca4d2dff24469487e5a /eclass/eclipse-ext.eclass | |
parent | Version bump for bug 81809. 2.04 stable on x86. (diff) | |
download | historical-8717630a95014611745feee5841411a6456699d5.tar.gz historical-8717630a95014611745feee5841411a6456699d5.tar.bz2 historical-8717630a95014611745feee5841411a6456699d5.zip |
Added simplistic plugin path resolver code.
Diffstat (limited to 'eclass/eclipse-ext.eclass')
-rw-r--r-- | eclass/eclipse-ext.eclass | 140 |
1 files changed, 129 insertions, 11 deletions
diff --git a/eclass/eclipse-ext.eclass b/eclass/eclipse-ext.eclass index 1e5c54a9bde3..599298d6ff08 100644 --- a/eclass/eclipse-ext.eclass +++ b/eclass/eclipse-ext.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/eclipse-ext.eclass,v 1.7 2004/09/15 23:10:21 kugelfang Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/eclipse-ext.eclass,v 1.8 2005/02/13 01:22:44 karltk Exp $ # Author: Karl Trygve Kalleberg <karltk@gentoo.org> # Maintainer: Karl Trygve Kalleberg <karltk@gentoo.org> @@ -11,9 +11,48 @@ INHERITED="${INHERITED} ${ECLASS}" IUSE="${IUSE}" SLOT="${SLOT}" -eclipse_ext_type="source" -eclipse_ext_slot="0" -eclipse_ext_basedir="/usr/lib-eclipse-${eclipse_ext_slot}" +# Must be listed in oldest->newest order! +known_eclipse_slots="2 3 3.1" + +# These should not be reinitialized if previously set +# (check allows require-slot in pkg_setup) + +[ -z "${eclipse_ext_type}" ] && \ + eclipse_ext_type="source" + +[ -z "${eclipse_ext_slot}" ] && \ + eclipse_ext_slot="0" + +[ -z "${eclipse_ext_basedir}" ] && \ + eclipse_ext_basedir="/usr/$(get_libdir)/eclipse-extensions-${eclipse_ext_slot}/eclipse" + +[ -z "${eclipse_ext_platformdir}" ] && \ + eclipse_ext_platformdir="/usr/$(get_libdir)/eclipse-${eclipse_ext_slot}" + +# --------------------------------------------------------------------------- +# @private _find-optimum-slot +# +# Look for a given SLOT. If not found return the least highest SLOT +# available. +# +# @param $1 - SLOT of Eclipse SDK that is most desired +# @return 0 - all is well, non-zero otherwise +# --------------------------------------------------------------------------- +function _find-optimum-slot { + local found=false + + for x in ${known_eclipse_slots} ; do + if [ "$1" == "$x" ] ; then + found=true + fi + if [ "${found}" == "true" ] && [ -d /usr/$(get_libdir)/eclipse-${x} ] ; then + echo $x + return 0 + fi + done + echo "" + return 1 +} # --------------------------------------------------------------------------- # @public require-slot @@ -26,15 +65,21 @@ eclipse_ext_basedir="/usr/lib-eclipse-${eclipse_ext_slot}" # @return 0 - all is well, non-zero otherwise # --------------------------------------------------------------------------- function eclipse-ext_require-slot { - # karltk: Should probably add support for a span of slots - local slot=$1 - if [ ! -d /usr/$(get_libdir)/eclipse-${slot} ] ; then - eerror "Cannot find any installed Eclipse SDK for slot ${slot}" + + local slot=$(_find-optimum-slot $1) + + if [ -z "${slot}" ] ; then + eerror "Cannot find any Eclipse SDK supporting slot $1" return 1 fi + if [ "${slot}" != "$1" ] ; then + ewarn "Slot $1 could not be satisfied, installing for ${slot} instead" + fi + eclipse_ext_slot=${slot} - eclipse_ext_basedir="/usr/lib-eclipse-${eclipse_ext_slot}" + eclipse_ext_basedir="/usr/$(get_libdir)/eclipse-extensions-${eclipse_ext_slot}/eclipse" + eclipse_ext_platformdir="/usr/$(get_libdir)/eclipse-${eclipse_ext_slot}" return 0 } @@ -56,8 +101,9 @@ function eclipse-ext_create-ext-layout { dodir ${eclipse_ext_basedir}/{features,plugins} touch ${D}/${eclipse_ext_basedir}/.eclipseextension else - eclipse_ext_basedir="/usr/$(get_libdir)/eclipse-${eclipse_ext_slot}" + eclipse_ext_basedir="/usr/$(get_libdir)/eclipse-extensions-${eclipse_ext_slot}/eclipse" dodir ${eclipse_ext_basedir}/{features,plugins} + touch ${D}/${eclipse_ext_basedir}/.eclipseextension fi } @@ -123,9 +169,81 @@ function eclipse-ext_install-plugins { function eclipse-ext_pkg_postinst() { einfo "For tips, tricks and general info on running Eclipse on Gentoo, go to:" - einfo "http://dev.gentoo.org/~karltk/projects/eclipse/" + einfo "http://gentoo-wiki.com/Eclipse" } function pkg_postinst() { eclipse-ext_pkg_postinst } + +# --------------------------------------------------------------------------- +# @public get-classpath +# +# Tries to parse out a classpath string from a build.properties file. Is very +# stupid: Assumes it's a one-liner on the form classpath = comma:separated: +# +# @param $1 - name of the file (typically build.properties) +# @param $2 - name of the one-liner env var (default 'classpath') +# @return - echo of space-separated classpath entries. +# --------------------------------------------------------------------------- + +eclipse-ext_get-classpath() { + + local file=$1 + local envvar="classpath" + + if [ "$1" == "build.properties" ] ; then + if [ ! -z "$2" ] ; then + envvar="$2" + fi + fi + + echo "$(cat ${FILESDIR}/build.properties-${PV} | sed "s/.*=//" | tr ';' ' ')" +} + +_path-dissecter() { + echo $1 | sed -r "s/.*\/([^/]+)_([0-9.]+)\/(.*)/\\${2}/" +} + +_get-plugin-name() { + _path-dissecter $1 1 +} + +_get-plugin-version() { + _path-dissecter $1 2 +} + +_get-plugin-content() { + _path-dissecter $1 3 +} + +# --------------------------------------------------------------------------- +# @public resolve-jars +# +# Takes a space-separated list of plugin_version/subdirs/file.jar entries and +# tries to resolve the version for the plugin against the chosen eclipse version +# (set by require-slot). +# +# Note: You must call require-slot prior to calling resolve-jars. +# +# @param $1 - string with space-separated plugin/jarfile +# @return - echo of :-separated resolved files +# --------------------------------------------------------------------------- +eclipse-ext_resolve-jars() { + + local resolved="" + + for x in $1 ; do + local jarfile=$(_get-plugin-content $x) + local name="$(_get-plugin-name $x)" + local x=$(echo ${eclipse_ext_platformdir}/plugins/${name}_*/${jarfile}) + if [ -f ${x} ] ; then + resolved="${resolved}:$x" + else + : + #echo "Warning: did not find ${name}" + fi + done + echo ${resolved} +} + |