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

André Draszik git at andred.net
Wed Jan 2 20:06:42 UTC 2019


On Thu, 2018-11-29 at 18:48 +0800, 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_ar
> ch(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
> +}

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'




More information about the Openembedded-devel mailing list