diff options
author | Ralph Sennhauser <sera@gentoo.org> | 2012-03-13 10:05:46 +0000 |
---|---|---|
committer | Ralph Sennhauser <sera@gentoo.org> | 2012-03-13 10:05:46 +0000 |
commit | 03df31cfe3de768cbd117a743916b587da3507a9 (patch) | |
tree | d0a57f9cb7f2ded396d454da8f6ac36793a9045d /eclass | |
parent | Version bump. (diff) | |
download | gentoo-2-03df31cfe3de768cbd117a743916b587da3507a9.tar.gz gentoo-2-03df31cfe3de768cbd117a743916b587da3507a9.tar.bz2 gentoo-2-03df31cfe3de768cbd117a743916b587da3507a9.zip |
Add JAVA_PKG_WANT_BUILD_VM to allow limiting build VM by VM handle. The main
aim is to allow respecting the system VM, if possible, for a subset of VMs
provided by the jdk virtuals.
Thanks to Vlastimil Babka <caster@gentoo.org> for contributing the variable
name and review.
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/ChangeLog | 9 | ||||
-rw-r--r-- | eclass/java-utils-2.eclass | 89 |
2 files changed, 88 insertions, 10 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog index b0e4938494ef..9c79e0878c68 100644 --- a/eclass/ChangeLog +++ b/eclass/ChangeLog @@ -1,6 +1,13 @@ # ChangeLog for eclass directory # Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.165 2012/03/10 21:21:30 dirtyepic Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.166 2012/03/13 10:05:46 sera Exp $ + + 13 Mar 2012; Ralph Sennhauser <sera@gentoo.org> java-utils-2.eclass: + Add JAVA_PKG_WANT_BUILD_VM to allow limiting build VM by VM handle. The main + aim is to allow respecting the system VM, if possible, for a subset of VMs + provided by the jdk virtuals. + Thanks to Vlastimil Babka <caster@gentoo.org> for contributing the variable + name and review. 10 Mar 2012; Ryan Hill <dirtyepic@gentoo.org> toolchain.eclass: Rev. 1.527 fixed 4.7 without me noticing. Add comments about the format of diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass index 15e0f1488f79..0c092b67df49 100644 --- a/eclass/java-utils-2.eclass +++ b/eclass/java-utils-2.eclass @@ -6,7 +6,7 @@ # # Licensed under the GNU General Public License, v2 # -# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.149 2011/12/27 17:55:12 fauli Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.150 2012/03/13 10:05:46 sera Exp $ # ----------------------------------------------------------------------------- # @eclass-begin @@ -116,6 +116,19 @@ JAVA_PKG_ALLOW_VM_CHANGE=${JAVA_PKG_ALLOW_VM_CHANGE:="yes"} # ----------------------------------------------------------------------------- # ----------------------------------------------------------------------------- +# @variable-external JAVA_PKG_WANT_BUILD_VM +# +# A list of VM handles to choose a build VM from. If the list contains the +# currently active VM use that one, otherwise step through the list till a +# usable/installed VM is found. +# +# This allows to use an explicit list of JDKs in DEPEND instead of a virtual. +# Users of this variable must make sure at least one of the listed handles is +# covered by DEPEND. +# Requires JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET to be set as well. +# ----------------------------------------------------------------------------- + +# ----------------------------------------------------------------------------- # @variable-external JAVA_PKG_WANT_SOURCE # # Specify a specific VM version to compile for to use for -source. @@ -2539,7 +2552,8 @@ java-pkg_setup-vm() { # ------------------------------------------------------------------------------ # @internal-function java-pkg_needs-vm # -# Does the current package depend on virtual/jdk? +# Does the current package depend on virtual/jdk or does it set +# JAVA_PKG_WANT_BUILD_VM? # # @return 0 - Package depends on virtual/jdk # @return 1 - Package does not depend on virtual/jdk @@ -2551,6 +2565,8 @@ java-pkg_needs-vm() { return 0 fi + [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0 + return 1 } @@ -2588,6 +2604,41 @@ java-pkg_get-vm-version() { } # ------------------------------------------------------------------------------ +# @internal-function java-pkg_build-vm-from-handle +# +# Selects a build vm from a list of vm handles. First checks for the system-vm +# beeing usable, then steps through the listed handles till a suitable vm is +# found. +# +# @return - VM handle of an available JDK +# ------------------------------------------------------------------------------ +java-pkg_build-vm-from-handle() { + debug-print-function ${FUNCNAME} "$*" + + local vm + vm=$(java-pkg_get-current-vm) + if [[ $? != 0 ]]; then + eerror "${FUNCNAME}: Failed to get active vm" + return 1 + fi + + if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then + echo ${vm} + return 0 + fi + + for vm in ${JAVA_PKG_WANT_BUILD_VM}; do + if java-config-2 --select-vm=${vm} 2>/dev/null; then + echo ${vm} + return 0 + fi + done + + eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}" + return 1 +} + +# ------------------------------------------------------------------------------ # @internal-function java-pkg_switch-vm # # Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and @@ -2605,15 +2656,35 @@ java-pkg_switch-vm() { export GENTOO_VM="${JAVA_PKG_FORCE_VM}" # if we're allowed to switch the vm... elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then - debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" - GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" - if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then - eerror "Unable to determine VM for building from dependencies:" - echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" - die "Failed to determine VM for building." + # if there is an explicit list of handles to choose from + if [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]]; then + debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}" + GENTOO_VM=$(java-pkg_build-vm-from-handle) + if [[ $? != 0 ]]; then + eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}" + die "${FUNCNAME}: Failed to determine VM for building" + fi + # JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET are required as + # they can't be deduced from handles. + if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then + eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE" + die "Specify JAVA_PKG_WANT_SOURCE" + fi + if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then + eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET" + die "Specify JAVA_PKG_WANT_TARGET" + fi + # otherwise determine a vm from dep string else - export GENTOO_VM + debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" + GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" + if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then + eerror "Unable to determine VM for building from dependencies:" + echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" + die "Failed to determine VM for building." + fi fi + export GENTOO_VM # otherwise just make sure the current VM is sufficient else java-pkg_ensure-vm-version-sufficient |