/[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.77 Revision 1.90
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.77 2007/04/24 10:26:33 caster Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.90 2007/06/19 21:08:57 caster Exp $
10
11 10
12# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
13# @eclass-begin 12# @eclass-begin
14# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
15# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
70# 69#
71# This is a convience variable to be used from the other java eclasses. This is 70# 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. We also need a recent version 71# the version of java-config we want to use. We also need a recent version
73# portage, that includes phase hooks. 72# portage, that includes phase hooks.
74# ----------------------------------------------------------------------------- 73# -----------------------------------------------------------------------------
75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.31 ${JAVA_PKG_PORTAGE_DEP}" 74JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.32 ${JAVA_PKG_PORTAGE_DEP}"
76 75
77# ----------------------------------------------------------------------------- 76# -----------------------------------------------------------------------------
78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 77# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
79# @variable-default yes 78# @variable-default yes
80# 79#
832# --build-only - makes the jar(s) not added into package.env DEPEND line. 831# --build-only - makes the jar(s) not added into package.env DEPEND line.
833# (assumed automatically when called inside src_test) 832# (assumed automatically when called inside src_test)
834# --with-dependencies - get jars also from requested package's dependencies 833# --with-dependencies - get jars also from requested package's dependencies
835# transitively. 834# transitively.
836# --into $dir - symlink jar(s) into $dir (must exist) instead of . 835# --into $dir - symlink jar(s) into $dir (must exist) instead of .
837# @param $1 - Package to get jars from. 836# @param $1 - Package to get jars from, or comma-separated list of packages in
837# case other parameters are not used.
838# @param $2 - jar from package. If not specified, all jars will be used. 838# @param $2 - jar from package. If not specified, all jars will be used.
839# @param $3 - When a single jar is specified, destination filename of the 839# @param $3 - When a single jar is specified, destination filename of the
840# symlink. Defaults to the name of the jar. 840# symlink. Defaults to the name of the jar.
841# ------------------------------------------------------------------------------ 841# ------------------------------------------------------------------------------
842# TODO could probably be cleaned up a little 842# TODO could probably be cleaned up a little
845 845
846 local build_only="" 846 local build_only=""
847 local destdir="." 847 local destdir="."
848 local deep="" 848 local deep=""
849 849
850 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true" 850 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
851 851
852 while [[ "${1}" == --* ]]; do 852 while [[ "${1}" == --* ]]; do
853 if [[ "${1}" = "--build-only" ]]; then 853 if [[ "${1}" = "--build-only" ]]; then
854 build_only="build" 854 build_only="build"
855 elif [[ "${1}" = "--with-dependencies" ]]; then 855 elif [[ "${1}" = "--with-dependencies" ]]; then
873 local error_msg="There was a problem getting the classpath for ${target_pkg}." 873 local error_msg="There was a problem getting the classpath for ${target_pkg}."
874 local classpath 874 local classpath
875 classpath="$(java-config ${deep} --classpath=${target_pkg})" 875 classpath="$(java-config ${deep} --classpath=${target_pkg})"
876 [[ $? != 0 ]] && die ${error_msg} 876 [[ $? != 0 ]] && die ${error_msg}
877 877
878 # When we have commas this functions is called to bring jars from multiple
879 # packages. This affects recording of dependencencies performed later
880 # which expects one package only, so we do it here.
881 if [[ ${target_pkg} = *,* ]]; then
882 for pkg in ${target_pkg//,/ }; do
883 java-pkg_ensure-dep "${build_only}" "${pkg}"
884 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}"
885 done
886 # setting this disables further record-jar_ calls later
887 build_only="build"
888 else
878 java-pkg_ensure-dep "${build_only}" "${target_pkg}" 889 java-pkg_ensure-dep "${build_only}" "${target_pkg}"
890 fi
879 891
880 pushd ${destdir} > /dev/null \ 892 pushd ${destdir} > /dev/null \
881 || die "failed to change directory to ${destdir}" 893 || die "failed to change directory to ${destdir}"
882
883 # When we have commas this functions is called to bring jars from multiple
884 # packages. This affects recording of dependencencies because that syntax uses :
885 # if we don't change them to : gjl and java-config -d -p break
886 if [[ ${target_pkg} = *,* ]]; then
887 build_only="true"
888 java-pkg_record-jar_ ${target_pkg//,/:}
889 fi
890 894
891 local jar 895 local jar
892 for jar in ${classpath//:/ }; do 896 for jar in ${classpath//:/ }; do
893 local jar_name=$(basename "${jar}") 897 local jar_name=$(basename "${jar}")
894 if [[ ! -f "${jar}" ]] ; then 898 if [[ ! -f "${jar}" ]] ; then
957 debug-print-function ${FUNCNAME} $* 961 debug-print-function ${FUNCNAME} $*
958 962
959 local build_only="" 963 local build_only=""
960 local deep="" 964 local deep=""
961 965
962 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true" 966 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
963 967
964 while [[ "${1}" == --* ]]; do 968 while [[ "${1}" == --* ]]; do
965 if [[ "${1}" = "--build-only" ]]; then 969 if [[ "${1}" = "--build-only" ]]; then
966 build_only="build" 970 build_only="build"
967 elif [[ "${1}" = "--with-dependencies" ]]; then 971 elif [[ "${1}" = "--with-dependencies" ]]; then
990 classpath="${classpath}:${jars}" 994 classpath="${classpath}:${jars}"
991 fi 995 fi
992 996
993 # Only record jars that aren't build-only 997 # Only record jars that aren't build-only
994 if [[ -z "${build_only}" ]]; then 998 if [[ -z "${build_only}" ]]; then
995 oldifs="${IFS}"
996 IFS=","
997 for pkg in ${pkgs}; do 999 for pkg in ${pkgs//,/ }; do
998 java-pkg_record-jar_ "${pkg}" 1000 java-pkg_record-jar_ "${pkg}"
999 done 1001 done
1000 IFS="${oldifs}"
1001 fi 1002 fi
1002 1003
1003 echo "${classpath}" 1004 echo "${classpath}"
1004} 1005}
1005 1006
1025java-pkg_getjar() { 1026java-pkg_getjar() {
1026 debug-print-function ${FUNCNAME} $* 1027 debug-print-function ${FUNCNAME} $*
1027 1028
1028 local build_only="" 1029 local build_only=""
1029 1030
1030 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="true" 1031 [[ "${EBUILD_PHASE}" == "test" ]] && build_only="build"
1031 1032
1032 while [[ "${1}" == --* ]]; do 1033 while [[ "${1}" == --* ]]; do
1033 if [[ "${1}" = "--build-only" ]]; then 1034 if [[ "${1}" = "--build-only" ]]; then
1034 build_only="build" 1035 build_only="build"
1035 else 1036 else
1075# from a package, into package.env DEPEND line. Can only be called in 1076# from a package, into package.env DEPEND line. Can only be called in
1076# src_install phase. 1077# src_install phase.
1077# Intended for binary packages where you don't need to symlink the jars or get 1078# Intended for binary packages where you don't need to symlink the jars or get
1078# their classpath during build. As such, the dependencies only need to be 1079# their classpath during build. As such, the dependencies only need to be
1079# specified in ebuild's RDEPEND, and should be omitted in DEPEND. 1080# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1080# Get the classpath provided by any number of packages.
1081# 1081#
1082# @param $1 - comma-separated list of packages, or a single package 1082# @param $1 - comma-separated list of packages, or a single package
1083# @param $2 - if param $1 is a single package, optionally specify the jar 1083# @param $2 - if param $1 is a single package, optionally specify the jar
1084# to depend on 1084# to depend on
1085# 1085#
1116 die "${FUNCNAME} called with both package list and jar name" 1116 die "${FUNCNAME} called with both package list and jar name"
1117 java-pkg_ensure-dep runtime "${pkgs}" 1117 java-pkg_ensure-dep runtime "${pkgs}"
1118 java-pkg_record-jar_ "${pkgs}" "${jar}" 1118 java-pkg_record-jar_ "${pkgs}" "${jar}"
1119 fi 1119 fi
1120 1120
1121 java-pkg_do_write_ 1121 java-pkg_do_write_
1122}
1123
1124# ------------------------------------------------------------------------------
1125# @ebuild-function java-pkg_register-optional-dependency
1126#
1127# Registers optional runtime dependency on a package, list of packages, or a
1128# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1129# called in src_install phase.
1130# Intended for packages that can use other packages when those are in classpath.
1131# Will be put on classpath by launcher if they are installed. Typical case is
1132# JDBC implementations for various databases. It's better than having USE flag
1133# for each implementation triggering hard dependency.
1134#
1135# @param $1 - comma-separated list of packages, or a single package
1136# @param $2 - if param $1 is a single package, optionally specify the jar
1137# to depend on
1138#
1139# Example: Record the optional dependency on some jdbc providers
1140# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1141#
1142# Note: Passing both list of packages as the first parameter AND specifying the
1143# jar as the second is not allowed and will cause the function to die. We assume
1144# that there's more chance one passes such combination as a mistake, than that
1145# there are more packages providing identically named jar without class
1146# collisions.
1147# ------------------------------------------------------------------------------
1148java-pkg_register-optional-dependency() {
1149 debug-print-function ${FUNCNAME} $*
1150
1151 java-pkg_check-phase install
1152
1153 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1154
1155 local pkgs="${1}"
1156 local jar="${2}"
1157
1158 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1159
1160 if [[ -z "${jar}" ]]; then
1161 for pkg in ${pkgs//,/ }; do
1162 java-pkg_record-jar_ --optional "${pkg}"
1163 done
1164 else
1165 [[ ${pkgs} == *,* ]] && \
1166 die "${FUNCNAME} called with both package list and jar name"
1167 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1168 fi
1169
1170 java-pkg_do_write_
1171}
1172
1173# ------------------------------------------------------------------------------
1174# @ebuild-function java-pkg_register-environment-variable
1175#
1176# Register an arbitrary environment variable into package.env. The gjl launcher
1177# for this package or any package depending on this will export it into
1178# environement before executing java command.
1179# Must only be called in src_install phase.
1180#
1181# @param $1 - variable name
1182# @param $2 - variable value
1183# ------------------------------------------------------------------------------
1184JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1185JAVA_PKG_EXTRA_ENV_VARS=""
1186java-pkg_register-environment-variable() {
1187 debug-print-function ${FUNCNAME} $*
1188
1189 java-pkg_check-phase install
1190
1191 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1192
1193 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1194 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1195
1196 java-pkg_do_write_
1122} 1197}
1123 1198
1124# This function reads stdin, and based on that input, figures out how to 1199# This function reads stdin, and based on that input, figures out how to
1125# populate jars from the filesystem. 1200# populate jars from the filesystem.
1126# Need to figure out a good way of making use of this, ie be able to use a 1201# Need to figure out a good way of making use of this, ie be able to use a
1614 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true 1689 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1615 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true 1690 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1616 done 1691 done
1617 1692
1618 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then 1693 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1619 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks" 1694 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1620 echo "all" 1695 echo "all"
1621 else 1696 else
1622 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant 1697 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1623 # so we deactivate all tasks that may be installed 1698 # so we deactivate all tasks that may be installed
1624 echo "none" 1699 echo "none"
1649 return 0 1724 return 0
1650 fi 1725 fi
1651} 1726}
1652 1727
1653# ------------------------------------------------------------------------------ 1728# ------------------------------------------------------------------------------
1729# @ebuild-function ejunit
1730#
1731# Junit wrapper function. Makes it easier to run the tests and checks for
1732# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1733#
1734# Examples:
1735# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1736# ejunit org.blinkenlights.jid3.test.AllTests
1737#
1738# @param $1 - -cp or -classpath
1739# @param $2 - classpath; junit and recorded dependencies get appended
1740# @param $@ - the rest of the parameters are passed to java
1741# ------------------------------------------------------------------------------
1742ejunit() {
1743 debug-print-function ${FUNCNAME} $*
1744
1745 local pkgs
1746 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1747 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1748 done
1749
1750 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1751 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1752 cp="${2}:${cp}"
1753 shift 2
1754 else
1755 cp=".:${cp}"
1756 fi
1757
1758 local runner=junit.textui.TestRunner
1759 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1760 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1761}
1762
1763# ------------------------------------------------------------------------------
1654# @section-end helper 1764# @section-end helper
1655# ------------------------------------------------------------------------------ 1765# ------------------------------------------------------------------------------
1656 1766
1657# ------------------------------------------------------------------------------ 1767# ------------------------------------------------------------------------------
1658# @section-begin build 1768# @section-begin build
1674# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1784# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1675# ------------------------------------------------------------------------------ 1785# ------------------------------------------------------------------------------
1676eant() { 1786eant() {
1677 debug-print-function ${FUNCNAME} $* 1787 debug-print-function ${FUNCNAME} $*
1678 1788
1679 # FIXME get this working
1680# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then
1681# java-pkg_announce-qa-violation \
1682# "Using eant, but not depending on dev-java/ant or dev-java/ant-core"
1683# fi
1684
1685 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then 1789 if ! hasq java-ant-2 ${INHERITED}; then
1686 local msg="You should inherit java-ant-2 when using eant" 1790 local msg="You should inherit java-ant-2 when using eant"
1687 java-pkg_announce-qa-violation ${msg} 1791 java-pkg_announce-qa-violation "${msg}"
1688 die ${msg}
1689 fi 1792 fi
1690 1793
1691 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1794 local antflags="-Dnoget=true -Dmaven.mode.offline=true"
1692 1795
1693 java-pkg_init-compiler_ 1796 java-pkg_init-compiler_
1731 echo "more info." 1834 echo "more info."
1732 fi 1835 fi
1733 fi 1836 fi
1734 done 1837 done
1735 1838
1839 # we use this in src_* so we run ant from /
1736 if has_version ">=dev-java/ant-core-1.7.0"; then 1840 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then
1737 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1841 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1738 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1842 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1739 1843
1740 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1844 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1741 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1845 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
2083# Writes the package.env out to disk. 2187# Writes the package.env out to disk.
2084# 2188#
2085# ------------------------------------------------------------------------------ 2189# ------------------------------------------------------------------------------
2086# TODO change to do-write, to match everything else 2190# TODO change to do-write, to match everything else
2087java-pkg_do_write_() { 2191java-pkg_do_write_() {
2192 debug-print-function ${FUNCNAME} $*
2088 java-pkg_init_paths_ 2193 java-pkg_init_paths_
2089 # Create directory for package.env 2194 # Create directory for package.env
2090 dodir "${JAVA_PKG_SHAREPATH}" 2195 dodir "${JAVA_PKG_SHAREPATH}"
2091 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2196 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2197 "${JAVA_PKG_DEPEND_FILE}" || -f \
2198 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2092 # Create package.env 2199 # Create package.env
2093 ( 2200 (
2094 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2201 echo "DESCRIPTION=\"${DESCRIPTION}\""
2095 echo "GENERATION=\"2\"" 2202 echo "GENERATION=\"2\""
2096 2203
2097 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2204 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2098 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2205 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2099 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2206 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2100 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2207 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2208 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2209 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2210 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2101 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2211 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2102 ) > "${JAVA_PKG_ENV}" 2212 ) > "${JAVA_PKG_ENV}"
2103 2213
2104 # register target/source 2214 # register target/source
2105 local target="$(java-pkg_get-target)" 2215 local target="$(java-pkg_get-target)"
2116 2226
2117 2227
2118 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2228 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
2119 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2229 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
2120 2230
2231 # extra env variables
2232 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2233 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2234 # nested echo to remove leading/trailing spaces
2235 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2236 >> "${JAVA_PKG_ENV}" || die
2237 fi
2238
2121 # Strip unnecessary leading and trailing colons 2239 # Strip unnecessary leading and trailing colons
2122 # TODO try to cleanup if possible 2240 # TODO try to cleanup if possible
2123 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2241 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2242 else
2243 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2244 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2245 debug-print "write package.env."
2124 fi 2246 fi
2125} 2247}
2126 2248
2127# ------------------------------------------------------------------------------ 2249# ------------------------------------------------------------------------------
2128# @internal-function java-pkg_record-jar_ 2250# @internal-function java-pkg_record-jar_
2129# 2251#
2130# Record a dependency to the package.env 2252# Record an (optional) dependency to the package.env
2131# 2253# @param --optional - record dependency as optional
2254# @param $1 - package to record
2255# @param $2 - (optional) jar of package to record
2132# ------------------------------------------------------------------------------ 2256# ------------------------------------------------------------------------------
2133JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2257JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2258JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2134 2259
2135java-pkg_record-jar_() { 2260java-pkg_record-jar_() {
2136 debug-print-function ${FUNCNAME} $* 2261 debug-print-function ${FUNCNAME} $*
2262
2263 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2264 if [[ "${1}" == "--optional" ]]; then
2265 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2266 shift
2267 fi
2137 2268
2138 local pkg=${1} jar=${2} append 2269 local pkg=${1} jar=${2} append
2139 if [[ -z "${jar}" ]]; then 2270 if [[ -z "${jar}" ]]; then
2140 append="${pkg}" 2271 append="${pkg}"
2141 else 2272 else
2142 append="$(basename ${jar})@${pkg}" 2273 append="$(basename ${jar})@${pkg}"
2143 fi 2274 fi
2144 2275
2145 echo ${append} >> ${JAVA_PKG_DEPEND} 2276 echo "${append}" >> "${depend_file}"
2146} 2277}
2147 2278
2148# ------------------------------------------------------------------------------ 2279# ------------------------------------------------------------------------------
2149# @internal-function java-pkg_append_ 2280# @internal-function java-pkg_append_
2150# 2281#
2210# 2341#
2211# ------------------------------------------------------------------------------ 2342# ------------------------------------------------------------------------------
2212java-pkg_setup-vm() { 2343java-pkg_setup-vm() {
2213 debug-print-function ${FUNCNAME} $* 2344 debug-print-function ${FUNCNAME} $*
2214 2345
2346 export LANG="C" LC_ALL="C"
2347
2215 local vendor="$(java-pkg_get-vm-vendor)" 2348 local vendor="$(java-pkg_get-vm-vendor)"
2216 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2349 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2217 addpredict "/dev/random" 2350 addpredict "/dev/random"
2218 elif [[ "${vendor}" == "ibm" ]]; then 2351 elif [[ "${vendor}" == "ibm" ]]; then
2219 addpredict "/proc/self/maps" 2352 addpredict "/proc/self/maps"
2220 addpredict "/proc/cpuinfo" 2353 addpredict "/proc/cpuinfo"
2221 export LANG="C" LC_ALL="C"
2222 elif [[ "${vendor}" == "jrockit" ]]; then 2354 elif [[ "${vendor}" == "jrockit" ]]; then
2223 addpredict "/proc/cpuinfo" 2355 addpredict "/proc/cpuinfo"
2224 fi 2356 fi
2225} 2357}
2226 2358
2414# Check that a package being used in jarfrom, getjars and getjar is contained 2546# Check that a package being used in jarfrom, getjars and getjar is contained
2415# within DEPEND or RDEPEND. 2547# within DEPEND or RDEPEND.
2416# @param $1 - empty - check both vars; "runtime" or "build" - check only 2548# @param $1 - empty - check both vars; "runtime" or "build" - check only
2417# RDEPEND, resp. DEPEND 2549# RDEPEND, resp. DEPEND
2418# @param $2 - Package name and slot. 2550# @param $2 - Package name and slot.
2551
2419java-pkg_ensure-dep() { 2552java-pkg_ensure-dep() {
2420 debug-print-function ${FUNCNAME} $* 2553 debug-print-function ${FUNCNAME} $*
2421 2554
2422 local limit_to="${1}" 2555 local limit_to="${1}"
2423 local target_pkg="${2}" 2556 local target_pkg="${2}"
2424 local dev_error="" 2557 local dev_error=""
2425 2558
2426 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2559 local stripped_pkg=$(echo "${target_pkg}" | sed \
2427 's/-[0-9]*\(\.[0-9]\)*$//') 2560 's/-[0-9]*\(\.[0-9]\)*$//')
2561
2562 debug-print "Matching against: ${stripped_pkg}"
2428 2563
2429 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2564 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2430 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2565 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2431 dev_error="${dev_error} declared in DEPEND." 2566 dev_error="${dev_error} declared in DEPEND."
2432 if is-java-strict; then 2567 if is-java-strict; then
2568 eerror "${dev_error}"
2433 die "${dev_error}" 2569 die "${dev_error}"
2434 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2570 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2435 eerror "${dev_error}" 2571 eerror "${dev_error}"
2436 elog "Because you have this package installed the package will" 2572 elog "Because you have this package installed the package will"
2437 elog "build without problems, but please report this to" 2573 elog "build without problems, but please report this to"
2438 elog "http://bugs.gentoo.org" 2574 elog "http://bugs.gentoo.org"
2439 fi 2575 fi
2440 fi 2576 fi
2441 2577
2578 if [[ ${limit_to} != build ]]; then
2442 if [[ ${limit_to} != build && ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then 2579 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2580 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2443 dev_error="The ebuild is attempting to use ${target_pkg}," 2581 dev_error="The ebuild is attempting to use ${target_pkg},"
2444 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND." 2582 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2583 dev_error="${dev_error} or PDEPEND."
2445 if is-java-strict; then 2584 if is-java-strict; then
2585 eerror "${dev_error}"
2446 die "${dev_error}" 2586 die "${dev_error}"
2447 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2587 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2448 eerror "${dev_error}" 2588 eerror "${dev_error}"
2449 elog "The package will build without problems, but may fail to run" 2589 elog "The package will build without problems, but may fail to run"
2450 elog "if you don't have ${target_pkg} installed, so please report" 2590 elog "if you don't have ${target_pkg} installed, so please report"
2451 elog "this to http://bugs.gentoo.org" 2591 elog "this to http://bugs.gentoo.org"
2592 fi
2593 fi
2452 fi 2594 fi
2453 fi 2595 fi
2454} 2596}
2455 2597
2456# ------------------------------------------------------------------------------ 2598# ------------------------------------------------------------------------------
2457# @section-end internal 2599# @section-end internal
2458# ------------------------------------------------------------------------------ 2600# ------------------------------------------------------------------------------
2459 2601
2460java-pkg_check-phase() { 2602java-pkg_check-phase() {
2461 local phase=${1} 2603 local phase=${1}
2462 local funcname=${2} 2604 local funcname=${FUNCNAME[1]}
2463 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then 2605 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
2464 java-pkg_announce-qa-violation \
2465 "${funcname} used outside of src_${phase}" 2606 local msg="${funcname} used outside of src_${phase}"
2607 java-pkg_announce-qa-violation "${msg}"
2466 fi 2608 fi
2467} 2609}
2468 2610
2469java-pkg_check-versioned-jar() { 2611java-pkg_check-versioned-jar() {
2470 local jar=${1} 2612 local jar=${1}
2479 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2621 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2480 fi 2622 fi
2481} 2623}
2482 2624
2483java-pkg_announce-qa-violation() { 2625java-pkg_announce-qa-violation() {
2484 if is-java-strict; then 2626 local nodie
2627 if [[ ${1} == "--nodie" ]]; then
2628 nodie="true"
2629 shift
2630 fi
2485 echo "Java QA Notice: $@" >&2 2631 echo "Java QA Notice: $@" >&2
2486 increment-qa-violations 2632 increment-qa-violations
2487 fi 2633 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
2488} 2634}
2489 2635
2490increment-qa-violations() { 2636increment-qa-violations() {
2491 let "JAVA_PKG_QA_VIOLATIONS+=1" 2637 let "JAVA_PKG_QA_VIOLATIONS+=1"
2492 export JAVA_PKG_QA_VIOLATIONS 2638 export JAVA_PKG_QA_VIOLATIONS

Legend:
Removed from v.1.77  
changed lines
  Added in v.1.90

  ViewVC Help
Powered by ViewVC 1.1.20