Gentoo Archives: gentoo-commits

From: James Le Cuirot <chewi@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Tue, 02 Aug 2016 22:34:49
Message-Id: 1470177264.436dd062c36057b2312c205928fd439b1c5b6e79.chewi@gentoo
1 commit: 436dd062c36057b2312c205928fd439b1c5b6e79
2 Author: James Le Cuirot <chewi <AT> gentoo <DOT> org>
3 AuthorDate: Sun Jul 31 22:16:54 2016 +0000
4 Commit: James Le Cuirot <chewi <AT> gentoo <DOT> org>
5 CommitDate: Tue Aug 2 22:34:24 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=436dd062
7
8 java-vm-2.eclass: Add java-vm_install-env to replace set_java_env
9
10 set_java_env is now deprecated. The new function is better because any
11 variable in the environment file can be resolved and it even allows
12 subshells for more dynamic content.
13
14 eclass/java-vm-2.eclass | 49 +++++++++++++++++++++++++++++++++++++++++++++----
15 1 file changed, 45 insertions(+), 4 deletions(-)
16
17 diff --git a/eclass/java-vm-2.eclass b/eclass/java-vm-2.eclass
18 index 8bfb1bb..e2d77ad 100644
19 --- a/eclass/java-vm-2.eclass
20 +++ b/eclass/java-vm-2.eclass
21 @@ -161,14 +161,14 @@ get_system_arch() {
22 # @FUNCTION: set_java_env
23 # @DESCRIPTION:
24 # Installs a vm env file.
25 +# DEPRECATED, use java-vm_install-env instead.
26
27 -# TODO rename to something more evident, like install_env_file
28 set_java_env() {
29 debug-print-function ${FUNCNAME} $*
30
31 local platform="$(get_system_arch)"
32 local env_file="${ED}${JAVA_VM_CONFIG_DIR}/${VMHANDLE}"
33 - local old_env_file="${ED}/etc/env.d/java/20${P}"
34 +
35 if [[ ${1} ]]; then
36 local source_env_file="${1}"
37 else
38 @@ -206,8 +206,49 @@ set_java_env() {
39
40 # Make the symlink
41 dodir "${JAVA_VM_DIR}"
42 - dosym ${java_home#${EPREFIX}} ${JAVA_VM_DIR}/${VMHANDLE} \
43 - || die "Failed to make VM symlink at ${JAVA_VM_DIR}/${VMHANDLE}"
44 + dosym ${java_home#${EPREFIX}} ${JAVA_VM_DIR}/${VMHANDLE}
45 +}
46 +
47 +
48 +# @FUNCTION: java-vm_install-env
49 +# @DESCRIPTION:
50 +#
51 +# Installs a Java VM environment file. The source can be specified but
52 +# defaults to ${FILESDIR}/${VMHANDLE}.env.sh.
53 +#
54 +# Environment variables within this file will be resolved. You should
55 +# escape the $ when referring to variables that should be resolved later
56 +# such as ${JAVA_HOME}. Subshells may be used but avoid using double
57 +# quotes. See icedtea-bin.env.sh for a good example.
58 +
59 +java-vm_install-env() {
60 + debug-print-function ${FUNCNAME} "$*"
61 +
62 + local env_file="${ED}${JAVA_VM_CONFIG_DIR}/${VMHANDLE}"
63 + local source_env_file="${1-${FILESDIR}/${VMHANDLE}.env.sh}"
64 +
65 + if [[ ! -f "${source_env_file}" ]]; then
66 + die "Unable to find the env file: ${source_env_file}"
67 + fi
68 +
69 + dodir "${JAVA_VM_CONFIG_DIR}"
70 +
71 + # Here be dragons! ;) -- Chewi
72 + eval echo "\"$(cat <<< "$(sed 's:":\\":g' "${source_env_file}")")\"" > "${env_file}" ||
73 + die "failed to create Java env file"
74 +
75 + (
76 + echo "VMHANDLE=\"${VMHANDLE}\""
77 + echo "BUILD_ONLY=\"${JAVA_VM_BUILD_ONLY}\""
78 + [[ ${JAVA_PROVIDE} ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" || true
79 + ) >> "${env_file}" || die "failed to append to Java env file"
80 +
81 + local java_home=$(unset JAVA_HOME; source "${env_file}"; echo ${JAVA_HOME})
82 + [[ -z ${java_home} ]] && die "No JAVA_HOME defined in ${env_file}"
83 +
84 + # Make the symlink
85 + dodir "${JAVA_VM_DIR}"
86 + dosym "${java_home#${EPREFIX}}" "${JAVA_VM_DIR}/${VMHANDLE}"
87 }