[meta-java,2/2] openjdk-common: Define JAVA_HOME by default

Submitted by Fang Jia on Nov. 29, 2018, 10:48 a.m. | Patch ID: 156733

Details

Message ID 1543488504-15595-2-git-send-email-fang.jia@windriver.com
State Under Review
Delegated to: Richard Leitner
Headers show

Commit Message

Fang Jia Nov. 29, 2018, 10:48 a.m.
Use postinst script to set the JAVA_HOME by default.

Signed-off-by: Fang Jia <fang.jia@windriver.com>
---
 recipes-core/openjdk/openjdk-common.inc | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

Patch hide | download patch | download mbox

diff --git a/recipes-core/openjdk/openjdk-common.inc b/recipes-core/openjdk/openjdk-common.inc
index 01a0a2a..aaf81f6 100644
--- a/recipes-core/openjdk/openjdk-common.inc
+++ b/recipes-core/openjdk/openjdk-common.inc
@@ -5,3 +5,17 @@  JDK_ARCH = "${@openjdk_build_helper_get_jdk_arch(d)}"
 
 # Provides the target architecture to the configure script.
 export LLVM_CONFIGURE_ARCH="${@openjdk_build_helper_get_llvm_configure_arch(d)}"
+
+pkg_postinst_${PN}() {
+	cat >> $D${sysconfdir}/profile << EOT
+JAVA_HOME=""
+for dir in ${libdir}/jvm/*; do
+        if [ -x "\${dir}/bin/java" ]; then
+                [ -z "\${JAVA_HOME}" ] && JAVA_HOME="\${dir}"
+        fi
+done
+if [ -n "\${JAVA_HOME}" ]; then
+        export JAVA_HOME=\${JAVA_HOME}
+fi
+EOT
+}