aboutsummaryrefslogtreecommitdiffstats
path: root/java
diff options
context:
space:
mode:
authorglewis <glewis@FreeBSD.org>2006-06-04 01:32:24 +0800
committerglewis <glewis@FreeBSD.org>2006-06-04 01:32:24 +0800
commit1ac4579411508ffa6ab4bd0d9e702147c75385f2 (patch)
tree9916b3b9403457c966451ecfbd67d85b2eeac878 /java
parenta3405f99aa0b8c8ee565081fb3633f4b75ec83ad (diff)
downloadfreebsd-ports-gnome-1ac4579411508ffa6ab4bd0d9e702147c75385f2.tar.gz
freebsd-ports-gnome-1ac4579411508ffa6ab4bd0d9e702147c75385f2.tar.zst
freebsd-ports-gnome-1ac4579411508ffa6ab4bd0d9e702147c75385f2.zip
. Allow the setting up of command line options to be passed to the
invoked Java VM. Reviewed by: hq
Diffstat (limited to 'java')
-rw-r--r--java/javavmwrapper/Makefile11
-rw-r--r--java/javavmwrapper/files/javavm_opts.conf.dist52
-rw-r--r--java/javavmwrapper/files/pkg-install.in13
-rw-r--r--java/javavmwrapper/pkg-deinstall12
-rw-r--r--java/javavmwrapper/pkg-plist1
-rw-r--r--java/javavmwrapper/src/javavm.111
-rw-r--r--java/javavmwrapper/src/javavm_opts.conf.597
-rw-r--r--java/javavmwrapper/src/javavmwrapper.sh52
8 files changed, 236 insertions, 13 deletions
diff --git a/java/javavmwrapper/Makefile b/java/javavmwrapper/Makefile
index 65ada80f98fa..47507035178a 100644
--- a/java/javavmwrapper/Makefile
+++ b/java/javavmwrapper/Makefile
@@ -8,8 +8,7 @@
#
PORTNAME= javavmwrapper
-PORTVERSION= 2.0
-PORTREVISION= 7
+PORTVERSION= 2.1
CATEGORIES= java
MASTER_SITES= # none
DISTFILES= # none
@@ -25,7 +24,7 @@ NO_WRKSUBDIR= yes
PKGINSTALL= ${WRKDIR}/pkg-install
MAN1= checkvms.1 javavm.1 registervm.1 unregistervm.1
-MAN5= javavms.5
+MAN5= javavm_opts.conf.5 javavms.5
SRC= ${.CURDIR}/src
SCRIPTS= classpath javavmwrapper
@@ -62,7 +61,11 @@ do-install:
.endfor
${INSTALL_MAN} ${WRKDIR}/registervm.1 \
${MAN1PREFIX}/man/man1/unregistervm.1
- ${INSTALL_MAN} ${WRKDIR}/${MAN5} ${MAN5PREFIX}/man/man5
+.for _man in ${MAN5}
+ ${INSTALL_MAN} ${WRKDIR}/${_man} ${MAN5PREFIX}/man/man5
+.endfor
+ ${INSTALL_DATA} ${FILESDIR}/javavm_opts.conf.dist \
+ ${PREFIX}/etc/javavm_opts.conf.dist
post-install:
${SETENV} PKG_PREFIX=${PREFIX} ${SH} ${PKGINSTALL} ${PKGNAME} \
diff --git a/java/javavmwrapper/files/javavm_opts.conf.dist b/java/javavmwrapper/files/javavm_opts.conf.dist
new file mode 100644
index 000000000000..37d43103cd17
--- /dev/null
+++ b/java/javavmwrapper/files/javavm_opts.conf.dist
@@ -0,0 +1,52 @@
+#
+# $FreeBSD$
+#
+# javavm_opts.conf.dist
+#
+# This file is sourced by javavm to determine the options to pass to the
+# Java command that its invoking.
+#
+# There are four different types of environment variables that are used
+# to determine the options for a particular command.
+#
+# 1. JAVAVM_OPTS
+#
+# The contents of this variable are passed as options to all java
+# commands invoked by javavm.
+#
+# 2. JAVAVM_OPTS_JAVA_HOME_DIR
+#
+# The contents of this variable are passed as options to all java
+# commands invoked by javavm within the JAVA_HOME_DIR directory specified.
+# The JAVA_HOME_DIR specified here is the directory portion of $JAVA_HOME
+# with special characters replaced by an underscore. For example, the
+# standard installation of the jdk15 port puts it in /usr/local/jdk1.5.0,
+# so to affect all of its programmes you would set JAVAVM_OPTS_jdk1_5_0.
+#
+# 3. JAVAVM_OPTS_JAVAVM_PROG
+#
+# The contents of this variable are passed as options to all invocations
+# of the specified java programme. For example, if you always wish to
+# have -deprecation passed to javac, then you would set JAVAVM_OPTS_javac.
+#
+# 4. JAVAVM_OPTS_JAVA_HOME_JAVAVM_PROG
+#
+# The contents of this variable are passed as options to the invocation
+# of the specified java programme within the specified JAVA_HOME
+# directory. This allows the options to only affect a single programme.
+# For example, to pass -Xlint to the javac in /usr/local/jdk1.5.0/bin
+# you would set JAVAVM_OPTS_jdk1_5_0_javac.
+#
+# These variables "stack", in that if multiple variables are
+# defined which apply to a particular command then all the variables
+# contents will be passed to the command as options. For example,
+# if you set JAVAVM_OPTS_jdk1_5_0 and JAVAVM_OPTS_javac, then the
+# contents of both variables will be passed to an invocation of
+# /usr/local/jdk1.5.0/bin/javac.
+#
+# Note that the order in which variables stack is an implementation
+# detail and should not be relied upon.
+#
+
+# This is required on SMP machines for Diablo JDK 1.5.0_06 build 0
+JAVAVM_OPTS_diablo_jdk1_5_0=-XX:+UseMembar
diff --git a/java/javavmwrapper/files/pkg-install.in b/java/javavmwrapper/files/pkg-install.in
index a2f067d68f7a..92a7d10b9e97 100644
--- a/java/javavmwrapper/files/pkg-install.in
+++ b/java/javavmwrapper/files/pkg-install.in
@@ -1,6 +1,6 @@
#!/bin/sh
#
-# $FreeBSD: /tmp/pcvs/ports/java/javavmwrapper/files/pkg-install.in,v 1.2 2005-04-11 21:21:16 glewis Exp $
+# $FreeBSD: /tmp/pcvs/ports/java/javavmwrapper/files/pkg-install.in,v 1.3 2006-06-03 17:32:24 glewis Exp $
LOCALBASE=%%LOCALBASE%%
@@ -9,6 +9,17 @@ if [ "x${2}" != "xPOST-INSTALL" ]; then
exit 0
fi
+# The option configuration file
+OPTION_CONF="${PKG_PREFIX}/etc/javavm_opts.conf"
+
+# Install default javavm options configuration
+if [ ! -e "${OPTION_CONF}" ]; then
+ cp "${OPTION_CONF}.dist" "${OPTION_CONF}"
+else
+ echo "${OPTION_CONF} already exists - not installing."
+ echo "You may need to hand merge changes."
+fi
+
# Ensure all JDKs and JREs are installed
for jvm in "${LOCALBASE}"/*jdk* "${LOCALBASE}"/*jre*; do
if [ -x "${jvm}/bin/java" ]; then
diff --git a/java/javavmwrapper/pkg-deinstall b/java/javavmwrapper/pkg-deinstall
index 3075b66c5428..dfac4ee292df 100644
--- a/java/javavmwrapper/pkg-deinstall
+++ b/java/javavmwrapper/pkg-deinstall
@@ -9,6 +9,18 @@ if [ "x${2}" != "xDEINSTALL" ]; then
exit 0
fi
+# The option configuration file
+OPTION_CONF="${PKG_PREFIX}/etc/javavm_opts.conf"
+
+# Remove the option configuration file if its identical to the
+# distributed version.
+if [ -f "${OPTION_CONF}" -a -f "${OPTION_CONF}.dist" ]; then
+ if [ `sed -e '/^#/d' -e '/^\s*$/d' "${OPTION_CONF}" | sort | md5` = \
+ `sed -e '/^#/d' -e '/^\s*$/d' "${OPTION_CONF}.dist" | sort | md5` ]; then
+ rm -f "${OPTION_CONF}"
+ fi
+fi
+
# The configuration file
CONF="${PKG_PREFIX}/etc/javavms"
diff --git a/java/javavmwrapper/pkg-plist b/java/javavmwrapper/pkg-plist
index 8ec477d3c9db..9ff1c2eb4999 100644
--- a/java/javavmwrapper/pkg-plist
+++ b/java/javavmwrapper/pkg-plist
@@ -3,3 +3,4 @@ bin/javavm
bin/registervm
bin/unregistervm
bin/checkvms
+etc/javavm_opts.conf.dist
diff --git a/java/javavmwrapper/src/javavm.1 b/java/javavmwrapper/src/javavm.1
index 93efe71eef91..801ba096b3be 100644
--- a/java/javavmwrapper/src/javavm.1
+++ b/java/javavmwrapper/src/javavm.1
@@ -1,6 +1,6 @@
.\"
.\" Copyright (C) 2005 Greg Lewis. All rights reserved.
-.\"
+.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
@@ -9,7 +9,7 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\"
+.\"
.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -124,6 +124,12 @@ Currently allowed versions are
.Ql 1.5
and
.Ql 1.5+ .
+.It Ev JAVAVM_OPTS
+The contents of this environment variable will be passed to the invoked
+Java VM as options.
+For more information on environment variables which can be used to set
+options see
+.Pa %%PREFIX%%/etc/javavm_opts.conf.dist .
.El
.Sh FILES
.Bl -tag -width indent
@@ -157,6 +163,7 @@ Execute MyApp with either a Java VM that is either version 1.2 or version 1.4.
.Xr make 1 ,
.Xr registervm 1 ,
.Xr unregistervm 1 ,
+.Xr javavm_opts.conf 5 ,
.Xr javavms 5
.Sh BUGS
The internal selection procedure of
diff --git a/java/javavmwrapper/src/javavm_opts.conf.5 b/java/javavmwrapper/src/javavm_opts.conf.5
new file mode 100644
index 000000000000..5c1cd05d4058
--- /dev/null
+++ b/java/javavmwrapper/src/javavm_opts.conf.5
@@ -0,0 +1,97 @@
+.\"
+.\" Copyright (C) 2006 Greg Lewis. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.\" $FreeBSD$
+.\"
+.Dd May 28, 2006
+.Os
+.Dt JAVAVM_OPTS.CONF 5
+.Sh NAME
+.Nm javavm_opts.conf
+.Nd the Java VM wrapper options configuration file.
+.Sh DESCRIPTION
+The file
+.Nm
+contains variables which set options that should be passed to the
+Java VM that is invoked by the Java VM wrapper.
+.Pp
+Which Java VM a variable provides options for is determined by the variable
+name. The Java VM wrapper currently recognises the following patterns for
+variable names:
+.Bl -tag -width indent
+.It Ev JAVAVM_OPTS
+The options specified by this variable are passed to all Java VM
+invocations. In practise, this variable should be reserved for use
+on the command line and not set in
+.Nm .
+.It Ev JAVAVM_OPTS_JAVA_HOME_DIR
+The contents of this variable are passed as options to all java
+commands invoked by javavm within the
+.Pa JAVA_HOME_DIR
+directory specified.
+The
+.Pa JAVA_HOME_DIR
+specified here is the directory portion of
+.Ev JAVA_HOME
+with special characters replaced by an underscore.
+.It Ev JAVAVM_OPTS_JAVA_PROG
+The contents of this variable are passed as options to all invocations
+of the specified java programme.
+.It Ev JAVAVM_OPTS_JAVA_HOME_DIR_JAVA_PROG
+The contents of this variable are passed as options to the invocation
+of the specified java programme within the specified JAVA_HOME
+directory.
+This allows the options to only affect a single programme.
+.El
+.Sh FILES
+.Bl -tag -width indent
+.It Pa %%PREFIX%%/etc/javavm_opts.conf
+The location of the Java VM wrapper options configuration file.
+.It Pa %%PREFIX%%/etc/javavm_opts.conf.dist
+The location of the example Java VM wrapper options configuration file
+distributed with the Java VM wrapper.
+.El
+.Sh EXAMPLES
+.Bl -tag -width indent
+.It Ev JAVAVM_OPTS_diablo_jdk1_5_0=-XX:+UseMembar
+Run the Java VMs installed by the Diablo JDK in
+.Pa %%PREFIX%%/diablo-jdk1.5.0
+with the option
+.Dq -XX:+UseMembar .
+.It Ev JAVAVM_OPTS_javac=-deprecation
+Run the
+.Pa javac
+programme with the option
+.Dq -deprecation .
+.It Ev JAVAVM_OPTS_diablo_jdk1_5_0_javac=-Xlint
+Run the javac installed by the Diablo JDK with the option
+.Dq -Xlint .
+.El
+.Pp
+Due to stacking, if the above three variables were set, then the javac
+installed by the Diablo JDK would run with the options
+.Dq -XX:+UseMembar -deprecation -Xlint
+(although not necessarily in that order).
+.Sh SEE ALSO
+.Xr javavm 1
diff --git a/java/javavmwrapper/src/javavmwrapper.sh b/java/javavmwrapper/src/javavmwrapper.sh
index f459c34e2c88..b1c555b3f431 100644
--- a/java/javavmwrapper/src/javavmwrapper.sh
+++ b/java/javavmwrapper/src/javavmwrapper.sh
@@ -34,6 +34,7 @@ export PATH=/bin:/sbin:/usr/bin:/usr/sbin
_JAVAVM_PREFIX="%%PREFIX%%"
_JAVAVM_CONF="${_JAVAVM_PREFIX}/etc/javavms"
+_JAVAVM_OPTS_CONF="${_JAVAVM_PREFIX}/etc/javavm_opts.conf"
_JAVAVM_PROG=`basename "${0}"`
_JAVAVM_MAKE=/usr/bin/make
@@ -53,6 +54,33 @@ tryJavaCommand () {
}
#
+# Set java command options, if applicable
+# 1 - Name of the java programme to be executed.
+# 2 - Base directory of JAVA_HOME for the java programme to be executed.
+#
+setJavaOptions () {
+ local OPTS_PROG=`echo ${1} | sed -e s/\\\\./_/g -e s/-/_/g`
+ local OPTS_JAVA_HOME=`echo ${2} | sed -e s/\\\\./_/g -e s/-/_/g`
+ local JAVA_HOME_PROG_OPTS="`eval echo \$\{JAVAVM_OPTS_${OPTS_JAVA_HOME}_${OPTS_PROG}\} 2>/dev/null`"
+ local JAVA_HOME_OPTS="`eval echo \$\{JAVAVM_OPTS_${OPTS_JAVA_HOME}\} 2>/dev/null`"
+ local PROG_OPTS="`eval echo \$\{JAVAVM_OPTS_${OPTS_PROG}\} 2>/dev/null`"
+
+ # Possible environment variables are stackable
+ if [ ! -z "${JAVA_HOME_PROG_OPTS}" ]; then
+ _JAVAVM_OPTS="${_JAVAVM_OPTS} ${JAVA_HOME_PROG_OPTS}"
+ fi
+ if [ ! -z "${JAVA_HOME_OPTS}" ]; then
+ _JAVAVM_OPTS="${_JAVAVM_OPTS} ${JAVA_HOME_OPTS}"
+ fi
+ if [ ! -z "${PROG_OPTS}" ]; then
+ _JAVAVM_OPTS="${_JAVAVM_OPTS} ${PROG_OPTS}"
+ fi
+ if [ ! -z "${JAVAVM_OPTS}" ]; then
+ _JAVAVM_OPTS="${_JAVAVM_OPTS} ${JAVAVM_OPTS}"
+ fi
+}
+
+#
# Create symbolic links for all of a Java VMs executables.
#
createJavaLinks () {
@@ -412,15 +440,23 @@ if [ "${_JAVAVM_PROG}" = "javavm" ]; then
_JAVAVM_PROG=java
fi
+# Initialise options
+if [ -r "${_JAVAVM_OPTS_CONF}" ]; then
+ . "${_JAVAVM_OPTS_CONF}"
+fi
+_JAVAVM_OPTS=
+
# Ignore JAVA_HOME if it's set to %%PREFIX%%
if [ "`realpath "${JAVA_HOME}"`" != "`realpath "${_JAVAVM_PREFIX}"`" ]; then
# Otherwise use JAVA_HOME if it's set
if [ ! -z "${JAVA_HOME}" -a -x "${JAVA_HOME}/bin/${_JAVAVM_PROG}" ]; then
+ setJavaOptions "${_JAVAVM_PROG}" "`basename ${JAVA_HOME}`"
export JAVA_HOME
- tryJavaCommand "${JAVA_HOME}/bin/${_JAVAVM_PROG}" "${@}"
+ tryJavaCommand "${JAVA_HOME}/bin/${_JAVAVM_PROG}" ${_JAVAVM_OPTS} "${@}"
elif [ ! -z "${JAVA_HOME}" -a -x "${JAVA_HOME}/jre/bin/${_JAVAVM_PROG}" ]; then
+ setJavaOptions "${_JAVAVM_PROG}" "`basename ${JAVA_HOME}`"
export JAVA_HOME
- tryJavaCommand "${JAVA_HOME}/jre/bin/${_JAVAVM_PROG}" "${@}"
+ tryJavaCommand "${JAVA_HOME}/jre/bin/${_JAVAVM_PROG}" ${_JAVAVM_OPTS} "${@}"
fi
fi
@@ -442,12 +478,14 @@ if [ ! -z "${_JAVAVM_BSD_PORT_MK}" ]; then
JAVA_HOME=`"${_JAVAVM_MAKE}" -f "${_JAVAVM_BSD_PORT_MK}" -V JAVA_HOME USE_JAVA=yes 2>/dev/null`
if [ ! -z "${JAVA_HOME}" -a \
-x "${JAVA_HOME}/bin/${_JAVAVM_PROG}" ]; then
+ setJavaOptions "${_JAVAVM_PROG}" "`basename ${JAVA_HOME}`"
export JAVA_HOME
- tryJavaCommand "${JAVA_HOME}/bin/${_JAVAVM_PROG}" "${@}"
+ tryJavaCommand "${JAVA_HOME}/bin/${_JAVAVM_PROG}" ${_JAVAVM_OPTS} "${@}"
elif [ ! -z "${JAVA_HOME}" -a \
-x "${JAVA_HOME}/jre/bin/${_JAVAVM_PROG}" ]; then
+ setJavaOptions "${_JAVAVM_PROG}" "`basename ${JAVA_HOME}`"
export JAVA_HOME
- tryJavaCommand "${JAVA_HOME}/jre/bin/${_JAVAVM_PROG}" "${@}"
+ tryJavaCommand "${JAVA_HOME}/jre/bin/${_JAVAVM_PROG}" ${_JAVAVM_OPTS} "${@}"
fi
fi
@@ -561,12 +599,14 @@ for _JAVAVM_JAVAVM in ${_JAVAVM_VMS}; do
# Check if the command exists and try to run it.
if [ ! -z "${JAVA_HOME}" -a \
-x "${JAVA_HOME}/bin/${_JAVAVM_PROG}" ]; then
+ setJavaOptions "${_JAVAVM_PROG}" "`basename ${JAVA_HOME}`"
export JAVA_HOME
- tryJavaCommand "${JAVA_HOME}/bin/${_JAVAVM_PROG}" "${@}"
+ tryJavaCommand "${JAVA_HOME}/bin/${_JAVAVM_PROG}" ${_JAVAVM_OPTS} "${@}"
elif [ ! -z "${JAVA_HOME}" -a \
-x "${JAVA_HOME}/jre/bin/${_JAVAVM_PROG}" ]; then
+ setJavaOptions "${_JAVAVM_PROG}" "`basename ${JAVA_HOME}`"
export JAVA_HOME
- tryJavaCommand "${JAVA_HOME}/jre/bin/${_JAVAVM_PROG}" "${@}"
+ tryJavaCommand "${JAVA_HOME}/jre/bin/${_JAVAVM_PROG}" ${_JAVAVM_OPTS} "${@}"
fi
done