/[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.151
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.151 2012/07/05 20:07:47 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
1675 1684
1676 echo ${flags} 1685 echo ${flags}
1677} 1686}
1678 1687
1679java-pkg_ensure-gcj() { 1688java-pkg_ensure-gcj() {
1680 if ! built_with_use sys-devel/gcc gcj ; then 1689 # was enforcing sys-devel/gcc[gcj]
1681 ewarn 1690 die "${FUNCNAME} was removed. Use use-deps available as of EAPI 2 instead. #261562"
1682 ewarn "You must build gcc with the gcj support to build with gcj"
1683 ewarn
1684 ebeep 5
1685 die "No GCJ support found!"
1686 fi
1687} 1691}
1688 1692
1689java-pkg_ensure-test() { 1693java-pkg_ensure-test() {
1690 if hasq test ${FEATURES} && ! hasq -test ${FEATURES} \ 1694 # was enforcing USE=test if FEATURES=test
1691 && hasq test ${IUSE} && ! use test; 1695 die "${FUNCNAME} was removed. Package mangers handle this already. #278965"
1692 then
1693 eerror "You specified FEATURES=test, but USE=test is needed"
1694 eerror "to pull in the additional dependencies for testing"
1695 die "Need USE=test enabled"
1696 fi
1697} 1696}
1698 1697
1699# ------------------------------------------------------------------------------ 1698# ------------------------------------------------------------------------------
1700# @ebuild-function java-pkg_register-ant-task 1699# @ebuild-function java-pkg_register-ant-task
1701# 1700#
1759 else 1758 else
1760 return 0 1759 return 0
1761 fi 1760 fi
1762} 1761}
1763 1762
1763
1764# ------------------------------------------------------------------------------ 1764# ------------------------------------------------------------------------------
1765# @ebuild-function ejunit 1765# @internal-function ejunit_
1766# 1766#
1767# Junit wrapper function. Makes it easier to run the tests and checks for 1767# 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. 1768# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1769# 1769#
1770# Examples: 1770# @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 1771# @param $2 - -cp or -classpath
1775# @param $2 - classpath; junit and recorded dependencies get appended 1772# @param $3 - classpath; junit and recorded dependencies get appended
1776# @param $@ - the rest of the parameters are passed to java 1773# @param $@ - the rest of the parameters are passed to java
1777# ------------------------------------------------------------------------------
1778ejunit() { 1774ejunit_() {
1779 debug-print-function ${FUNCNAME} $* 1775 debug-print-function ${FUNCNAME} $*
1780 1776
1781 local pkgs 1777 local pkgs
1782 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then 1778 if [[ -f ${JAVA_PKG_DEPEND_FILE} ]]; then
1783 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do 1779 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1784 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//") 1780 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1785 done 1781 done
1786 fi 1782 fi
1787 1783
1784 local junit=${1}
1785 shift 1
1786
1788 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs}) 1787 local cp=$(java-pkg_getjars --with-dependencies ${junit}${pkgs})
1789 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1788 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1790 cp="${2}:${cp}" 1789 cp="${2}:${cp}"
1791 shift 2 1790 shift 2
1792 else 1791 else
1793 cp=".:${cp}" 1792 cp=".:${cp}"
1794 fi 1793 fi
1795 1794
1796 local runner=junit.textui.TestRunner 1795 local runner=junit.textui.TestRunner
1796 if [[ "${junit}" == "junit-4" ]] ; then
1797 runner=org.junit.runner.JUnitCore
1798 fi
1797 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1799 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1798 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" 1800 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1799} 1801}
1800 1802
1801# ------------------------------------------------------------------------------ 1803# ------------------------------------------------------------------------------
1804# @ebuild-function ejunit
1805#
1806# Junit wrapper function. Makes it easier to run the tests and checks for
1807# dev-java/junit in DEPEND. Launches the tests using org.junit.runner.JUnitCore.
1808#
1809# Examples:
1810# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1811# ejunit org.blinkenlights.jid3.test.AllTests
1812# ejunit org.blinkenlights.jid3.test.FirstTest \
1813# org.blinkenlights.jid3.test.SecondTest
1814#
1815# @param $1 - -cp or -classpath
1816# @param $2 - classpath; junit and recorded dependencies get appended
1817# @param $@ - the rest of the parameters are passed to java
1818# ------------------------------------------------------------------------------
1819ejunit() {
1820 debug-print-function ${FUNCNAME} $*
1821
1822 ejunit_ "junit" "${@}"
1823}
1824
1825# ------------------------------------------------------------------------------
1826# @ebuild-function ejunit4
1827#
1828# Junit4 wrapper function. Makes it easier to run the tests and checks for
1829# dev-java/junit:4 in DEPEND. Launches the tests using junit.textui.TestRunner.
1830#
1831# Examples:
1832# ejunit4 -cp build/classes org.blinkenlights.jid3.test.AllTests
1833# ejunit4 org.blinkenlights.jid3.test.AllTests
1834# ejunit4 org.blinkenlights.jid3.test.FirstTest \
1835# org.blinkenlights.jid3.test.SecondTest
1836#
1837# @param $1 - -cp or -classpath
1838# @param $2 - classpath; junit and recorded dependencies get appended
1839# @param $@ - the rest of the parameters are passed to java
1840# ------------------------------------------------------------------------------
1841ejunit4() {
1842 debug-print-function ${FUNCNAME} $*
1843
1844 ejunit_ "junit-4" "${@}"
1845}
1846
1847# ------------------------------------------------------------------------------
1802# @section-end helper 1848# @section-end helper
1803# ------------------------------------------------------------------------------ 1849# ------------------------------------------------------------------------------
1850
1851# ------------------------------------------------------------------------------
1852# @eclass-src_prepare
1853#
1854# src_prepare Searches for bundled jars
1855# Don't call directly, but via java-pkg-2_src_prepare!
1856# ------------------------------------------------------------------------------
1857
1858java-utils-2_src_prepare() {
1859 [[ ${EBUILD_PHASE} == prepare ]] &&
1860 java-pkg_func-exists java_prepare && java_prepare
1861
1862 # Remember that eant will call this unless called via Portage
1863 if [[ ! -e "${T}/java-utils-2_src_prepare-run" ]] && is-java-strict; then
1864 echo "Searching for bundled jars:"
1865 java-pkg_find-normal-jars || echo "None found."
1866 echo "Searching for bundled classes (no output if none found):"
1867 find "${WORKDIR}" -name "*.class"
1868 echo "Search done."
1869 fi
1870 touch "${T}/java-utils-2_src_prepare-run"
1871}
1872
1873# ------------------------------------------------------------------------------
1874# @eclass-pkg_preinst
1875#
1876# pkg_preinst Searches for missing and unneeded dependencies
1877# Don't call directly, but via java-pkg-2_pkg_preinst!
1878# ------------------------------------------------------------------------------
1879
1880java-utils-2_pkg_preinst() {
1881 if is-java-strict; then
1882 if has_version dev-java/java-dep-check; then
1883 [[ -e "${JAVA_PKG_ENV}" ]] || return
1884 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1885 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then
1886 ewarn "Possibly unneeded dependencies found in package.env:"
1887 for dep in ${output}; do
1888 ewarn "\t${dep}"
1889 done
1890 fi
1891 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1892 ewarn "${output}"
1893 fi
1894 else
1895 eerror "Install dev-java/java-dep-check for dependency checking"
1896 fi
1897 fi
1898}
1804 1899
1805# ------------------------------------------------------------------------------ 1900# ------------------------------------------------------------------------------
1806# @section-begin build 1901# @section-begin build
1807# @section-summary Build functions 1902# @section-summary Build functions
1808# 1903#
1817# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1912# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1818# variables: 1913# variables:
1819# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1914# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1820# gentoo.classpath property. Be sure to call 1915# gentoo.classpath property. Be sure to call
1821# java-ant_rewrite-classpath in src_unpack. 1916# java-ant_rewrite-classpath in src_unpack.
1822# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files 1917# EANT_NEEDS_TOOLS - add tools.jar to the gentoo.classpath. Should only be used
1918# for build-time purposes, the dependency is not recorded to
1919# package.env!
1823# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1920# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1824# ------------------------------------------------------------------------------ 1921# ------------------------------------------------------------------------------
1825eant() { 1922eant() {
1826 debug-print-function ${FUNCNAME} $* 1923 debug-print-function ${FUNCNAME} $*
1827 1924
1828 if [[ ${EBUILD_PHASE} = compile ]]; then 1925 if [[ ${EBUILD_PHASE} = compile ]]; then
1829 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can 1926 java-ant-2_src_configure
1830 # finally get rid of the hooks without breaking stuff 1927 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 1928 fi
1838 1929
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 1930 if ! has java-ant-2 ${INHERITED}; then
1853 local msg="You should inherit java-ant-2 when using eant" 1931 local msg="You should inherit java-ant-2 when using eant"
1854 java-pkg_announce-qa-violation "${msg}" 1932 java-pkg_announce-qa-violation "${msg}"
1855 fi 1933 fi
1856 1934
1857 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore" 1935 local antflags="-Dnoget=true -Dmaven.mode.offline=true -Dbuild.sysclasspath=ignore"
1932 2010
1933 if [[ ${EBUILD_PHASE} = "test" ]]; then 2011 if [[ ${EBUILD_PHASE} = "test" ]]; then
1934 antflags="${antflags} -DJunit.present=true" 2012 antflags="${antflags} -DJunit.present=true"
1935 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit" 2013 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1936 getjarsarg="--with-dependencies" 2014 getjarsarg="--with-dependencies"
2015 else
2016 antflags="${antflags} -Dmaven.test.skip=true"
1937 fi 2017 fi
1938 2018
1939 local cp 2019 local cp
1940 2020
1941 for atom in ${gcp}; do 2021 for atom in ${gcp}; do
1942 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})" 2022 cp="${cp}:$(java-pkg_getjars ${getjarsarg} ${atom})"
1943 done 2023 done
1944 2024
2025 [[ -n "${EANT_NEEDS_TOOLS}" ]] && cp="${cp}:$(java-config --tools)"
2026
1945 if [[ ${cp} ]]; then 2027 if [[ ${cp} ]]; then
1946 # It seems ant does not like single quotes around ${cp} 2028 # It seems ant does not like single quotes around ${cp}
2029 cp=${cp#:}
2030 [[ ${EANT_GENTOO_CLASSPATH_EXTRA} ]] && \
2031 cp="${cp}:${EANT_GENTOO_CLASSPATH_EXTRA}"
1947 antflags="${antflags} -Dgentoo.classpath=\"${cp#:}\"" 2032 antflags="${antflags} -Dgentoo.classpath=\"${cp}\""
1948 fi 2033 fi
1949 2034
1950 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 2035 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1951 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}" 2036 debug-print "Calling ant (GENTOO_VM: ${GENTOO_VM}): ${antflags} ${@}"
1952 ant ${antflags} "${@}" || die "eant failed" 2037 ant ${antflags} "${@}" || die "eant failed"
2053# call it during each of the phases of the merge process. 2138# call it during each of the phases of the merge process.
2054# 2139#
2055# ----------------------------------------------------------------------------- 2140# -----------------------------------------------------------------------------
2056java-pkg_init() { 2141java-pkg_init() {
2057 debug-print-function ${FUNCNAME} $* 2142 debug-print-function ${FUNCNAME} $*
2143
2144 # Don't set up build environment if installing from binary. #206024 #258423
2145 [[ "${MERGE_TYPE}" == "binary" ]] && return
2146 # Also try Portage's nonstandard EMERGE_FROM for old EAPIs, if it doesn't
2147 # work nothing is lost.
2148 has ${EAPI:-0} 0 1 2 3 && [[ "${EMERGE_FROM}" == "binary" ]] && return
2149
2058 unset JAVAC 2150 unset JAVAC
2059 unset JAVA_HOME 2151 unset JAVA_HOME
2152
2153 java-config --help >/dev/null || {
2154 eerror ""
2155 eerror "Can't run java-config --help"
2156 eerror "Have you upgraded python recently but haven't"
2157 eerror "run python-updater yet?"
2158 die "Can't run java-config --help"
2159 }
2060 2160
2061 # People do all kinds of weird things. 2161 # People do all kinds of weird things.
2062 # http://forums.gentoo.org/viewtopic-p-3943166.html 2162 # http://forums.gentoo.org/viewtopic-p-3943166.html
2063 local silence="${SILENCE_JAVA_OPTIONS_WARNING}" 2163 local silence="${SILENCE_JAVA_OPTIONS_WARNING}"
2064 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}" 2164 local accept="${I_WANT_GLOBAL_JAVA_OPTIONS}"
2102 export CLASSPATH= 2202 export CLASSPATH=
2103 2203
2104 # Unset external ANT_ stuff 2204 # Unset external ANT_ stuff
2105 export ANT_TASKS= 2205 export ANT_TASKS=
2106 export ANT_OPTS= 2206 export ANT_OPTS=
2207 export ANT_RESPECT_JAVA_HOME=
2107} 2208}
2108 2209
2109# ------------------------------------------------------------------------------ 2210# ------------------------------------------------------------------------------
2110# @function-internal java-pkg-init-compiler_ 2211# @function-internal java-pkg-init-compiler_
2111# 2212#
2273 # Create package.env 2374 # Create package.env
2274 ( 2375 (
2275 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2376 echo "DESCRIPTION=\"${DESCRIPTION}\""
2276 echo "GENERATION=\"2\"" 2377 echo "GENERATION=\"2\""
2277 echo "SLOT=\"${SLOT}\"" 2378 echo "SLOT=\"${SLOT}\""
2379 echo "CATEGORY=\"${CATEGORY}\""
2380 echo "PVR=\"${PVR}\""
2278 2381
2279 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2382 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2280 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2383 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2281 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2384 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2282 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2385 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2283 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2386 && echo "DEPEND=\"$(sort -u "${JAVA_PKG_DEPEND_FILE}" | tr '\n' ':')\""
2284 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2387 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2285 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2388 && 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 ! 2389 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2390 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2391 && echo "BUILD_DEPEND=\"$(sort -u "${JAVA_PKG_BUILD_DEPEND_FILE}" | tr '\n' ':')\""
2287 ) > "${JAVA_PKG_ENV}" 2392 ) > "${JAVA_PKG_ENV}"
2288 2393
2289 # register target/source 2394 # register target/source
2290 local target="$(java-pkg_get-target)" 2395 local target="$(java-pkg_get-target)"
2291 local source="$(java-pkg_get-source)" 2396 local source="$(java-pkg_get-source)"
2324# ------------------------------------------------------------------------------ 2429# ------------------------------------------------------------------------------
2325# @internal-function java-pkg_record-jar_ 2430# @internal-function java-pkg_record-jar_
2326# 2431#
2327# Record an (optional) dependency to the package.env 2432# Record an (optional) dependency to the package.env
2328# @param --optional - record dependency as optional 2433# @param --optional - record dependency as optional
2434# @param --build - record dependency as build_only
2329# @param $1 - package to record 2435# @param $1 - package to record
2330# @param $2 - (optional) jar of package to record 2436# @param $2 - (optional) jar of package to record
2331# ------------------------------------------------------------------------------ 2437# ------------------------------------------------------------------------------
2332JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2438JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2333JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend" 2439JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2440JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2334 2441
2335java-pkg_record-jar_() { 2442java-pkg_record-jar_() {
2336 debug-print-function ${FUNCNAME} $* 2443 debug-print-function ${FUNCNAME} $*
2337 2444
2338 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2445 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2339 if [[ "${1}" == "--optional" ]]; then 2446 case "${1}" in
2340 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2447 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2341 shift 2448 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2342 fi 2449 esac
2343 2450
2344 local pkg=${1} jar=${2} append 2451 local pkg=${1} jar=${2} append
2345 if [[ -z "${jar}" ]]; then 2452 if [[ -z "${jar}" ]]; then
2346 append="${pkg}" 2453 append="${pkg}"
2347 else 2454 else
2400# 2507#
2401# @return 0 - function is declared 2508# @return 0 - function is declared
2402# @return 1 - function is undeclared 2509# @return 1 - function is undeclared
2403# ------------------------------------------------------------------------------ 2510# ------------------------------------------------------------------------------
2404java-pkg_func-exists() { 2511java-pkg_func-exists() {
2405 if [[ -n "$(declare -f ${1})" ]]; then 2512 declare -F ${1} > /dev/null
2406 return 0
2407 else
2408 return 1
2409 fi
2410} 2513}
2411 2514
2412# ------------------------------------------------------------------------------ 2515# ------------------------------------------------------------------------------
2413# @internal-function java-pkg_setup-vm 2516# @internal-function java-pkg_setup-vm
2414# 2517#
2415# Sets up the environment for a specific VM 2518# Sets up the environment for a specific VM
2416# 2519#
2417# ------------------------------------------------------------------------------ 2520# ------------------------------------------------------------------------------
2418java-pkg_setup-vm() { 2521java-pkg_setup-vm() {
2419 debug-print-function ${FUNCNAME} $* 2522 debug-print-function ${FUNCNAME} $*
2420
2421 export LANG="C" LC_ALL="C"
2422 2523
2423 local vendor="$(java-pkg_get-vm-vendor)" 2524 local vendor="$(java-pkg_get-vm-vendor)"
2424 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2525 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2425 addpredict "/dev/random" 2526 addpredict "/dev/random"
2426 elif [[ "${vendor}" == "ibm" ]]; then 2527 elif [[ "${vendor}" == "ibm" ]]; then
2427 addpredict "/proc/self/maps" 2528 addpredict "/proc/self/maps"
2428 addpredict "/proc/cpuinfo" 2529 addpredict "/proc/cpuinfo"
2530 addpredict "/proc/self/coredump_filter"
2531 elif [[ "${vendor}" == "oracle" ]]; then
2532 addpredict "/dev/random"
2533 addpredict "/proc/self/coredump_filter"
2534 elif [[ "${vendor}" == icedtea* ]] && java-pkg_is-vm-version-ge "1.7" ; then
2535 addpredict "/dev/random"
2536 addpredict "/proc/self/coredump_filter"
2429 elif [[ "${vendor}" == "jrockit" ]]; then 2537 elif [[ "${vendor}" == "jrockit" ]]; then
2430 addpredict "/proc/cpuinfo" 2538 addpredict "/proc/cpuinfo"
2431 fi 2539 fi
2432} 2540}
2433 2541
2434# ------------------------------------------------------------------------------ 2542# ------------------------------------------------------------------------------
2435# @internal-function java-pkg_needs-vm 2543# @internal-function java-pkg_needs-vm
2436# 2544#
2437# Does the current package depend on virtual/jdk? 2545# Does the current package depend on virtual/jdk or does it set
2546# JAVA_PKG_WANT_BUILD_VM?
2438# 2547#
2439# @return 0 - Package depends on virtual/jdk 2548# @return 0 - Package depends on virtual/jdk
2440# @return 1 - Package does not depend on virtual/jdk 2549# @return 1 - Package does not depend on virtual/jdk
2441# ------------------------------------------------------------------------------ 2550# ------------------------------------------------------------------------------
2442java-pkg_needs-vm() { 2551java-pkg_needs-vm() {
2443 debug-print-function ${FUNCNAME} $* 2552 debug-print-function ${FUNCNAME} $*
2444 2553
2445 if [[ -n "$(echo ${DEPEND} | sed -e '\:virtual/jdk:!d')" ]]; then 2554 if [[ -n "$(echo ${JAVA_PKG_NV_DEPEND:-${DEPEND}} | sed -e '\:virtual/jdk:!d')" ]]; then
2446 return 0 2555 return 0
2447 fi 2556 fi
2557
2558 [[ -n "${JAVA_PKG_WANT_BUILD_VM}" ]] && return 0
2448 2559
2449 return 1 2560 return 1
2450} 2561}
2451 2562
2452# ------------------------------------------------------------------------------ 2563# ------------------------------------------------------------------------------
2478# ------------------------------------------------------------------------------ 2589# ------------------------------------------------------------------------------
2479java-pkg_get-vm-version() { 2590java-pkg_get-vm-version() {
2480 debug-print-function ${FUNCNAME} $* 2591 debug-print-function ${FUNCNAME} $*
2481 2592
2482 java-config -g PROVIDES_VERSION 2593 java-config -g PROVIDES_VERSION
2594}
2595
2596# ------------------------------------------------------------------------------
2597# @internal-function java-pkg_build-vm-from-handle
2598#
2599# Selects a build vm from a list of vm handles. First checks for the system-vm
2600# beeing usable, then steps through the listed handles till a suitable vm is
2601# found.
2602#
2603# @return - VM handle of an available JDK
2604# ------------------------------------------------------------------------------
2605java-pkg_build-vm-from-handle() {
2606 debug-print-function ${FUNCNAME} "$*"
2607
2608 local vm
2609 vm=$(java-pkg_get-current-vm)
2610 if [[ $? != 0 ]]; then
2611 eerror "${FUNCNAME}: Failed to get active vm"
2612 return 1
2613 fi
2614
2615 if has ${vm} ${JAVA_PKG_WANT_BUILD_VM}; then
2616 echo ${vm}
2617 return 0
2618 fi
2619
2620 for vm in ${JAVA_PKG_WANT_BUILD_VM}; do
2621 if java-config-2 --select-vm=${vm} 2>/dev/null; then
2622 echo ${vm}
2623 return 0
2624 fi
2625 done
2626
2627 eerror "${FUNCNAME}: No vm found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2628 return 1
2483} 2629}
2484 2630
2485# ------------------------------------------------------------------------------ 2631# ------------------------------------------------------------------------------
2486# @internal-function java-pkg_switch-vm 2632# @internal-function java-pkg_switch-vm
2487# 2633#
2498 # If you're forcing the VM, I hope you know what your doing... 2644 # 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}" 2645 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2500 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2646 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2501 # if we're allowed to switch the vm... 2647 # if we're allowed to switch the vm...
2502 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2648 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}" 2649 # if there is an explicit list of handles to choose from
2504 if [[ -n ${JAVA_PKG_VNEED} ]]; then 2650 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}}")" 2651 debug-print "JAVA_PKG_WANT_BUILD_VM used: ${JAVA_PKG_WANT_BUILD_VM}"
2652 GENTOO_VM=$(java-pkg_build-vm-from-handle)
2653 if [[ $? != 0 ]]; then
2654 eerror "${FUNCNAME}: No VM found for handles: ${JAVA_PKG_WANT_BUILD_VM}"
2655 die "${FUNCNAME}: Failed to determine VM for building"
2656 fi
2657 # JAVA_PKG_WANT_SOURCE and JAVA_PKG_WANT_TARGET are required as
2658 # they can't be deduced from handles.
2659 if [[ -z "${JAVA_PKG_WANT_SOURCE}" ]]; then
2660 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_SOURCE"
2661 die "Specify JAVA_PKG_WANT_SOURCE"
2662 fi
2663 if [[ -z "${JAVA_PKG_WANT_TARGET}" ]]; then
2664 eerror "JAVA_PKG_WANT_BUILD_VM specified but not JAVA_PKG_WANT_TARGET"
2665 die "Specify JAVA_PKG_WANT_TARGET"
2666 fi
2667 # otherwise determine a vm from dep string
2506 else 2668 else
2669 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}}")" 2670 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2671 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2672 eerror "Unable to determine VM for building from dependencies:"
2673 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2674 die "Failed to determine VM for building."
2675 fi
2508 fi 2676 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 2677 export GENTOO_VM
2516 fi
2517 # otherwise just make sure the current VM is sufficient 2678 # otherwise just make sure the current VM is sufficient
2518 else 2679 else
2519 java-pkg_ensure-vm-version-sufficient 2680 java-pkg_ensure-vm-version-sufficient
2520 fi 2681 fi
2521 debug-print "Using: $(java-config -f)" 2682 debug-print "Using: $(java-config -f)"
2556# 2717#
2557# Enhanced die for Java packages, which displays some information that may be 2718# Enhanced die for Java packages, which displays some information that may be
2558# useful for debugging bugs on bugzilla. 2719# useful for debugging bugs on bugzilla.
2559# ------------------------------------------------------------------------------ 2720# ------------------------------------------------------------------------------
2560#register_die_hook java-pkg_die 2721#register_die_hook java-pkg_die
2561if ! hasq java-pkg_die ${EBUILD_DEATH_HOOKS}; then 2722if ! has java-pkg_die ${EBUILD_DEATH_HOOKS}; then
2562 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die" 2723 EBUILD_DEATH_HOOKS="${EBUILD_DEATH_HOOKS} java-pkg_die"
2563fi 2724fi
2564 2725
2565java-pkg_die() { 2726java-pkg_die() {
2566 echo "!!! When you file a bug report, please include the following information:" >&2 2727 echo "!!! When you file a bug report, please include the following information:" >&2
2640 2801
2641 local limit_to="${1}" 2802 local limit_to="${1}"
2642 local target_pkg="${2}" 2803 local target_pkg="${2}"
2643 local dev_error="" 2804 local dev_error=""
2644 2805
2806 # remove the version specification, which may include globbing (* and [123])
2645 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2807 local stripped_pkg=$(echo "${target_pkg}" | sed \
2646 's/-[0-9]*\(\.[0-9]\)*$//') 2808 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//')
2647 2809
2648 debug-print "Matching against: ${stripped_pkg}" 2810 debug-print "Matching against: ${stripped_pkg}"
2649 2811
2650 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2812 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2651 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2813 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2701 java-pkg_announce-qa-violation "installing versioned jar '${jar}'" 2863 java-pkg_announce-qa-violation "installing versioned jar '${jar}'"
2702 fi 2864 fi
2703} 2865}
2704 2866
2705java-pkg_check-jikes() { 2867java-pkg_check-jikes() {
2706 if hasq jikes ${IUSE}; then 2868 if has jikes ${IUSE}; then
2707 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2869 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2708 fi 2870 fi
2709} 2871}
2710 2872
2711java-pkg_announce-qa-violation() { 2873java-pkg_announce-qa-violation() {
2727is-java-strict() { 2889is-java-strict() {
2728 [[ -n ${JAVA_PKG_STRICT} ]] 2890 [[ -n ${JAVA_PKG_STRICT} ]]
2729 return $? 2891 return $?
2730} 2892}
2731 2893
2894
2732# ------------------------------------------------------------------------------ 2895# ------------------------------------------------------------------------------
2733# @eclass-end 2896# @eclass-end
2734# ------------------------------------------------------------------------------ 2897# ------------------------------------------------------------------------------

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

  ViewVC Help
Powered by ViewVC 1.1.20