/[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.127 Revision 1.131
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-2005, 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.127 2009/05/19 21:23:32 caster Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.131 2010/01/17 12:53:18 betelgeuse 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
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.1.6 ${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 )" 76hasq 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#
872 889
873 local build_only="" 890 local build_only=""
874 local destdir="." 891 local destdir="."
875 local deep="" 892 local deep=""
876 local virtual="" 893 local virtual=""
894 local record_jar=""
877 895
878 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 896 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
879 897
880 while [[ "${1}" == --* ]]; do 898 while [[ "${1}" == --* ]]; do
881 if [[ "${1}" = "--build-only" ]]; then 899 if [[ "${1}" = "--build-only" ]]; then
916 for pkg in ${target_pkg//,/ }; do 934 for pkg in ${target_pkg//,/ }; do
917 java-pkg_ensure-dep "${build_only}" "${pkg}" 935 java-pkg_ensure-dep "${build_only}" "${pkg}"
918 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 936 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
919 done 937 done
920 # setting this disables further record-jar_ calls later 938 # setting this disables further record-jar_ calls later
921 build_only="build" 939 record_jar="true"
922 else 940 else
923 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 941 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
924 fi 942 fi
925 943
926 # Record the entire virtual as a dependency so that 944 # Record the entire virtual as a dependency so that
927 # no jars are missed. 945 # no jars are missed.
928 if [[ -z "${build_only}" && -n "${virtual}" ]]; then 946 if [[ -z "${build_only}" && -n "${virtual}" ]]; then
929 java-pkg_record-jar_ "${target_pkg}" 947 java-pkg_record-jar_ "${target_pkg}"
930 # setting this disables further record-jars_ calls later 948 # setting this disables further record-jars_ calls later
931 build_only="build" 949 record_jar="true"
932 fi 950 fi
933 951
934 pushd ${destdir} > /dev/null \ 952 pushd ${destdir} > /dev/null \
935 || die "failed to change directory to ${destdir}" 953 || die "failed to change directory to ${destdir}"
936 954
944 # If no specific target jar was indicated, link it 962 # If no specific target jar was indicated, link it
945 if [[ -z "${target_jar}" ]] ; then 963 if [[ -z "${target_jar}" ]] ; then
946 [[ -f "${target_jar}" ]] && rm "${target_jar}" 964 [[ -f "${target_jar}" ]] && rm "${target_jar}"
947 ln -snf "${jar}" \ 965 ln -snf "${jar}" \
948 || die "Failed to make symlink from ${jar} to ${jar_name}" 966 || die "Failed to make symlink from ${jar} to ${jar_name}"
967 if [[ -z "${record_jar}" ]]; then
968 if [[ -z "${build_only}" ]]; then
949 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 969 java-pkg_record-jar_ "${target_pkg}" "${jar}"
970 else
971 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
972 fi
973 fi
950 # otherwise, if the current jar is the target jar, link it 974 # otherwise, if the current jar is the target jar, link it
951 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 975 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
952 [[ -f "${destjar}" ]] && rm "${destjar}" 976 [[ -f "${destjar}" ]] && rm "${destjar}"
953 ln -snf "${jar}" "${destjar}" \ 977 ln -snf "${jar}" "${destjar}" \
954 || die "Failed to make symlink from ${jar} to ${destjar}" 978 || die "Failed to make symlink from ${jar} to ${destjar}"
979 if [[ -z "${record_jar}" ]]; then
980 if [[ -z "${build_only}" ]]; then
955 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${target_pkg}" "${jar}" 981 java-pkg_record-jar_ "${target_pkg}" "${jar}"
982 else
983 java-pkg_record-jar_ --build-only "${target_jar}" "${jar}"
984 fi
985 fi
956 popd > /dev/null 986 popd > /dev/null
957 return 0 987 return 0
958 fi 988 fi
959 done 989 done
960 popd > /dev/null 990 popd > /dev/null
1033 1063
1034 for pkg in ${pkgs//,/ }; do 1064 for pkg in ${pkgs//,/ }; do
1035 java-pkg_ensure-dep "${build_only}" "${pkg}" 1065 java-pkg_ensure-dep "${build_only}" "${pkg}"
1036 done 1066 done
1037 1067
1038 # Only record jars that aren't build-only 1068 for pkg in ${pkgs//,/ }; do
1039 if [[ -z "${build_only}" ]]; then 1069 if [[ -z "${build_only}" ]]; then
1040 for pkg in ${pkgs//,/ }; do
1041 java-pkg_record-jar_ "${pkg}" 1070 java-pkg_record-jar_ "${pkg}"
1071 else
1072 java-pkg_record-jar_ --build-only "${pkg}"
1073 fi
1042 done 1074 done
1043 fi
1044 1075
1045 echo "${jars}" 1076 echo "${jars}"
1046} 1077}
1047 1078
1048# ------------------------------------------------------------------------------ 1079# ------------------------------------------------------------------------------
1069java-pkg_getjar() { 1100java-pkg_getjar() {
1070 debug-print-function ${FUNCNAME} $* 1101 debug-print-function ${FUNCNAME} $*
1071 1102
1072 local build_only="" 1103 local build_only=""
1073 local virtual="" 1104 local virtual=""
1105 local record_jar=""
1074 1106
1075 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build" 1107 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1076 1108
1077 while [[ "${1}" == --* ]]; do 1109 while [[ "${1}" == --* ]]; do
1078 if [[ "${1}" = "--build-only" ]]; then 1110 if [[ "${1}" = "--build-only" ]]; then
1104 java-pkg_ensure-dep "${build_only}" "${pkg}" 1136 java-pkg_ensure-dep "${build_only}" "${pkg}"
1105 1137
1106 # Record the package(Virtual) as a dependency and then set build_only 1138 # Record the package(Virtual) as a dependency and then set build_only
1107 # So that individual jars are not recorded. 1139 # So that individual jars are not recorded.
1108 if [[ -n "${virtual}" ]]; then 1140 if [[ -n "${virtual}" ]]; then
1141 if [[ -z "${build_only}" ]]; then
1109 java-pkg_record-jar_ "${pkg}" 1142 java-pkg_record-jar_ "${pkg}"
1110 build_only="true" 1143 else
1144 java-pkg_record-jar_ --build-only "${pkg}"
1145 fi
1146 record_jar="true"
1111 fi 1147 fi
1112 1148
1113 for jar in ${classpath//:/ }; do 1149 for jar in ${classpath//:/ }; do
1114 if [[ ! -f "${jar}" ]] ; then 1150 if [[ ! -f "${jar}" ]] ; then
1115 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 1151 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
1116 fi 1152 fi
1117 1153
1118 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then 1154 if [[ "$(basename ${jar})" == "${target_jar}" ]] ; then
1119 # Only record jars that aren't build-only 1155 # Only record jars that aren't build-only
1120 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}" 1156 if [[ -z "${record_jar}" ]]; then
1157 if [[ -z "${build_only}" ]]; then
1158 java-pkg_record-jar_ "${pkg}" "${jar}"
1159 else
1160 java-pkg_record-jar_ --build-only "${pkg}" "${jar}"
1161 fi
1162 fi
1121 echo "${jar}" 1163 echo "${jar}"
1122 return 0 1164 return 0
1123 fi 1165 fi
1124 done 1166 done
1125 1167
1306# @section-begin helper 1348# @section-begin helper
1307# @section-summary Helper functions 1349# @section-summary Helper functions
1308# 1350#
1309# Various other functions to use from an ebuild 1351# Various other functions to use from an ebuild
1310# ------------------------------------------------------------------------------ 1352# ------------------------------------------------------------------------------
1311
1312# ------------------------------------------------------------------------------
1313# @ebuild-function java-pkg_need
1314#
1315# Adds virtual dependencies, which can optionally be controlled by a USE flag.
1316# Currently supported virtuals are:
1317# javamail
1318# jdbc-stdext
1319# jaf
1320# jdbc-rowset
1321# jms
1322#
1323# @param $1 - Optionally indicate that the dependencies are controlled by
1324# a use flag by specifying '--use' Requires $2.
1325# @param $2 - USE flag which will enable the dependencies.
1326# @param $@ - virtual packages to add depenedencies for
1327# ------------------------------------------------------------------------------
1328# TODO rewrite to parse a line based declaration file instead -- karltk
1329#java-pkg_need() {
1330# debug-print-function ${FUNCNAME} $*
1331# local useflag
1332# if [[ ${1} == "--use" ]]; then
1333# useflag="${2}"
1334# shift 2
1335# fi
1336#
1337# if [[ -z ${1} ]]; then
1338# die "Must specify at least one virtual package."
1339# fi
1340#
1341# local depstr newdepstr
1342#
1343# for virtual in ${@}; do
1344# if has ${virtual} ${JAVA_PKG_VNEED}; then
1345# debug-print "Already registered virtual ${virtual}"
1346# continue
1347# fi
1348# case ${virtual} in
1349# javamail)
1350# debug-print "java-pkg_need: adding javamail dependencies"
1351# newdepstr="|| ( dev-java/gnu-javamail dev-java/sun-javamail-bin )"
1352# ;;
1353# jdbc-stdext)
1354# debug-print "java-pkg_need: adding jdbc-stdext dependencies"
1355# newdepstr="|| ( >=virtual/jdk-1.4 dev-java/jdbc2-stdext )"
1356# ;;
1357# jaf)
1358# debug-print "java-pkg_need: adding jaf dependencies"
1359# newdepstr="|| ( dev-java/gnu-jaf dev-java/sun-jaf-bin )"
1360# ;;
1361# jdbc-rowset)
1362# debug-print "java-pkg_need: adding jdbc-rowset dependencies"
1363# newdepstr="|| ( >=virtual/jdk-1.5 dev-java/sun-jdbc-rowset )"
1364# ;;
1365# jms)
1366# debug-print "java-pkg_need: adding jms dependencies"
1367# newdepstr="|| ( dev-java/sun-jms dev-java/openjms )"
1368# ;;
1369# *)
1370# die "Invalid virtual: ${virtual}"
1371# esac
1372#
1373# export JAVA_PKG_VNEED="${JAVA_PKG_VNEED} ${virtual}"
1374#
1375# if [[ -n ${useflag} ]]; then
1376# depstr="${depstr} ${useflag}? ( ${newdepstr} )"
1377# else
1378# depstr="${depstr} ${newdepstr}"
1379# fi
1380# done
1381#
1382# [[ -z ${JAVA_PKG_NV_DEPEND} ]] && export JAVA_PKG_NV_DEPEND="${DEPEND}"
1383# [[ -z ${JAVA_PKG_NV_RDEPEND} ]] && export JAVA_PKG_NV_RDEPEND="${RDEPEND}"
1384#
1385# export DEPEND="${DEPEND} ${depstr}"
1386# export RDEPEND="${RDEPEND} ${depstr}"
1387#}
1388 1353
1389# ------------------------------------------------------------------------------ 1354# ------------------------------------------------------------------------------
1390# @ebuild-function java-pkg_find-normal-jars 1355# @ebuild-function java-pkg_find-normal-jars
1391# 1356#
1392# Find the files with suffix .jar file in the given directory or $WORKDIR 1357# Find the files with suffix .jar file in the given directory or $WORKDIR
2318 # Create package.env 2283 # Create package.env
2319 ( 2284 (
2320 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2285 echo "DESCRIPTION=\"${DESCRIPTION}\""
2321 echo "GENERATION=\"2\"" 2286 echo "GENERATION=\"2\""
2322 echo "SLOT=\"${SLOT}\"" 2287 echo "SLOT=\"${SLOT}\""
2288 echo "CATEGORY=\"${CATEGORY}\""
2289 echo "PVR=\"${PVR}\""
2323 2290
2324 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2291 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2325 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2292 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2326 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2293 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2327 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2294 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2328 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2295 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2329 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \ 2296 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2330 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\"" 2297 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2331 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2298 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2299 [[ -f "${JAVA_PKG_BUILD_DEPEND_FILE}" ]] \
2300 && echo "BUILD_DEPEND=\"$(cat "${JAVA_PKG_BUILD_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2332 ) > "${JAVA_PKG_ENV}" 2301 ) > "${JAVA_PKG_ENV}"
2333 2302
2334 # register target/source 2303 # register target/source
2335 local target="$(java-pkg_get-target)" 2304 local target="$(java-pkg_get-target)"
2336 local source="$(java-pkg_get-source)" 2305 local source="$(java-pkg_get-source)"
2369# ------------------------------------------------------------------------------ 2338# ------------------------------------------------------------------------------
2370# @internal-function java-pkg_record-jar_ 2339# @internal-function java-pkg_record-jar_
2371# 2340#
2372# Record an (optional) dependency to the package.env 2341# Record an (optional) dependency to the package.env
2373# @param --optional - record dependency as optional 2342# @param --optional - record dependency as optional
2343# @param --build - record dependency as build_only
2374# @param $1 - package to record 2344# @param $1 - package to record
2375# @param $2 - (optional) jar of package to record 2345# @param $2 - (optional) jar of package to record
2376# ------------------------------------------------------------------------------ 2346# ------------------------------------------------------------------------------
2377JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2347JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2378JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend" 2348JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2349JAVA_PKG_BUILD_DEPEND_FILE="${T}/java-pkg-build-depend"
2379 2350
2380java-pkg_record-jar_() { 2351java-pkg_record-jar_() {
2381 debug-print-function ${FUNCNAME} $* 2352 debug-print-function ${FUNCNAME} $*
2382 2353
2383 local depend_file="${JAVA_PKG_DEPEND_FILE}" 2354 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2384 if [[ "${1}" == "--optional" ]]; then 2355 case "${1}" in
2385 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}" 2356 "--optional") depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"; shift;;
2386 shift 2357 "--build-only") depend_file="${JAVA_PKG_BUILD_DEPEND_FILE}"; shift;;
2387 fi 2358 esac
2388 2359
2389 local pkg=${1} jar=${2} append 2360 local pkg=${1} jar=${2} append
2390 if [[ -z "${jar}" ]]; then 2361 if [[ -z "${jar}" ]]; then
2391 append="${pkg}" 2362 append="${pkg}"
2392 else 2363 else
2539 # If you're forcing the VM, I hope you know what your doing... 2510 # If you're forcing the VM, I hope you know what your doing...
2540 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}" 2511 debug-print "JAVA_PKG_FORCE_VM used: ${JAVA_PKG_FORCE_VM}"
2541 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 2512 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
2542 # if we're allowed to switch the vm... 2513 # if we're allowed to switch the vm...
2543 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 2514 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
2544 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 2515 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2545 if [[ -n ${JAVA_PKG_VNEED} ]]; then
2546 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2547 else
2548 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 2516 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
2549 fi
2550 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then 2517 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
2551 eerror "Unable to determine VM for building from dependencies:" 2518 eerror "Unable to determine VM for building from dependencies:"
2552 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}" 2519 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
2553 echo "VNEED: ${JAVA_PKG_VNEED}"
2554 die "Failed to determine VM for building." 2520 die "Failed to determine VM for building."
2555 else 2521 else
2556 export GENTOO_VM 2522 export GENTOO_VM
2557 fi 2523 fi
2558 # otherwise just make sure the current VM is sufficient 2524 # otherwise just make sure the current VM is sufficient

Legend:
Removed from v.1.127  
changed lines
  Added in v.1.131

  ViewVC Help
Powered by ViewVC 1.1.20