pkgsrc-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: lang/sun-jdk7 and lang/oracle-jdk8 not using built-in



On 2/15/16 2:16 AM, Jonathan Perkin wrote:
> In that case we should add some logic to handle this correctly.  If
> on Darwin we could use /usr/libexec/java_home to set PKG_JVM and the
> resulting variables correctly.
>
> Do you want to have a go at adding this?

Sure, attached.

The patch is against pkgsrc-2015Q4 and makes the builtin.mk of
lang/sun-jre7 and lang/oracle-jre8 verify that "/Library/Internet
Plug-Ins/JavaAppletPlugin.plugin/Contents/Home" contains the expected
JRE version before using it.

Since I didn't "use /usr/libexec/java_home to set PKG_JVM and the
resulting variables correctly" as you suggested, I suspect my patch is
not at all what you had in mind.  I'm sorry, I didn't understand what
you were suggesting.

Regards,

Lewis
diff --git a/lang/oracle-jre8/builtin.mk b/lang/oracle-jre8/builtin.mk
index 3b28a65..978805f 100644
--- a/lang/oracle-jre8/builtin.mk
+++ b/lang/oracle-jre8/builtin.mk
@@ -16,14 +16,22 @@ BUILTIN_FIND_FILES.JAVAVM8=	\
 ### unfortunately, the path contains a space, and the BUILTIN_FIND_FILES
 ### "subroutine" can't handle paths containing whitespace (because it
 ### iterates over the paths in a for-loop).  So, we perform the check by
-### hand.
+### hand.  Lastly, since the JRE version is not encoded in the path, we
+### can't tell which version of the JRE is actually installed there.
+### So, we invoke the virtual machine to determine the JRE version and
+### only consider the JRE suitable if the version is 1.8.
 ###
 .if ${OPSYS} == "Darwin" && \
     !empty(JAVAVM8:M__nonexistent__)
 _JRE_HOME=	\
 	/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
 .  if exists(${_JRE_HOME})
+_JRE_MAJOR_MINOR_VERSION!= ${_JRE_HOME:Q}/bin/java -version 2>&1 | \
+	${AWK} -F \" '{print $$2; exit}' | \
+	${AWK} -F . '{print $$1 "." $$2}'
+.    if ${_JRE_MAJOR_MINOR_VERSION} == "1.8"
 JAVAVM8=	${_JRE_HOME}
+.    endif
 .  endif
 .endif
 
diff --git a/lang/sun-jre7/builtin.mk b/lang/sun-jre7/builtin.mk
index 82fd44d..5e2db6c 100644
--- a/lang/sun-jre7/builtin.mk
+++ b/lang/sun-jre7/builtin.mk
@@ -16,14 +16,22 @@ BUILTIN_FIND_FILES.JAVAVM7=	\
 ### unfortunately, the path contains a space, and the BUILTIN_FIND_FILES
 ### "subroutine" can't handle paths containing whitespace (because it
 ### iterates over the paths in a for-loop).  So, we perform the check by
-### hand.
+### hand.  Lastly, since the JRE version is not encoded in the path, we
+### can't tell which version of the JRE is actually installed there.
+### So, we invoke the virtual machine to determine the JRE version and
+### only consider the JRE suitable if the version is 1.7.
 ###
 .if ${OPSYS} == "Darwin" && \
     !empty(JAVAVM7:M__nonexistent__)
 _JRE_HOME=	\
 	/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
 .  if exists(${_JRE_HOME})
+_JRE_MAJOR_MINOR_VERSION!= ${_JRE_HOME:Q}/bin/java -version 2>&1 | \
+	${AWK} -F \" '{print $$2; exit}' | \
+	${AWK} -F . '{print $$1 "." $$2}'
+.    if ${_JRE_MAJOR_MINOR_VERSION} == "1.7"
 JAVAVM7=	${_JRE_HOME}
+.    endif
 .  endif
 .endif
 


Home | Main Index | Thread Index | Old Index