Fixup ant startup script so that java is found in path and falls

back on a default JAVACMD value. It checks JAVACMD, JAVA_HOME,
java found in PATH then a default JAVACMD value. discussed with ian@
This commit is contained in:
kurt 2006-07-19 17:37:01 +00:00
parent 1637e30e73
commit 17f428da4f
2 changed files with 45 additions and 8 deletions

View File

@ -1,9 +1,9 @@
# $OpenBSD: Makefile,v 1.7 2006/07/11 16:32:13 kurt Exp $
# $OpenBSD: Makefile,v 1.8 2006/07/19 17:37:01 kurt Exp $
COMMENT= "java replacement for make"
DISTNAME= apache-ant-1.6.5
PKGNAME= ${DISTNAME}p1
PKGNAME= ${DISTNAME}p2
CATEGORIES= devel
HOMEPAGE= http://ant.apache.org/
@ -38,6 +38,7 @@ TXT= README WHATSNEW LICENSE NOTICE LICENSE.dom LICENSE.sax LICENSE.xerces
do-install:
@cd ${WRKDIST}/bin; \
perl -pi -e 's|_antlibs_|${TRUEPREFIX}/ant/lib|;' \
-e 's|%%DEFAULT_JAVACMD%%|${JAVA_HOME}/bin/java|;' \
ant runant.pl; \
${INSTALL_SCRIPT} ant antRun runant.pl ${PREFIX}/bin
@${INSTALL_DATA_DIR} ${ANTDOCS}

View File

@ -1,12 +1,48 @@
$OpenBSD: patch-bin_ant,v 1.2 2005/08/09 14:37:58 kurt Exp $
--- bin/ant.orig Fri Jul 22 11:09:14 2005
+++ bin/ant Fri Jul 22 11:09:30 2005
@@ -117,7 +117,7 @@ if $cygwin ; then
$OpenBSD: patch-bin_ant,v 1.3 2006/07/19 17:37:01 kurt Exp $
--- bin/ant.orig Thu Jun 2 09:15:34 2005
+++ bin/ant Sat Jul 15 11:32:41 2006
@@ -117,27 +117,31 @@ if $cygwin ; then
fi
# set ANT_LIB location
-ANT_LIB="${ANT_HOME}/lib"
+ANT_LIB="_antlibs_"
+DEFAULT_JAVACMD=%%DEFAULT_JAVACMD%%
-if [ -z "$JAVACMD" ] ; then
- if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
+# Determine JAVACMD if not set
+if [ -z "${JAVACMD}" ]; then
+ if [ -n "${JAVA_HOME}" ]; then
+ # assume Sun style java executable location and command
+ JAVACMD="${JAVA_HOME}/bin/java"
+ if [ ! -x "$JAVACMD" ]; then
+ echo "Error: JAVA_HOME is not defined correctly: ${JAVA_HOME}"
+ echo " Unable to find ${JAVACMD} or it is not executable"
+ exit 1
fi
else
- JAVACMD=`which java 2> /dev/null `
+ # assume Sun style java command and check path
+ JAVACMD=`which java > /dev/null 2>&1 && which java`
if [ -z "$JAVACMD" ] ; then
- JAVACMD=java
+ JAVACMD=${DEFAULT_JAVACMD}
fi
fi
fi
-if [ ! -x "$JAVACMD" ] ; then
- echo "Error: JAVA_HOME is not defined correctly."
- echo " We cannot execute $JAVACMD"
+if [ ! -x "$JAVACMD" ]; then
+ echo "Error: JAVACMD is not defined correctly: ${JAVACMD}"
+ echo " Unable to find ${JAVACMD} or it is not executable"
exit 1
fi
if [ -z "$JAVACMD" ] ; then
if [ -n "$JAVA_HOME" ] ; then