diff options
author | Adrian Almenar <strider@gentoo.org> | 2003-03-22 07:07:17 +0000 |
---|---|---|
committer | Adrian Almenar <strider@gentoo.org> | 2003-03-22 07:07:17 +0000 |
commit | f496053ec0153b2a8e7b8d03d5db6eae645885b2 (patch) | |
tree | 55651e2b76783cdb57cb76d50726a384a91745ff /dev-java/java-config | |
parent | Unstable bumpage (diff) | |
download | historical-f496053ec0153b2a8e7b8d03d5db6eae645885b2.tar.gz historical-f496053ec0153b2a8e7b8d03d5db6eae645885b2.tar.bz2 historical-f496053ec0153b2a8e7b8d03d5db6eae645885b2.zip |
New java-config with some enhancements for easy use.
Diffstat (limited to 'dev-java/java-config')
-rw-r--r-- | dev-java/java-config/files/0.2.8/30java-finalclasspath | 1 | ||||
-rw-r--r-- | dev-java/java-config/files/0.2.8/java-config | 397 | ||||
-rw-r--r-- | dev-java/java-config/files/0.2.8/java-config.1 | 104 | ||||
-rw-r--r-- | dev-java/java-config/files/digest-java-config-0.2.8 | 0 | ||||
-rw-r--r-- | dev-java/java-config/java-config-0.2.8.ebuild | 22 |
5 files changed, 524 insertions, 0 deletions
diff --git a/dev-java/java-config/files/0.2.8/30java-finalclasspath b/dev-java/java-config/files/0.2.8/30java-finalclasspath new file mode 100644 index 000000000000..a35470483e48 --- /dev/null +++ b/dev-java/java-config/files/0.2.8/30java-finalclasspath @@ -0,0 +1 @@ +CLASSPATH=. diff --git a/dev-java/java-config/files/0.2.8/java-config b/dev-java/java-config/files/0.2.8/java-config new file mode 100644 index 000000000000..92df4d076e08 --- /dev/null +++ b/dev-java/java-config/files/0.2.8/java-config @@ -0,0 +1,397 @@ +#! /bin/sh +# +# Copyright 2001-2002 Gentoo Technologies, Inc. +# Distributed under the terms of the GNU General Public License, v2 or later +# Maintainer: Tools Team <tools@gentoo.org> +# Author: Karl Trygve Kalleberg <karltk@gentoo.org> +# $Header: /var/cvsroot/gentoo-x86/dev-java/java-config/files/0.2.8/java-config,v 1.1 2003/03/22 07:07:17 strider Exp $ + +version="0.2.8" +all_params="$*" + +SYSTEM_ARCH=`echo $ARCH |\ + sed -e s/[i]*.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/` + +if [ -z "$SYSTEM_ARCH" ] ; then + SYSTEM_ARCH=`uname -m |\ + sed -e s/[i]*.86/i386/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/` +fi + +PFORM="i386" + +case $SYSTEM_ARCH in + ppc) PFORM="ppc";; + i386) PFORM="i386";; + sparc64)PFORM="sparc64";; + sparc) PFORM="arm";; + arm) PFORM="arm";; +esac + +if [ $UID != 0 ] && [ -f $HOME/.gentoo/java-env ] ; then + . $HOME/.gentoo/java-env +elif [ -f /etc/env.d/20java ] ; then + oldpath=$PATH + . /etc/env.d/20java + PATH=$oldpath:$PATH +fi + +function eerror() { + echo "!!! $1" 1>&2 +} +svm=`echo $1|egrep "\-\-(set-(system|user)-vm|list-available-vms)"` +if [ -z "$JAVA_HOME" ] && [ -z "$svm" ] && [ "$1" != "--help" ]; then + eerror "No Java installation found" + eerror "Use --set-system-vm to select default system JVM" + eerror "Alternatively, use --set-user-vm to select default user JVM" + exit 1 +fi + +usage() { + cat <<EOF +Usage: java-config [OPTIONS] [LIBRARIES] +Options: + [--javac] + [--java] + [--jar] + [--jdk-home] + [--jre-home] + [--java-version] + [--classpath[=package1,package2,...]] + [--full-classpath=package1,package2,...] + [--exec=filename] + [--list-available-packages] + [--list-available-vms] + [--set-system-vm=<vm-id>] + [--set-user-vm=<vm-id>] + [--set-system-classpath=package1,package2,...] + [--set-user-classpath=package1,package2,...] + [--clean-system-classpath] +EOF + echo "Using ${JAVA_HOME}" + exit $1 +} + +find_exec() { + if [ -f ${JAVA_HOME}/bin/$1 ] ; then + echo ${JAVA_HOME}/bin/$1 + elif [ -f ${JAVA_HOME}/jre/bin/$1 ] ; then + echo ${JAVA_HOME}/jre/bin/$1 + else + eerror "$1 not found" + exit 1 + fi +} + +classpathfor() +{ + local pkgs=`echo $1 | sed "s/,/ /g"` + local total="" + for i in $pkgs ; do + if [ -f /usr/share/${i}/classpath.env ] ; then + total="${total}`cat /usr/share/${i}/classpath.env`" + elif [ -f /usr/share/${i}/package.env ] ; then + pf=/usr/share/${i}/package.env + addcp=`grep "CLASSPATH=" $pf | sed "s/CLASSPATH=//"` + total="${total}:${addcp}" + else + eerror "Package ${i} not found" + exit 1 + fi + done + echo $total | sed "s/::/:/g" +} + +normalise_classpath() { + local iter=`echo $1|sed "s/::/:/g"|sed "s/^://"` + local result + oldifs=${IFS} + IFS=":" + set -f -- ${iter} + while [ "$1" != "" ] ; do + found=`false` + for i in ${result} ; do + if [ "$i" == "$1" ] ; then + found=1 + fi + done + if [ ! $found ] && [ $1 != "." ] ; then + result="${result}:$1" + fi + shift + done + IFS="${oldifs}" + echo ${result} | sed "s/^://" +} + +findpluginpath() { + + # This covers Sun and Blackdown + + rootpath=${JAVA_HOME}/jre/plugin/${PFORM} + + if [ $1 == "ns4" ] || [ $1 == "netscape4" ] ; then + for i in ${rootpath}/{ns4,netscape4}/javaplugin.so ; do + if [ -e $i ] ; then + echo $i + break + fi + done + elif [ $1 == "ns6" ] || [ $1 == "netscape6" ] || [ $1 == "moz" ] || [ $1 == "mozilla" ] ; then + for i in ${rootpath}/{mozilla,ns600,netscape6}/{libjavaplugin_oji,javaplugin_oji}.so ; do + if [ -e $i ] ; then + echo $i + break + fi + done + else + eerror "Browser [$1] unknown" + fi + + # This covers IBM + + rootpath=${JAVA_HOME} + if [ $1 == "ns4" ] || [ $1 == "netscape4" ] ; then + for i in ${rootpath}/{,jre}/bin/javaplugin.so ; do + if [ -e $i ] ; then + echo $i + break + fi + done + elif [ $1 == "ns6" ] || [ $1 == "netscape6" ] || [ $1 == "moz" ] || [ $1 == "mozilla" ] ; then + for i in ${rootpath}/{,jre}/bin/libjavaplugin_oji.so ; do + if [ -e $i ] ; then + echo $i + break + fi + done + fi +} + +function env_update() { + if [ $UID == 0 ]; then + env-update + echo -e "\033[01;37m * \033[01;32m You should login again to have your java-config changes available" + else + echo -e "\033[01;37m * \033[01;32m You should login again to have your java-config changes available" + fi +} + +#WE NEED TO FIX THIS BECAUSE I DONT KNOW +#IF ALWAYS THE VMs GET INSTALLED IN /opt +function vm_shortname_path_opt_only() { + basename $1 | sed -e "s/\/opt\///" +} + +function vm_shortname() { + basename $1 | sed -e "s/20//" #-e "s/-[0-9]\..*//" +} + +function vm_version() { + ( . $1 ; echo "$VERSION ($i)" ) +} + +function vm_exists() { + ( . $i ; export TMP_JAVA_HOME=$JAVA_HOME + if [ -d $TMP_JAVA_HOME ]; then + echo true + unset TMP_JAVA_HOME + else + echo false + unset TMP_JAVA_HOME + fi ) +} + +function vm_envvars() { + local file=$1 + local system="$2" + + ( . $file ; + for i in $ENV_VARS ; do + if [ $i == "ADDPATH" ] && [ -z "$system" ]; then + echo "PATH=\${PATH}:${!i}" + elif [ $i == "ADDPATH" ] && [ "$system" ]; then + echo "PATH=${!i}" + echo "ROOTPATH=${!i}" + elif [ $i == "ADDLDPATH" ] ; then + if [ "$system" ]; then + echo "LDPATH=${!i}" + fi + elif [ $i == "CLASSPATH" ] ; then + echo "${i}=`normalise_classpath ${!i}`" + else + echo "${i}=${!i}" + fi + done + ) +} + +function source_java_classpath() { + echo "if [ -f $HOME/.gentoo/java-env-classpath ] ; then" + echo " . $HOME/.gentoo/java-env-classpath" + echo "fi" +} + +function set_vm() { + local vm=$1 + local cfgpath=$2 + local cfgfile=$3 + local system="" + if [ "$cfgpath" == "/etc/env.d" ] ; then + system="yes" + fi + local found="" + + for i in /etc/env.d/java/20*-* ; do + if [ $vm == `vm_shortname $i` ] ; then + echo "Now using `vm_version $i`" + mkdir -p $cfgpath + echo "# Autogenerated by java-config $version" > ${cfgpath}/${cfgfile} + echo "# Cmd: $0 $all_params" >> ${cfgpath}/${cfgfile} + vm_envvars $i $system >> ${cfgpath}/${cfgfile} + if [ -z $system ] ; then + source_java_classpath >> $HOME/.gentoo/java-env + fi + found="yes" + fi + done + if [ -z "$found" ] ; then + echo "$vm not found" + fi +} + +function calc_full_classpath() { + local foo=`classpathfor $1` + local bar=`normalise_classpath "${foo}"` + echo "${bar}" +} + +if [ $# == 0 ] ; then + echo "Usage: java-config [OPTIONS] [LIBRARIES]" + exit 1 +fi + +while test $# -gt 0; do + + case "$1" in + -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) optarg= ;; + esac + + case $1 in + --debug) + set -x + ;; + --browser-plugin=*) + pluginpath=`findpluginpath $optarg` + if [ -n "$pluginpath" ] ; then + echo `basename $pluginpath` + else + eerror "Plugin not found" + fi + ;; + --full-browser-plugin-path=*) + findpluginpath $optarg + ;; + --classpath) + normalise_classpath ${CLASSPATH} + ;; + --classpath=*) + normalise_classpath `classpathfor $optarg` + ;; + --full-classpath=*) + calc_full_classpath $optarg + ;; + --jdk-home) + echo ${JDK_HOME} + ;; + --jre-home) + echo ${JRE_HOME} + ;; + --javac) + find_exec javac + ;; + --java) + find_exec java + ;; + --jar) + find_exec jar + ;; + --java-version) + `find_exec java` -version + ;; + --exec=*) + find_exec $optarg + ;; + --version) + echo java-config $version + ;; + --list-available-packages) + # Old env var file + for i in /usr/share/*/classpath.env ; do + if [ ! -f $i ] ; then continue ; fi + dn=`dirname $i` + echo "[`basename $dn`] No description ($i)" + done + # New env var file + for i in /usr/share/*/package.env ; do + if [ ! -f $i ] ; then continue ; fi + dn=`dirname $i` + id=`basename $dn` + desc=`grep DESC $i | sed "s/DESCRIPTION=//"` + echo "[${id}] ${desc} ($i)" + done + + ;; + --list-available-vms) + if [ -d /etc/env.d/java ] ; then + for i in `find /etc/env.d/java/ -name "20*-*"` ; do + if [ "`vm_exists $i`" == "true" ]; then + if [ "`vm_shortname_path_opt_only $JAVA_HOME`" == "`vm_shortname $i`" ]; then + echo -e "\033[01;33m [`vm_shortname $i`] `vm_version $i` (*)" + else + echo -e "\033[01;37m [`vm_shortname $i`] `vm_version $i` ()" + fi + fi + done + fi + ;; + --set-system-classpath=*) + if [ "$optarg" == "" ] ; then + eerror "If you want to clean the classpath, please use --clean-system-classpath" + else + echo "CLASSPATH=`calc_full_classpath $optarg`" > \ + /etc/env.d/21java-classpath + fi + ;; + --clean-system-classpath) + if [ -f /etc/env.d/21java-classpath ]; then + rm -f /etc/env.d/21java-classpath + fi + ;; + --set-user-classpath=*) + mkdir -p $HOME/.gentoo + echo "CLASSPATH=\${CLASSPATH}:`calc_full_classpath $optarg`" > \ + $HOME/.gentoo/java-env-classpath + if [ ! -f $HOME/.gentoo/java-env ] ; then + source_java_classpath > $HOME/.gentoo/java-env + fi + ;; + --set-system-vm=*) + set_vm $optarg /etc/env.d 20java + env_update + ;; + --set-user-vm=*) + if [ $UID == 0 ] ; then + eerror "ERROR: root should _always_ use the system-vm" + eerror "NOTE : user-vm for root not set." + else + set_vm $optarg $HOME/.gentoo java-env + env_update + fi + ;; + *) + usage + ;; + esac + shift +done diff --git a/dev-java/java-config/files/0.2.8/java-config.1 b/dev-java/java-config/files/0.2.8/java-config.1 new file mode 100644 index 000000000000..49d0f00f29cb --- /dev/null +++ b/dev-java/java-config/files/0.2.8/java-config.1 @@ -0,0 +1,104 @@ +.TH java-config "1" "March 2002" "java-config 0.2.0" +.SH NAME +java-config \- manual page for java-config, the Java configuration tool for +Gentoo +.SH SYNOPSIS +.B java-config +\fI[options]\fB + +.SH DESCRIPTION +.PP +.I java-config +is used to query/set properties of your system's Java environment. It can be +used to list available VMs, java packages, set system default JVM and set user +default JVM. +.PP +In addition, it is used by Portage as a common interface to querying +properties about the various JVMs. +.SH OPTIONS +.TP +\fB--javac\fI +show full path to currently selected Java compiler. +.TP +\fB--jar\fI +show full path to currently selected +.I jar +command +.TP +\fB--jdk-home\fI +show path to currently selected JDK +.TP +\fB--jre-home\fI +show path to currently selected JRE +.TP +\fB--java-version\fI +query current JVM for version +.TP +\fB--classpath[=package1,package2,...]\fI +calculate classpath for a package. +.TP +\fB--full-classpath[=package1,package2,...]\fI +calculate classpath with absolute paths ready to be assigned to CLASSPATH. +.TP +\fB--exec=filename\fI +figure full path to one of the JDK/JRE utilities, such as +.I keytool +. +.TP +\fB--list-available-packages\fI +list available Java packages. Used for selection by +.I --classpath +and +.I --full-classpath +. +.TP +\fB--list-available-vms\fI +lists available JVMs. Used with +.I --set-system-vm +and +.I --set-user-vm +. +.TP +\fB--set-system-vm=<vm-id>\fI +sets the system-wide default JVM. +.TP +\fB--set-user-vm=<vm-id>\fI +sets the user-specific JVM by putting all necessary env vars into +.I $HOME/.gentoo/java-env +.TP +\fB--set-system-classpath=package1,package2,...\fI +sets the system-wide default CLASSPATH. +.TP +\fB--set-user-classpath=package1,package2,...\fI +sets the user-specific CLASSPATH by putting all necessary env vars into +.I $HOME/.gentoo/java-env-classpath +(sourced from $HOME/.gentoo/java-env). +.TP +\fB--clean-system-classpath\fI +cleans the system-wide default classpath, leaving only vm needed jars +on it. +. + +.SH NOTES +You can get the <vm-id> that is used with +.I --set-system-vm=<vm-id> +and +.I --set-user-vm=<vm-id> +in the output of +.I java-config --list-available-vms +inside the brackets. Ex. [blackdown-jdk-1.4.1] and you can use this to +set your default Java Virtual Machine. + +.SH AUTHORS +Karl Trygve Kalleberg <karltk@gentoo.org> +.br +Adrian Almenar <strider@gentoo.org> + +.SH BUGS +It cannot be used to set default browser plugin yet. + +.SH "SEE ALSO" +env-update(5) +.TP +The \fI/usr/bin/java-config\fR script. +.TP diff --git a/dev-java/java-config/files/digest-java-config-0.2.8 b/dev-java/java-config/files/digest-java-config-0.2.8 new file mode 100644 index 000000000000..e69de29bb2d1 --- /dev/null +++ b/dev-java/java-config/files/digest-java-config-0.2.8 diff --git a/dev-java/java-config/java-config-0.2.8.ebuild b/dev-java/java-config/java-config-0.2.8.ebuild new file mode 100644 index 000000000000..5ec3e305f283 --- /dev/null +++ b/dev-java/java-config/java-config-0.2.8.ebuild @@ -0,0 +1,22 @@ +# Copyright 1999-2003 Gentoo Technologies, Inc. +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/dev-java/java-config/java-config-0.2.8.ebuild,v 1.1 2003/03/22 07:07:17 strider Exp $ + +S=${WORKDIR}/${P} +DESCRIPTION="Gentoo-specific configuration for Java" +SRC_URI="" +HOMEPAGE="http://www.gentoo.org/~karltk/projects/java-config" +DEPEND="" +RDEPEND="" +LICENSE="GPL-2" +SLOT="0" +KEYWORDS="~x86 ~ppc ~sparc ~alpha" +IUSE="" + +src_install () { + dobin ${FILESDIR}/${PV}/java-config + doman ${FILESDIR}/${PV}/java-config.1 + + insinto /etc/env.d + doins ${FILESDIR}/${PV}/30java-finalclasspath +} |