diff options
author | sobomax <sobomax@FreeBSD.org> | 2000-06-12 17:42:51 +0800 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2000-06-12 17:42:51 +0800 |
commit | 6325c04f4463524506f533492fbaf21fff46c2a6 (patch) | |
tree | 9b94d5888c2961755fd55a738cac1daff72730fd /java | |
parent | 786a498cc2a7eba95f1ed79825aa7f25cd322f1a (diff) | |
download | freebsd-ports-gnome-6325c04f4463524506f533492fbaf21fff46c2a6.tar.gz freebsd-ports-gnome-6325c04f4463524506f533492fbaf21fff46c2a6.tar.zst freebsd-ports-gnome-6325c04f4463524506f533492fbaf21fff46c2a6.zip |
Initial import of javavmwrapper - a simple shell script which would allow
Java-based ports to use any of the Java Virtual Machines installed on the
system.
Diffstat (limited to 'java')
-rw-r--r-- | java/javavmwrapper/Makefile | 35 | ||||
-rw-r--r-- | java/javavmwrapper/pkg-comment | 1 | ||||
-rw-r--r-- | java/javavmwrapper/pkg-descr | 2 | ||||
-rw-r--r-- | java/javavmwrapper/pkg-plist | 3 | ||||
-rw-r--r-- | java/javavmwrapper/src/javavmwrapper.sh | 120 |
5 files changed, 161 insertions, 0 deletions
diff --git a/java/javavmwrapper/Makefile b/java/javavmwrapper/Makefile new file mode 100644 index 000000000000..025458e4ddc5 --- /dev/null +++ b/java/javavmwrapper/Makefile @@ -0,0 +1,35 @@ +# New ports collection makefile for: javavmwrapper +# Date created: 10 June 2000 +# Whom: Maxim Sobolev <sobomax@FreeBSD.org> +# +# $FreeBSD$ +# +# This port is self contained in the src directory. +# + +PORTNAME= javavmwrapper +PORTVERSION= 1.0 +CATEGORIES= java +MASTER_SITES= # none +DISTFILES= # none + +MAINTAINER= sobomax@FreeBSD.org + +NO_BUILD= yes +NO_WRKSUBDIR= yes + +SRC= ${.CURDIR}/src + +do-fetch: + @${DO_NADA} + +do-configure: + ${SED} 's|%%PREFIX%%|${PREFIX}|' \ + < ${SRC}/javavmwrapper.sh > ${WRKDIR}/javavmwrapper.sh + +do-install: + ${INSTALL_SCRIPT} ${WRKDIR}/javavmwrapper.sh ${PREFIX}/bin/javavm + ${LN} -sf ${PREFIX}/bin/javavm ${PREFIX}/bin/registervm + ${LN} -sf ${PREFIX}/bin/javavm ${PREFIX}/bin/unregistervm + +.include <bsd.port.mk> diff --git a/java/javavmwrapper/pkg-comment b/java/javavmwrapper/pkg-comment new file mode 100644 index 000000000000..6713fedf6164 --- /dev/null +++ b/java/javavmwrapper/pkg-comment @@ -0,0 +1 @@ +Wrapper script for various Java Virtual Machines diff --git a/java/javavmwrapper/pkg-descr b/java/javavmwrapper/pkg-descr new file mode 100644 index 000000000000..934875c757c7 --- /dev/null +++ b/java/javavmwrapper/pkg-descr @@ -0,0 +1,2 @@ +Wrapper script to allow several different Java Virtual Machines being installef +on the same system. diff --git a/java/javavmwrapper/pkg-plist b/java/javavmwrapper/pkg-plist new file mode 100644 index 000000000000..00e0e070e808 --- /dev/null +++ b/java/javavmwrapper/pkg-plist @@ -0,0 +1,3 @@ +bin/javavm +bin/registervm +bin/unregistervm diff --git a/java/javavmwrapper/src/javavmwrapper.sh b/java/javavmwrapper/src/javavmwrapper.sh new file mode 100644 index 000000000000..5507efe3cbc1 --- /dev/null +++ b/java/javavmwrapper/src/javavmwrapper.sh @@ -0,0 +1,120 @@ +#!/bin/sh +# +# javawrapper.sh +# +# Allows to install several Java Virtual Machines +# on the same system and use config file/or environment +# variable to select wichever to use +# +# ---------------------------------------------------------------------------- +# "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp): +# Maxim Sobolev <sobomax@FreeBSD.org> wrote this file. As long as you retain +# this notice you can do whatever you want with this stuff. If we meet some +# day, and you think this stuff is worth it, you can buy me a beer in return. +# +# Maxim Sobolev +# ---------------------------------------------------------------------------- +# +# $FreeBSD$ +# +# MAINTAINER= sobomax@FreeBSD.org + +ARGS="${*}" +PREFIX="%%PREFIX%%" +CONF="${PREFIX}/etc/javavms" +IAM=`basename "${0}"` + +tryrunVM () { + if [ -x "${1}" ]; then + exec "${1}" ${2} + fi + + /bin/echo "${IAM}: warning: couldn't start specified JavaVM - \"${1}\"" >&2 +} + +registerVM () { + if [ x"${1}" = x"" ]; then + /bin/echo "Usage: ${IAM} path" + exit + fi + + if [ ! -e "${CONF}" ]; then + /usr/bin/touch "${CONF}" + fi + + if [ ! -x "${1}" ]; then + /bin/echo "${IAM}: warning: the specified JavaVM \"${1}\" either not exists of not executable" >&2 + fi + + /bin/ed "${CONF}" >/dev/null <<EOF +0a +${1} +. +w +q +EOF + exit 0 +} + +unregisterVM () { + if [ x"${1}" = x"" ]; then + /bin/echo "Usage: ${IAM} path" + exit + fi + + if [ ! -e "${CONF}" ]; then + /bin/echo "${IAM}: error: can't find ${CONF} config file!" >&2 + exit 1 + fi + + if [ x"`grep ${1} ${CONF}`" = x"" ]; then + /bin/echo "${IAM}: error: \"${1}\" JavaVM is not currently registered" + exit 1 + fi + + /bin/ed "${CONF}" >/dev/null <<EOF +g|${1}|d +w +q +EOF + + # Remove config file if its size reached 0 + if [ ! -s "${CONF}" ]; then + /bin/rm "${CONF}" + fi + + exit 0 +} + +case "${IAM}" in + registervm ) + registerVM "${1}" + ;; + unregistervm ) + unregisterVM "${1}" + ;; +esac + +# Main () + +# First check if JAVAVM environment variable is set +if [ x"${JAVAVM}" != x"" ]; then + tryrunVM "${JAVAVM}" "${ARGS}" +fi + +# Then try to make sure that ${CONF} exists +if [ ! -e "${CONF}" ]; then + echo "${IAM}: error: can't find ${CONF} config file" >&2 + exit 1 +fi + +# Allow coment in the ${CONF} +VMS=`/usr/bin/sed 's|#.*||' < "${CONF}" | uniq` + +# Finally try to run one of the ${VMS} +for JAVAVM in ${VMS}; do + tryrunVM "${JAVAVM}" "${ARGS}"; +done + +echo "${IAM}: error: no suitable JavaVMs found" >&2 +exit 1
\ No newline at end of file |