/[gentoo-x86]/eclass/java-utils-2.eclass
Gentoo

Diff of /eclass/java-utils-2.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.110 Revision 1.150
1# Base eclass for Java packages 1# Base eclass for Java packages
2# 2#
3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org> 3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org> 4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
5# Copyright (c) 2004-2005, Gentoo Foundation 5# Copyright (c) 2004-2011, Gentoo Foundation
6# 6#
7# Licensed under the GNU General Public License, v2 7# Licensed under the GNU General Public License, v2
8# 8#
9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.110 2008/07/09 21:16:40 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.150 2012/03/13 10:05:46 sera Exp $
10 10
11# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
12# @eclass-begin 12# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
59# ----------------------------------------------------------------------------- 59# -----------------------------------------------------------------------------
60# @variable-internal JAVA_PKG_PORTAGE_DEP 60# @variable-internal JAVA_PKG_PORTAGE_DEP
61# 61#
62# The version of portage we need to function properly. Previously it was 62# The version of portage we need to function properly. Previously it was
63# portage with phase hooks support but now we use a version with proper env 63# portage with phase hooks support but now we use a version with proper env
64# saving. 64# saving. For EAPI 2 we have new enough stuff so let's have cleaner deps.
65# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7" 66has "${EAPI}" 0 1 && JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1.2.7"
67 67
68# ----------------------------------------------------------------------------- 68# -----------------------------------------------------------------------------
69# @variable-internal JAVA_PKG_E_DEPEND 69# @variable-internal JAVA_PKG_E_DEPEND
70# 70#
71# This is a convience variable to be used from the other java eclasses. This is 71# This is a convience variable to be used from the other java eclasses. This is
72# the version of java-config we want to use. Usually the latest stable version 72# the version of java-config we want to use. Usually the latest stable version
73# so that ebuilds can use new features without depending on specific versions. 73# so that ebuilds can use new features without depending on specific versions.
74# ----------------------------------------------------------------------------- 74# -----------------------------------------------------------------------------
75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.33-r1 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.9-r1 ${JAVA_PKG_PORTAGE_DEP}"
76hasq source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )" 76has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
77
78# -----------------------------------------------------------------------------
79# @variable-preinherit JAVA_PKG_WANT_BOOTCLASSPATH
80#
81# The version of bootclasspath the package needs to work. Translates to a proper
82# dependency. The bootclasspath has to be obtained by java-ant_rewrite-bootclasspath
83# -----------------------------------------------------------------------------
84
85if [[ -n "${JAVA_PKG_WANT_BOOTCLASSPATH}" ]]; then
86 if [[ "${JAVA_PKG_WANT_BOOTCLASSPATH}" == "1.5" ]]; then
87 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} >=dev-java/gnu-classpath-0.98-r1:0.98"
88 else
89 eerror "Unknown value of JAVA_PKG_WANT_BOOTCLASSPATH"
90 # since die in global scope doesn't work, this will make repoman fail
91 JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} BAD_JAVA_PKG_WANT_BOOTCLASSPATH"
92 fi
93fi
77 94
78# ----------------------------------------------------------------------------- 95# -----------------------------------------------------------------------------
79# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 96# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
80# @variable-default yes 97# @variable-default yes
81# 98#
94# Should only be used for testing and debugging. 111# Should only be used for testing and debugging.
95# 112#
96# @example Use sun-jdk-1.5 to emerge foo 113# @example Use sun-jdk-1.5 to emerge foo
97# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo 114# JAVA_PKG_FORCE_VM=sun-jdk-1.5 emerge foo
98# 115#
116# -----------------------------------------------------------------------------
117
118# -----------------------------------------------------------------------------
119# @variable-external JAVA_PKG_WANT_BUILD_VM
120#
121# A list of VM handles to choose a build VM from. If the list contains the
122# currently active VM use that one, otherwise step through the list till a
123# usable/installed VM is found.
124#
125# This allows to use an explicit list of JDKs in DEPEND instead of a virtual.
126# Users of this variable must make sure at least one of the listed handles is
127# covered by DEPEND.
128# Requires JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET to be set as well.
99# ----------------------------------------------------------------------------- 129# -----------------------------------------------------------------------------
100 130
101# ----------------------------------------------------------------------------- 131# -----------------------------------------------------------------------------
102# @variable-external JAVA_PKG_WANT_SOURCE 132# @variable-external JAVA_PKG_WANT_SOURCE
103# 133#
224 ( # dont want to pollute calling env 254 ( # dont want to pollute calling env
225 insinto "${dest}" 255 insinto "${dest}"
226 doins -r "$@" 256 doins -r "$@"
227 ) || die "Installing examples failed" 257 ) || die "Installing examples failed"
228 fi 258 fi
259
260 # Let's make a symlink to the directory we have everything else under
261 dosym "${dest}" "${JAVA_PKG_SHAREPATH}/examples" || die
229} 262}
230 263
231# ----------------------------------------------------------------------------- 264# -----------------------------------------------------------------------------
232# @ebuild-function java-pkg_dojar 265# @ebuild-function java-pkg_dojar
233# 266#
365 if [[ ${jar} = *\** ]]; then 398 if [[ ${jar} = *\** ]]; then
366 eerror "The argument ${jar} to ${FUNCNAME}" 399 eerror "The argument ${jar} to ${FUNCNAME}"
367 eerror "has * in it. If you want it to glob in" 400 eerror "has * in it. If you want it to glob in"
368 eerror '${D} add ${D} to the argument.' 401 eerror '${D} add ${D} to the argument.'
369 fi 402 fi
403 debug-print "${jar} or ${D}${jar} not found"
370 die "${jar} does not exist" 404 die "${jar} does not exist"
371 fi 405 fi
372 done 406 done
373 407
374 java-pkg_do_write_ 408 java-pkg_do_write_
429# @param $@ - JNI libraries to install 463# @param $@ - JNI libraries to install
430# ------------------------------------------------------------------------------ 464# ------------------------------------------------------------------------------
431java-pkg_doso() { 465java-pkg_doso() {
432 debug-print-function ${FUNCNAME} $* 466 debug-print-function ${FUNCNAME} $*
433 467
434 [[ ${#} -lt 1 ]] && "At least one argument required for ${FUNCNAME}"
435 java-pkg_check-phase install 468 java-pkg_check-phase install
436 469
437 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 470 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
438 471
439 java-pkg_init_paths_ 472 java-pkg_init_paths_
440 473
441 local lib 474 local lib
442 # for each lib 475 # for each lib
445 if [[ -e "${lib}" ]] ; then 478 if [[ -e "${lib}" ]] ; then
446 # install if it isn't a symlink 479 # install if it isn't a symlink
447 if [[ ! -L "${lib}" ]] ; then 480 if [[ ! -L "${lib}" ]] ; then
448 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 481 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
449 INSOPTIONS="${LIBOPTIONS}" \ 482 INSOPTIONS="${LIBOPTIONS}" \
450 doins "${lib}" || "failed to install ${lib}" 483 doins "${lib}" || die "failed to install ${lib}"
451 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 484 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
452 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 485 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
453 # otherwise make a symlink to the symlink's origin 486 # otherwise make a symlink to the symlink's origin
454 else 487 else
455 # TODO use dosym 488 dosym "$(readlink "${lib}")" "${JAVA_PKG_LIBDEST}/${lib##*/}"
456 ln -s "$(readlink "${lib}")" \
457 "${D}${JAVA_PKG_LIBDEST}/$(basename "${lib}")"
458 debug-print "${lib} is a symlink, linking accordanly" 489 debug-print "${lib} is a symlink, linking accordantly"
459 fi 490 fi
460 # otherwise die 491 # otherwise die
461 else 492 else
462 die "${lib} does not exist" 493 die "${lib} does not exist"
463 fi 494 fi
479java-pkg_regso() { 510java-pkg_regso() {
480 debug-print-function ${FUNCNAME} $* 511 debug-print-function ${FUNCNAME} $*
481 512
482 java-pkg_check-phase install 513 java-pkg_check-phase install
483 514
484 [[ ${#} -lt 1 ]] && "at least one argument needed" 515 [[ ${#} -lt 1 ]] && die "${FUNCNAME} requires at least one argument"
485 516
486 java-pkg_init_paths_ 517 java-pkg_init_paths_
487 518
488 local lib target_dir 519 local lib target_dir
489 for lib in "$@" ; do 520 for lib in "$@" ; do
874 905
875 local build_only="" 906 local build_only=""
876 local destdir="." 907 local destdir="."
877 local deep="" 908 local deep=""
878 local virtual="" 909 local virtual=""
910 local record_jar=""
879 911
880 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 912 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
881 913
882 while [[ "${1}" == --* ]]; do 914 while [[ "${1}" == --* ]]; do
883 if [[ "${1}" = "--build-only" ]]; then 915 if [[ "${1}" = "--build-only" ]]; then
918 for pkg in ${target_pkg//,/ }; do 950 for pkg in ${target_pkg//,/ }; do
919 java-pkg_ensure-dep "${build_only}" "${pkg}" 951 java-pkg_ensure-dep "${build_only}" "${pkg}"
920 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 952 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
921 done 953 done
922 # setting this disables further record-jar_ calls later 954 # setting this disables further record-jar_ calls later
923 build_only="build" 955 record_jar="true"
924 else 956 else
925 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 957 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
926 fi 958 fi
927 959
928 # Record the entire virtual as a dependency so that 960 # Record the entire virtual as a dependency so that
929 # no jars are missed. 961 # no jars are missed.
930 if [[ -z "${build_only}" && -n "${virtual}" ]]; then 962 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
931 java-pkg_record-jar_ "${target_pkg}" 963 java-pkg_record-jar_ "${target_pkg}"
932 # setting this disables further record-jars_ calls later 964 # setting this disables further record-jars_ calls later
933 build_only="build" 965 record_jar="true"
934 fi 966 fi
935 967
936 pushd ${destdir} > /dev/null \ 968 pushd ${destdir} > /dev/null \
937 || die "failed to change directory to ${destdir}" 969 || die "failed to change directory to ${destdir}"
938 970
946 # If no specific target jar was indicated, link it 978 # If no specific target jar was indicated, link it
947 if [[ -z "${target_jar}" ]] ; then 979 if [[ -z "${target_jar}" ]] ; then
948 [[ -f "${target_jar}" ]] && rm "${target_jar}" 980 [[ -f "${target_jar}" ]] && rm "${target_jar}"
949 ln -snf "${jar}" \ 981 ln -snf "${jar}" \
950 || die "Failed to make symlink from ${jar} to ${jar_name}" 982 || die "Failed to make symlink from ${jar} to ${jar_name}"
983 if [[ -z "${record_jar}" ]]; then
984 if [[ -z "${build_only}" ]]; then
951 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 985 java-pkg_record-jar_ "${target_pkg}" "${jar}"
986 else
987 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
988 fi
989 fi
952 # otherwise, if the current jar is the target jar, link it 990 # otherwise, if the current jar is the target jar, link it
953 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 991 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
954 [[ -f "${destjar}" ]] && rm "${destjar}" 992 [[ -f "${destjar}" ]] && rm "${destjar}"
955 ln -snf "${jar}" "${destjar}" \ 993 ln -snf "${jar}" "${destjar}" \
956 || die "Failed to make symlink from ${jar} to ${destjar}" 994 || die "Failed to make symlink from ${jar} to ${destjar}"
995 if [[ -z "${record_jar}" ]]; then
996 if [[ -z "${build_only}" ]]; then
957 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 997 java-pkg_record-jar_ "${target_pkg}" "${jar}"
998 else
999 java-pkg_record-jar_ --build-only "${target_jar}" "${jar}"
1000 fi
1001 fi
958 popd > /dev/null 1002 popd > /dev/null
959 return 0 1003 return 0
960 fi 1004 fi
961 done 1005 done
962 popd > /dev/null 1006 popd > /dev/null
1035 1079
1036 for pkg in ${pkgs//,/ }; do 1080 for pkg in ${pkgs//,/ }; do
1037 java-pkg_ensure-dep "${build_only}" "${pkg}" 1081 java-pkg_ensure-dep "${build_only}" "${pkg}"
1038 done 1082 done
1039 1083
1040 # Only record jars that aren't build-only 1084 for pkg in ${pkgs//,/ }; do
1041 if [[ -z "${build_only}" ]]; then 1085 if [[ -z "${build_only}" ]]; then
1042 for pkg in ${pkgs//,/ }; do
1043 java-pkg_record-jar_ "${pkg}" 1086 java-pkg_record-jar_ "${pkg}"
1087 else
1088 java-pkg_record-jar_ --build-only "${pkg}"
1089 fi
1044 done 1090 done
1045 fi
1046 1091
1047 echo "${jars}" 1092 echo "${jars}"
1048} 1093}
1049 1094
1050# ------------------------------------------------------------------------------ 1095# ------------------------------------------------------------------------------
1071java-pkg_getjar() { 1116java-pkg_getjar() {
1072 debug-print-function ${FUNCNAME} $* 1117 debug-print-function ${FUNCNAME} $*
1073 1118
1074 local build_only="" 1119 local build_only=""
1075 local virtual="" 1120 local virtual=""
1121 local record_jar=""
1076 1122
1077 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1123 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1078 1124
1079 while [[ "${1}" == --* ]]; do 1125 while [[ "${1}" == --* ]]; do
1080 if [[ "${1}" = "--build-only" ]]; then 1126 if [[ "${1}" = "--build-only" ]]; then
1106 java-pkg_ensure-dep "${build_only}" "${pkg}" 1152 java-pkg_ensure-dep "${build_only}" "${pkg}"
1107 1153
1108 # Record the package(Virtual) as a dependency and then set build_only 1154 # Record the package(Virtual) as a dependency and then set build_only
1109 # So that individual jars are not recorded. 1155 # So that individual jars are not recorded.
1110 if [[ -n "${virtual}" ]]; then 1156 if [[ -n "${virtual}" ]]; then
1157 if [[ -z "${build_only}" ]]; then
1111 java-pkg_record-jar_ "${pkg}" 1158 java-pkg_record-jar_ "${pkg}"
1112 build_only="true" 1159 else
1160 java-pkg_record-jar_ --build-only "${pkg}"
1161 fi
1162 record_jar="true"
1113 fi 1163 fi
1114 1164
1115 for jar in ${classpath//:/ }; do 1165 for jar in ${classpath//:/ }; do
1116 if [[ ! -f "${jar}" ]] ; then 1166 if [[ ! -f "${jar}" ]] ; then
1117 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1167 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1118 fi 1168 fi
1119 1169
1120 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1170 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1121 # Only record jars that aren't build-only 1171 # Only record jars that aren't build-only
1122 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}" 1172 if [[ -z "${record_jar}" ]]; then
1173 if [[ -z "${build_only}" ]]; then
1174 java-pkg_record-jar_ "${pkg}" "${jar}"
1175 else
1176 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1177 fi
1178 fi
1123 echo "${jar}" 1179 echo "${jar}"
1124 return 0 1180 return 0
1125 fi 1181 fi
1126 done 1182 done
1127 1183
1261 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV} 1317 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1262 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}" 1318 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1263 1319
1264 java-pkg_do_write_ 1320 java-pkg_do_write_
1265} 1321}
1322
1323# ------------------------------------------------------------------------------
1324# @ebuild-function java-pkg_get-bootclasspath
1325#
1326# Returns classpath of a given bootclasspath-providing package version.
1327#
1328# @param $1 - the version of bootclasspath (e.g. 1.5), 'auto' for bootclasspath
1329# of the current JDK
1330# ------------------------------------------------------------------------------
1331
1332java-pkg_get-bootclasspath() {
1333 local version="${1}"
1334
1335 local bcp
1336 case "${version}" in
1337 auto)
1338 bcp="$(java-config -g BOOTCLASSPATH)"
1339 ;;
1340 1.5)
1341 bcp="$(java-pkg_getjars --build-only gnu-classpath-0.98)"
1342 ;;
1343 *)
1344 eerror "unknown parameter of java-pkg_get-bootclasspath"
1345 die "unknown parameter of java-pkg_get-bootclasspath"
1346 ;;
1347 esac
1348
1349 echo "${bcp}"
1350}
1351
1266 1352
1267# This function reads stdin, and based on that input, figures out how to 1353# This function reads stdin, and based on that input, figures out how to
1268# populate jars from the filesystem. 1354# populate jars from the filesystem.
1269# Need to figure out a good way of making use of this, ie be able to use a 1355# Need to figure out a good way of making use of this, ie be able to use a
1270# string that was built instead of stdin 1356# string that was built instead of stdin
1308# @section-begin helper 1394# @section-begin helper
1309# @section-summary Helper functions 1395# @section-summary Helper functions
1310# 1396#
1311# Various other functions to use from an ebuild 1397# Various other functions to use from an ebuild
1312# ------------------------------------------------------------------------------ 1398# ------------------------------------------------------------------------------
1313
1314# ------------------------------------------------------------------------------
1315# @ebuild-function java-pkg_need
1316#
1317# Adds virtual dependencies, which can optionally be controlled by a USE flag.
1318# Currently supported virtuals are:
1319# javamail
1320# jdbc-stdext
1321# jaf
1322# jdbc-rowset
1323# jms
1324#
1325# @param $1 - Optionally indicate that the dependencies are controlled by
1326# a use flag by specifying '--use' Requires $2.
1327# @param $2 - USE flag which will enable the dependencies.
1328# @param $@ - virtual packages to add depenedencies for
1329# ------------------------------------------------------------------------------
1330# TODO rewrite to parse a line based declaration file instead -- karltk
1331#java-pkg_need() {
1332# debug-print-function ${FUNCNAME} $*
1333# local useflag
1334# if [[ ${1} == "--use" ]]; then
1335# useflag="${2}"
1336# shift 2
1337# fi
1338#
1339# if [[ -z ${1} ]]; then
1340# die "Must specify at least one virtual package."
1341# fi
1342#
1343# local depstr newdepstr
1344#
1345# for virtual in ${@}; do
1346# if has ${virtual} ${JAVA_PKG_VNEED}; then
1347# debug-print "Already registered virtual ${virtual}"
1348# continue
1349# fi
1350# case ${virtual} in
1351# javamail)
1352# debug-print "java-pkg_need: adding javamail dependencies"
1353# newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )"
1354# ;;
1355# jdbc-stdext)
1356# debug-print "java-pkg_need: adding jdbc-stdext dependencies"
1357# newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )"
1358# ;;
1359# jaf)
1360# debug-print "java-pkg_need: adding jaf dependencies"
1361# newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )"
1362# ;;
1363# jdbc-rowset)
1364# debug-print "java-pkg_need: adding jdbc-rowset dependencies"
1365# newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )"
1366# ;;
1367# jms)
1368# debug-print "java-pkg_need: adding jms dependencies"
1369# newdepstr="|| ( dev-java/sun-jms dev-java/openjms )"
1370# ;;
1371# *)
1372# die "Invalid virtual: ${virtual}"
1373# esac
1374#
1375# export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}"
1376#
1377# if [[ -n ${useflag} ]]; then
1378# depstr="${depstr} ${useflag}? ( ${newdepstr} )"
1379# else
1380# depstr="${depstr} ${newdepstr}"
1381# fi
1382# done
1383#
1384# [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}"
1385# [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}"
1386#
1387# export DEPEND="${DEPEND} ${depstr}"
1388# export RDEPEND="${RDEPEND} ${depstr}"
1389#}
1390 1399
1391# ------------------------------------------------------------------------------ 1400# ------------------------------------------------------------------------------
1392# @ebuild-function java-pkg_find-normal-jars 1401# @ebuild-function java-pkg_find-normal-jars
1393# 1402#
1394# Find the files with suffix .jar file in the given directory or $WORKDIR 1403# Find the files with suffix .jar file in the given directory or $WORKDIR
1560java-pkg_get-current-vm() { 1569java-pkg_get-current-vm() {
1561 echo ${GENTOO_VM} 1570 echo ${GENTOO_VM}
1562} 1571}
1563 1572
1564java-pkg_current-vm-matches() { 1573java-pkg_current-vm-matches() {
1565 hasq $(java-pkg_get-current-vm) ${@} 1574 has $(java-pkg_get-current-vm) ${@}
1566 return $? 1575 return $?
1567} 1576}
1568 1577
1569# ------------------------------------------------------------------------------ 1578# ------------------------------------------------------------------------------
1570# @ebuild-function java-pkg_get-source 1579# @ebuild-function java-pkg_get-source
1685 die "No GCJ support found!" 1694 die "No GCJ support found!"
1686 fi 1695 fi
1687} 1696}
1688 1697
1689java-pkg_ensure-test() { 1698java-pkg_ensure-test() {
1690 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \ 1699 if has test ${FEATURES} && ! has -test ${FEATURES} \
1691 && hasq test ${IUSE} && ! use test; 1700 && has test ${IUSE} && ! use test;
1692 then 1701 then
1693 eerror "You specified FEATURES=test, but USE=test is needed" 1702 eerror "You specified FEATURES=test, but USE=test is needed"
1694 eerror "to pull in the additional dependencies for testing" 1703 eerror "to pull in the additional dependencies for testing"
1695 die "Need USE=test enabled" 1704 die "Need USE=test enabled"
1696 fi 1705 fi
1759 else 1768 else
1760 return 0 1769 return 0
1761 fi 1770 fi
1762} 1771}
1763 1772
1773
1764# ------------------------------------------------------------------------------ 1774# ------------------------------------------------------------------------------
1765# @ebuild-function ejunit 1775# @internal-function ejunit_
1766# 1776#
1767# Junit wrapper function. Makes it easier to run the tests and checks for 1777# Internal Junit wrapper function. Makes it easier to run the tests and checks for
1768# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner. 1778# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1769# 1779#
1770# Examples: 1780# @param $1 - junit package (junit or junit-4)
1771# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1772# ejunit org.blinkenlights.jid3.test.AllTests
1773#
1774# @param $1 - -cp or -classpath 1781# @param $2 - -cp or -classpath
1775# @param $2 - classpath; junit and recorded dependencies get appended 1782# @param $3 - classpath; junit and recorded dependencies get appended
1776# @param $@ - the rest of the parameters are passed to java 1783# @param $@ - the rest of the parameters are passed to java
1777# ------------------------------------------------------------------------------
1778ejunit() { 1784ejunit_() {
1779 debug-print-function ${FUNCNAME} $* 1785 debug-print-function ${FUNCNAME} $*
1780 1786
1781 local pkgs 1787 local pkgs
1782 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then 1788 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1783 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1789 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1784 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1790 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1785 done 1791 done
1786 fi 1792 fi
1787 1793
1794 local junit=${1}
1795 shift 1
1796
1788 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1797 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1789 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1798 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1790 cp="${2}:${cp}" 1799 cp="${2}:${cp}"
1791 shift 2 1800 shift 2
1792 else 1801 else
1793 cp=".:${cp}" 1802 cp=".:${cp}"
1794 fi 1803 fi
1795 1804
1796 local runner=junit.textui.TestRunner 1805 local runner=junit.textui.TestRunner
1806 if [[ "${junit}" == "junit-4" ]] ; then
1807 runner=org.junit.runner.JUnitCore
1808 fi
1797 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1809 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1798 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" 1810 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1799} 1811}
1800 1812
1801# ------------------------------------------------------------------------------ 1813# ------------------------------------------------------------------------------
1814# @ebuild-function ejunit
1815#
1816# Junit wrapper function. Makes it easier to run the tests and checks for
1817# dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore.
1818#
1819# Examples:
1820# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1821# ejunit org.blinkenlights.jid3.test.AllTests
1822# ejunit org.blinkenlights.jid3.test.FirstTest \
1823# org.blinkenlights.jid3.test.SecondTest
1824#
1825# @param $1 - -cp or -classpath
1826# @param $2 - classpath; junit and recorded dependencies get appended
1827# @param $@ - the rest of the parameters are passed to java
1828# ------------------------------------------------------------------------------
1829ejunit() {
1830 debug-print-function ${FUNCNAME} $*
1831
1832 ejunit_ "junit" "${@}"
1833}
1834
1835# ------------------------------------------------------------------------------
1836# @ebuild-function ejunit4
1837#
1838# Junit4 wrapper function. Makes it easier to run the tests and checks for
1839# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
1840#
1841# Examples:
1842# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
1843# ejunit4 org.blinkenlights.jid3.test.AllTests
1844# ejunit4 org.blinkenlights.jid3.test.FirstTest \
1845# org.blinkenlights.jid3.test.SecondTest
1846#
1847# @param $1 - -cp or -classpath
1848# @param $2 - classpath; junit and recorded dependencies get appended
1849# @param $@ - the rest of the parameters are passed to java
1850# ------------------------------------------------------------------------------
1851ejunit4() {
1852 debug-print-function ${FUNCNAME} $*
1853
1854 ejunit_ "junit-4" "${@}"
1855}
1856
1857# ------------------------------------------------------------------------------
1802# @section-end helper 1858# @section-end helper
1803# ------------------------------------------------------------------------------ 1859# ------------------------------------------------------------------------------
1860
1861# ------------------------------------------------------------------------------
1862# @eclass-src_prepare
1863#
1864# src_prepare Searches for bundled jars
1865# Don't call directly, but via java-pkg-2_src_prepare!
1866# ------------------------------------------------------------------------------
1867
1868java-utils-2_src_prepare() {
1869 [[ ${EBUILD_PHASE} == prepare ]] &&
1870 java-pkg_func-exists java_prepare && java_prepare
1871
1872 # Remember that eant will call this unless called via Portage
1873 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1874 echo "Searching for bundled jars:"
1875 java-pkg_find-normal-jars || echo "None found."
1876 echo "Searching for bundled classes (no output if none found):"
1877 find "${WORKDIR}" -name "*.class"
1878 echo "Search done."
1879 fi
1880 touch "${T}/java-utils-2_src_prepare-run"
1881}
1882
1883# ------------------------------------------------------------------------------
1884# @eclass-pkg_preinst
1885#
1886# pkg_preinst Searches for missing and unneeded dependencies
1887# Don't call directly, but via java-pkg-2_pkg_preinst!
1888# ------------------------------------------------------------------------------
1889
1890java-utils-2_pkg_preinst() {
1891 if is-java-strict; then
1892 if has_version dev-java/java-dep-check; then
1893 [[ -e "${JAVA_PKG_ENV}" ]] || return
1894 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1895 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1896 ewarn "Possibly unneeded dependencies found in package.env:"
1897 for dep in ${output}; do
1898 ewarn "\t${dep}"
1899 done
1900 fi
1901 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1902 ewarn "${output}"
1903 fi
1904 else
1905 eerror "Install dev-java/java-dep-check for dependency checking"
1906 fi
1907 fi
1908}
1804 1909
1805# ------------------------------------------------------------------------------ 1910# ------------------------------------------------------------------------------
1806# @section-begin build 1911# @section-begin build
1807# @section-summary Build functions 1912# @section-summary Build functions
1808# 1913#
1817# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1922# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1818# variables: 1923# variables:
1819# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1924# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1820# gentoo.classpath property. Be sure to call 1925# gentoo.classpath property. Be sure to call
1821# java-ant_rewrite-classpath in src_unpack. 1926# java-ant_rewrite-classpath in src_unpack.
1822# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files 1927# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1928# for build-time purposes, the dependency is not recorded to
1929# package.env!
1823# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1930# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1824# ------------------------------------------------------------------------------ 1931# ------------------------------------------------------------------------------
1825eant() { 1932eant() {
1826 debug-print-function ${FUNCNAME} $* 1933 debug-print-function ${FUNCNAME} $*
1827 1934
1828 if [[ ${EBUILD_PHASE} = compile ]]; then 1935 if [[ ${EBUILD_PHASE} = compile ]]; then
1829 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1936 java-ant-2_src_configure
1830 # finally get rid of the hooks without breaking stuff 1937 java-utils-2_src_prepare
1831
1832 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1833 && java-ant_ignore-system-classes "${S}/build.xml"
1834
1835 if hasq java-ant-2 ${INHERITED}; then
1836 java-ant_bsfix
1837 fi 1938 fi
1838 1939
1839 # eant can be called multiple times
1840 JAVA_PKG_BSFIX="off"
1841
1842 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1843 echo "Searching for bundled jars:"
1844 java-pkg_find-normal-jars || echo "None found."
1845 echo "Searching for bundled classes (no output if none found):"
1846 find "${WORKDIR}" -name "*.class"
1847 echo "Search done."
1848 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1849 fi
1850 fi
1851
1852 if ! hasq java-ant-2 ${INHERITED}; then 1940 if ! has java-ant-2 ${INHERITED}; then
1853 local msg="You should inherit java-ant-2 when using eant" 1941 local msg="You should inherit java-ant-2 when using eant"
1854 java-pkg_announce-qa-violation "${msg}" 1942 java-pkg_announce-qa-violation "${msg}"
1855 fi 1943 fi
1856 1944
1857 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore" 1945 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1932 2020
1933 if [[ ${EBUILD_PHASE} = "test" ]]; then 2021 if [[ ${EBUILD_PHASE} = "test" ]]; then
1934 antflags="${antflags} -DJunit.present=true" 2022 antflags="${antflags} -DJunit.present=true"
1935 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 2023 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1936 getjarsarg="--with-dependencies" 2024 getjarsarg="--with-dependencies"
2025 else
2026 antflags="${antflags} -Dmaven.test.skip=true"
1937 fi 2027 fi
1938 2028
1939 local cp 2029 local cp
1940 2030
1941 for atom in ${gcp}; do 2031 for atom in ${gcp}; do
1942 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 2032 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1943 done 2033 done
1944 2034
2035 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
2036
1945 if [[ ${cp} ]]; then 2037 if [[ ${cp} ]]; then
1946 # It seems ant does not like single quotes around ${cp} 2038 # It seems ant does not like single quotes around ${cp}
2039 cp=${cp#:}
2040 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
2041 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1947 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 2042 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1948 fi 2043 fi
1949 2044
1950 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 2045 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1951 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 2046 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1952 ant ${antflags} "${@}" || die "eant failed" 2047 ant ${antflags} "${@}" || die "eant failed"
2053# call it during each of the phases of the merge process. 2148# call it during each of the phases of the merge process.
2054# 2149#
2055# ----------------------------------------------------------------------------- 2150# -----------------------------------------------------------------------------
2056java-pkg_init() { 2151java-pkg_init() {
2057 debug-print-function ${FUNCNAME} $* 2152 debug-print-function ${FUNCNAME} $*
2153
2154 # Don't set up build environment if installing from binary. #206024 #258423
2155 [[ "${MERGE_TYPE}" == "binary" ]] && return
2156 # Also try Portage's nonstandard EMERGE_FROM for old EAPIs, if it doesn't
2157 # work nothing is lost.
2158 has ${EAPI:-0} 0 1 2 3 && [[ "${EMERGE_FROM}" == "binary" ]] && return
2159
2058 unset JAVAC 2160 unset JAVAC
2059 unset JAVA_HOME 2161 unset JAVA_HOME
2162
2163 java-config --help >/dev/null || {
2164 eerror ""
2165 eerror "Can't run java-config --help"
2166 eerror "Have you upgraded python recently but haven't"
2167 eerror "run python-updater yet?"
2168 die "Can't run java-config --help"
2169 }
2060 2170
2061 # People do all kinds of weird things. 2171 # People do all kinds of weird things.
2062 # http://forums.gentoo.org/viewtopic-p-3943166.html 2172 # http://forums.gentoo.org/viewtopic-p-3943166.html
2063 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2173 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2064 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2174 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2102 export CLASSPATH= 2212 export CLASSPATH=
2103 2213
2104 # Unset external ANT_ stuff 2214 # Unset external ANT_ stuff
2105 export ANT_TASKS= 2215 export ANT_TASKS=
2106 export ANT_OPTS= 2216 export ANT_OPTS=
2217 export ANT_RESPECT_JAVA_HOME=
2107} 2218}
2108 2219
2109# ------------------------------------------------------------------------------ 2220# ------------------------------------------------------------------------------
2110# @function-internal java-pkg-init-compiler_ 2221# @function-internal java-pkg-init-compiler_
2111# 2222#
2273 # Create package.env 2384 # Create package.env
2274 ( 2385 (
2275 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2386 echo "DESCRIPTION=\"${DESCRIPTION}\""
2276 echo "GENERATION=\"2\"" 2387 echo "GENERATION=\"2\""
2277 echo "SLOT=\"${SLOT}\"" 2388 echo "SLOT=\"${SLOT}\""
2389 echo "CATEGORY=\"${CATEGORY}\""
2390 echo "PVR=\"${PVR}\""
2278 2391
2279 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2392 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2280 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2393 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2281 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2394 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2282 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2395 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2283 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2396 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2284 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2397 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2285 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2398 && echo "OPTIONAL_DEPEND=\"$(sort -u "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | tr '\n' ':')\""
2286 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2399 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2400 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2401 && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
2287 ) > "${JAVA_PKG_ENV}" 2402 ) > "${JAVA_PKG_ENV}"
2288 2403
2289 # register target/source 2404 # register target/source
2290 local target="$(java-pkg_get-target)" 2405 local target="$(java-pkg_get-target)"
2291 local source="$(java-pkg_get-source)" 2406 local source="$(java-pkg_get-source)"
2324# ------------------------------------------------------------------------------ 2439# ------------------------------------------------------------------------------
2325# @internal-function java-pkg_record-jar_ 2440# @internal-function java-pkg_record-jar_
2326# 2441#
2327# Record an (optional) dependency to the package.env 2442# Record an (optional) dependency to the package.env
2328# @param --optional - record dependency as optional 2443# @param --optional - record dependency as optional
2444# @param --build - record dependency as build_only
2329# @param $1 - package to record 2445# @param $1 - package to record
2330# @param $2 - (optional) jar of package to record 2446# @param $2 - (optional) jar of package to record
2331# ------------------------------------------------------------------------------ 2447# ------------------------------------------------------------------------------
2332JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2448JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2333JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend" 2449JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2450JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2334 2451
2335java-pkg_record-jar_() { 2452java-pkg_record-jar_() {
2336 debug-print-function ${FUNCNAME} $* 2453 debug-print-function ${FUNCNAME} $*
2337 2454
2338 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2455 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2339 if [[ "${1}" == "--optional" ]]; then 2456 case "${1}" in
2340 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2457 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2341 shift 2458 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2342 fi 2459 esac
2343 2460
2344 local pkg=${1} jar=${2} append 2461 local pkg=${1} jar=${2} append
2345 if [[ -z "${jar}" ]]; then 2462 if [[ -z "${jar}" ]]; then
2346 append="${pkg}" 2463 append="${pkg}"
2347 else 2464 else
2400# 2517#
2401# @return 0 - function is declared 2518# @return 0 - function is declared
2402# @return 1 - function is undeclared 2519# @return 1 - function is undeclared
2403# ------------------------------------------------------------------------------ 2520# ------------------------------------------------------------------------------
2404java-pkg_func-exists() { 2521java-pkg_func-exists() {
2405 if [[ -n "$(declare -f ${1})" ]]; then 2522 declare -F ${1} > /dev/null
2406 return 0
2407 else
2408 return 1
2409 fi
2410} 2523}
2411 2524
2412# ------------------------------------------------------------------------------ 2525# ------------------------------------------------------------------------------
2413# @internal-function java-pkg_setup-vm 2526# @internal-function java-pkg_setup-vm
2414# 2527#
2415# Sets up the environment for a specific VM 2528# Sets up the environment for a specific VM
2416# 2529#
2417# ------------------------------------------------------------------------------ 2530# ------------------------------------------------------------------------------
2418java-pkg_setup-vm() { 2531java-pkg_setup-vm() {
2419 debug-print-function ${FUNCNAME} $* 2532 debug-print-function ${FUNCNAME} $*
2420
2421 export LANG="C" LC_ALL="C"
2422 2533
2423 local vendor="$(java-pkg_get-vm-vendor)" 2534 local vendor="$(java-pkg_get-vm-vendor)"
2424 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2535 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2425 addpredict "/dev/random" 2536 addpredict "/dev/random"
2426 elif [[ "${vendor}" == "ibm" ]]; then 2537 elif [[ "${vendor}" == "ibm" ]]; then
2427 addpredict "/proc/self/maps" 2538 addpredict "/proc/self/maps"
2428 addpredict "/proc/cpuinfo" 2539 addpredict "/proc/cpuinfo"
2540 addpredict "/proc/self/coredump_filter"
2541 elif [[ "${vendor}" == "oracle" ]]; then
2542 addpredict "/dev/random"
2543 addpredict "/proc/self/coredump_filter"
2544 elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then
2545 addpredict "/dev/random"
2546 addpredict "/proc/self/coredump_filter"
2429 elif [[ "${vendor}" == "jrockit" ]]; then 2547 elif [[ "${vendor}" == "jrockit" ]]; then
2430 addpredict "/proc/cpuinfo" 2548 addpredict "/proc/cpuinfo"
2431 fi 2549 fi
2432} 2550}
2433 2551
2434# ------------------------------------------------------------------------------ 2552# ------------------------------------------------------------------------------
2435# @internal-function java-pkg_needs-vm 2553# @internal-function java-pkg_needs-vm
2436# 2554#
2437# Does the current package depend on virtual/jdk? 2555# Does the current package depend on virtual/jdk or does it set
2556# JAVA_PKG_WANT_BUILD_VM?
2438# 2557#
2439# @return 0 - Package depends on virtual/jdk 2558# @return 0 - Package depends on virtual/jdk
2440# @return 1 - Package does not depend on virtual/jdk 2559# @return 1 - Package does not depend on virtual/jdk
2441# ------------------------------------------------------------------------------ 2560# ------------------------------------------------------------------------------
2442java-pkg_needs-vm() { 2561java-pkg_needs-vm() {
2443 debug-print-function ${FUNCNAME} $* 2562 debug-print-function ${FUNCNAME} $*
2444 2563
2445 if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then 2564 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2446 return 0 2565 return 0
2447 fi 2566 fi
2567
2568 [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0
2448 2569
2449 return 1 2570 return 1
2450} 2571}
2451 2572
2452# ------------------------------------------------------------------------------ 2573# ------------------------------------------------------------------------------
2478# ------------------------------------------------------------------------------ 2599# ------------------------------------------------------------------------------
2479java-pkg_get-vm-version() { 2600java-pkg_get-vm-version() {
2480 debug-print-function ${FUNCNAME} $* 2601 debug-print-function ${FUNCNAME} $*
2481 2602
2482 java-config -g PROVIDES_VERSION 2603 java-config -g PROVIDES_VERSION
2604}
2605
2606# ------------------------------------------------------------------------------
2607# @internal-function java-pkg_build-vm-from-handle
2608#
2609# Selects a build vm from a list of vm handles. First checks for the system-vm
2610# beeing usable, then steps through the listed handles till a suitable vm is
2611# found.
2612#
2613# @return - VM handle of an available JDK
2614# ------------------------------------------------------------------------------
2615java-pkg_build-vm-from-handle() {
2616 debug-print-function ${FUNCNAME} "$*"
2617
2618 local vm
2619 vm=$(java-pkg_get-current-vm)
2620 if [[ $? != 0 ]]; then
2621 eerror "${FUNCNAME}: Failed to get active vm"
2622 return 1
2623 fi
2624
2625 if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then
2626 echo ${vm}
2627 return 0
2628 fi
2629
2630 for vm in ${JAVA_PKG_WANT_BUILD_VM}; do
2631 if java-config-2 --select-vm=${vm} 2>/dev/null; then
2632 echo ${vm}
2633 return 0
2634 fi
2635 done
2636
2637 eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2638 return 1
2483} 2639}
2484 2640
2485# ------------------------------------------------------------------------------ 2641# ------------------------------------------------------------------------------
2486# @internal-function java-pkg_switch-vm 2642# @internal-function java-pkg_switch-vm
2487# 2643#
2498 # If you're forcing the VM, I hope you know what your doing... 2654 # If you're forcing the VM, I hope you know what your doing...
2499 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}" 2655 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2500 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2656 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2501 # if we're allowed to switch the vm... 2657 # if we're allowed to switch the vm...
2502 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2658 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
2503 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2659 # if there is an explicit list of handles to choose from
2504 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2660 if [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]]; then
2505 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2661 debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}"
2662 GENTOO_VM=$(java-pkg_build-vm-from-handle)
2663 if [[ $? != 0 ]]; then
2664 eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2665 die "${FUNCNAME}: Failed to determine VM for building"
2666 fi
2667 # JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET are required as
2668 # they can't be deduced from handles.
2669 if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then
2670 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE"
2671 die "Specify JAVA_PKG_WANT_SOURCE"
2672 fi
2673 if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then
2674 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET"
2675 die "Specify JAVA_PKG_WANT_TARGET"
2676 fi
2677 # otherwise determine a vm from dep string
2506 else 2678 else
2679 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2507 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2680 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2681 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2682 eerror "Unable to determine VM for building from dependencies:"
2683 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2684 die "Failed to determine VM for building."
2685 fi
2508 fi 2686 fi
2509 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2510 eerror "Unable to determine VM for building from dependencies:"
2511 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2512 echo "VNEED: ${JAVA_PKG_VNEED}"
2513 die "Failed to determine VM for building."
2514 else
2515 export GENTOO_VM 2687 export GENTOO_VM
2516 fi
2517 # otherwise just make sure the current VM is sufficient 2688 # otherwise just make sure the current VM is sufficient
2518 else 2689 else
2519 java-pkg_ensure-vm-version-sufficient 2690 java-pkg_ensure-vm-version-sufficient
2520 fi 2691 fi
2521 debug-print "Using: $(java-config -f)" 2692 debug-print "Using: $(java-config -f)"
2556# 2727#
2557# Enhanced die for Java packages, which displays some information that may be 2728# Enhanced die for Java packages, which displays some information that may be
2558# useful for debugging bugs on bugzilla. 2729# useful for debugging bugs on bugzilla.
2559# ------------------------------------------------------------------------------ 2730# ------------------------------------------------------------------------------
2560#register_die_hook java-pkg_die 2731#register_die_hook java-pkg_die
2561if ! hasq java-pkg_die ${EBUILD_DEATH_HOOKS}; then 2732if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
2562 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" 2733 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
2563fi 2734fi
2564 2735
2565java-pkg_die() { 2736java-pkg_die() {
2566 echo "!!! When you file a bug report, please include the following information:" >&2 2737 echo "!!! When you file a bug report, please include the following information:" >&2
2640 2811
2641 local limit_to="${1}" 2812 local limit_to="${1}"
2642 local target_pkg="${2}" 2813 local target_pkg="${2}"
2643 local dev_error="" 2814 local dev_error=""
2644 2815
2816 # remove the version specification, which may include globbing (* and [123])
2645 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2817 local stripped_pkg=$(echo "${target_pkg}" | sed \
2646 's/-[0-9]*\(\.[0-9]\)*$//') 2818 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//')
2647 2819
2648 debug-print "Matching against: ${stripped_pkg}" 2820 debug-print "Matching against: ${stripped_pkg}"
2649 2821
2650 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2822 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2651 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2823 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2701 java-pkg_announce-qa-violation "installing versioned jar '${jar}'" 2873 java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
2702 fi 2874 fi
2703} 2875}
2704 2876
2705java-pkg_check-jikes() { 2877java-pkg_check-jikes() {
2706 if hasq jikes ${IUSE}; then 2878 if has jikes ${IUSE}; then
2707 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2879 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2708 fi 2880 fi
2709} 2881}
2710 2882
2711java-pkg_announce-qa-violation() { 2883java-pkg_announce-qa-violation() {
2727is-java-strict() { 2899is-java-strict() {
2728 [[ -n ${JAVA_PKG_STRICT} ]] 2900 [[ -n ${JAVA_PKG_STRICT} ]]
2729 return $? 2901 return $?
2730} 2902}
2731 2903
2904
2732# ------------------------------------------------------------------------------ 2905# ------------------------------------------------------------------------------
2733# @eclass-end 2906# @eclass-end
2734# ------------------------------------------------------------------------------ 2907# ------------------------------------------------------------------------------

Legend:
Removed from v.1.110  
changed lines
  Added in v.1.150

  ViewVC Help
Powered by ViewVC 1.1.20