Skip to contentSkip to conversation

Revert "base-files: Define JAVA_HOME by default"

PATCH In review Fang Jia 3 participants 5 messages Nov 29, 2018 – Jan 3, 2019

lore
Share & tools
lore

Fang Jia

author
#0 lore raw

PATCH 1/2 Revert "base-files: Define JAVA_HOME by default"

This reverts commit ada652564f09756a81f54495cbc2091125239625.

When enable multilib on 64bit system, probably both base-file and lib32-base-files are installed.
Since both packages want to modify the file "profile", then there will be an error like:
"
Error: Transaction check error:
file /etc/profile conflicts between attempted installs of lib32-base-files-3.0.14-r148.gpb_virt and base-files-3.0.14-r148.gpb_virt
"
The task should be added into openjdk pacakge as postinst script.

---
 recipes-core/base-files/base-files_3.0.14.bbappend | 13 -------------
 1 file changed, 13 deletions(-)
 delete mode 100644 recipes-core/base-files/base-files_3.0.14.bbappend
recipes-core/base-files/base-files_3.0.14.bbappend deleted +0 -13
deleted file mode 100644
index 4651185..0000000
@@ -1,13 +0,0 @@
-do_install_append() {
-	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
-}
Signature · 1 line
2.7.4
author
#1 lore raw

PATCH 2/2 openjdk-common: Define JAVA_HOME by default

Use postinst script to set the JAVA_HOME by default.

---
 recipes-core/openjdk/openjdk-common.inc | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
recipes-core/openjdk/openjdk-common.inc +14 -0
index 01a0a2a..aaf81f6 100644
@@ -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
+}
Signature · 1 line
2.7.4
#2 lore raw

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

Hi,
thanks for the patch!

Just one question: what happens when the package gets removed? Is there any mechanism to remove the JAVA_HOME definition again?

If not: may you please implement one? Thanks!

regards;Richard.L

Quoted 30 lines · Fang Jia

Use postinst script to set the JAVA_HOME by default.

---
 recipes-core/openjdk/openjdk-common.inc | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
recipes-core/openjdk/openjdk-common.inc +14 -0
index 01a0a2a..aaf81f6 100644
@@ -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
+}
#3 lore raw

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

In reply to Fang Jia
Quoted 21 lines · Fang Jia

Use postinst script to set the JAVA_HOME by default.

---
 recipes-core/openjdk/openjdk-common.inc | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
recipes- renamed from recipes-core/openjdk/openjdk-common.inc +0 -0

core/openjdk/openjdk-common.inc
index 01a0a2a..aaf81f6 100644

recipes-core/openjdk/openjdk-common.inc +0 -0
@@ -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_ar

ch(d)}"

recipes-core/openjdk/openjdk-common.inc +4 -0
+
+pkg_postinst_${PN}() {
+	cat >> $D${sysconfdir}/profile << EOT
+JAVA_HOME=""

recipes-core/openjdk/openjdk-common.inc JDK_ARCH = "${@openjdk_build_helper_get_jdk_arch(d)}" · line 21

Quoted 10 lines
recipes-core/openjdk/openjdk-common.inc +10 -0
+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
+}

I'd say this should be done via adding a file to ${sysconfdir}/profile.d/ instead. Have a look at e.g. the DistCC recipe
poky.git/meta/recipes-devtools/devel-config/distcc-config.bb

Cheers,
Andre'

#4 lore raw

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

In reply to Fang Jia

recipes-core/openjdk/openjdk-common.inc

Quoted 12 lines · Fang Jia

Use postinst script to set the JAVA_HOME by default.

---
 recipes-core/openjdk/openjdk-common.inc | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
recipes- renamed from recipes-core/openjdk/openjdk-common.inc +0 -0

core/openjdk/openjdk-common.inc
index 01a0a2a..aaf81f6 100644

recipes-core/openjdk/openjdk-common.inc +0 -0

What about all the other Java providers that could be installed in the system instead? The original did take care of that, whereas this only does the right thing now if OpenJDK-8 is installed...

Cheers,
Andre'