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

Richard Leitner richard.leitner at skidata.com
Mon Dec 17 13:45:18 UTC 2018


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

On 29.11.18 11:48, Fang Jia wrote:
> Use postinst script to set the JAVA_HOME by default.
> 
> Signed-off-by: Fang Jia <fang.jia at windriver.com>
> ---
>  recipes-core/openjdk/openjdk-common.inc | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> 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
> +}
> 


More information about the Openembedded-devel mailing list