/[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.80 Revision 1.92
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.80 2007/04/26 23:32:12 caster Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.92 2007/08/05 08:17:05 betelgeuse 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
58#WANT_ANT_TASKS 57#WANT_ANT_TASKS
59 58
60# ----------------------------------------------------------------------------- 59# -----------------------------------------------------------------------------
61# @variable-internal JAVA_PKG_PORTAGE_DEP 60# @variable-internal JAVA_PKG_PORTAGE_DEP
62# 61#
63# The version of portage we need to function properly. At this moment it's 62# The version of portage we need to function properly. Previously it was
64# portage with phase hooks support. 63# portage with phase hooks support but now we use a version with proper env
64# saving.
65# ----------------------------------------------------------------------------- 65# -----------------------------------------------------------------------------
66JAVA_PKG_PORTAGE_DEP=">=sys-apps/portage-2.1_pre1" 66JAVA_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. We also need a recent version 72# the version of java-config we want to use. Usually the latest stable version
73# portage, that includes phase hooks. 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.31 ${JAVA_PKG_PORTAGE_DEP}" 75JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.33-r1 ${JAVA_PKG_PORTAGE_DEP}"
76 76
77# ----------------------------------------------------------------------------- 77# -----------------------------------------------------------------------------
78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE 78# @variable-external JAVA_PKG_ALLOW_VM_CHANGE
79# @variable-default yes 79# @variable-default yes
80# 80#
995 classpath="${classpath}:${jars}" 995 classpath="${classpath}:${jars}"
996 fi 996 fi
997 997
998 # Only record jars that aren't build-only 998 # Only record jars that aren't build-only
999 if [[ -z "${build_only}" ]]; then 999 if [[ -z "${build_only}" ]]; then
1000 for pkg in ${pkgs//:/ }; do 1000 for pkg in ${pkgs//,/ }; do
1001 java-pkg_record-jar_ "${pkg}" 1001 java-pkg_record-jar_ "${pkg}"
1002 done 1002 done
1003 fi 1003 fi
1004 1004
1005 echo "${classpath}" 1005 echo "${classpath}"
1077# from a package, into package.env DEPEND line. Can only be called in 1077# from a package, into package.env DEPEND line. Can only be called in
1078# src_install phase. 1078# src_install phase.
1079# Intended for binary packages where you don't need to symlink the jars or get 1079# Intended for binary packages where you don't need to symlink the jars or get
1080# their classpath during build. As such, the dependencies only need to be 1080# their classpath during build. As such, the dependencies only need to be
1081# specified in ebuild's RDEPEND, and should be omitted in DEPEND. 1081# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1082# Get the classpath provided by any number of packages.
1083# 1082#
1084# @param $1 - comma-separated list of packages, or a single package 1083# @param $1 - comma-separated list of packages, or a single package
1085# @param $2 - if param $1 is a single package, optionally specify the jar 1084# @param $2 - if param $1 is a single package, optionally specify the jar
1086# to depend on 1085# to depend on
1087# 1086#
1118 die "${FUNCNAME} called with both package list and jar name" 1117 die "${FUNCNAME} called with both package list and jar name"
1119 java-pkg_ensure-dep runtime "${pkgs}" 1118 java-pkg_ensure-dep runtime "${pkgs}"
1120 java-pkg_record-jar_ "${pkgs}" "${jar}" 1119 java-pkg_record-jar_ "${pkgs}" "${jar}"
1121 fi 1120 fi
1122 1121
1123 java-pkg_do_write_ 1122 java-pkg_do_write_
1123}
1124
1125# ------------------------------------------------------------------------------
1126# @ebuild-function java-pkg_register-optional-dependency
1127#
1128# Registers optional runtime dependency on a package, list of packages, or a
1129# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1130# called in src_install phase.
1131# Intended for packages that can use other packages when those are in classpath.
1132# Will be put on classpath by launcher if they are installed. Typical case is
1133# JDBC implementations for various databases. It's better than having USE flag
1134# for each implementation triggering hard dependency.
1135#
1136# @param $1 - comma-separated list of packages, or a single package
1137# @param $2 - if param $1 is a single package, optionally specify the jar
1138# to depend on
1139#
1140# Example: Record the optional dependency on some jdbc providers
1141# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1142#
1143# Note: Passing both list of packages as the first parameter AND specifying the
1144# jar as the second is not allowed and will cause the function to die. We assume
1145# that there's more chance one passes such combination as a mistake, than that
1146# there are more packages providing identically named jar without class
1147# collisions.
1148# ------------------------------------------------------------------------------
1149java-pkg_register-optional-dependency() {
1150 debug-print-function ${FUNCNAME} $*
1151
1152 java-pkg_check-phase install
1153
1154 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1155
1156 local pkgs="${1}"
1157 local jar="${2}"
1158
1159 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1160
1161 if [[ -z "${jar}" ]]; then
1162 for pkg in ${pkgs//,/ }; do
1163 java-pkg_record-jar_ --optional "${pkg}"
1164 done
1165 else
1166 [[ ${pkgs} == *,* ]] && \
1167 die "${FUNCNAME} called with both package list and jar name"
1168 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1169 fi
1170
1171 java-pkg_do_write_
1172}
1173
1174# ------------------------------------------------------------------------------
1175# @ebuild-function java-pkg_register-environment-variable
1176#
1177# Register an arbitrary environment variable into package.env. The gjl launcher
1178# for this package or any package depending on this will export it into
1179# environement before executing java command.
1180# Must only be called in src_install phase.
1181#
1182# @param $1 - variable name
1183# @param $2 - variable value
1184# ------------------------------------------------------------------------------
1185JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1186JAVA_PKG_EXTRA_ENV_VARS=""
1187java-pkg_register-environment-variable() {
1188 debug-print-function ${FUNCNAME} $*
1189
1190 java-pkg_check-phase install
1191
1192 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1193
1194 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1195 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1196
1197 java-pkg_do_write_
1124} 1198}
1125 1199
1126# This function reads stdin, and based on that input, figures out how to 1200# This function reads stdin, and based on that input, figures out how to
1127# populate jars from the filesystem. 1201# populate jars from the filesystem.
1128# Need to figure out a good way of making use of this, ie be able to use a 1202# Need to figure out a good way of making use of this, ie be able to use a
1616 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true 1690 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1617 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true 1691 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1618 done 1692 done
1619 1693
1620 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then 1694 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1621 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks" 1695 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1622 echo "all" 1696 echo "all"
1623 else 1697 else
1624 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant 1698 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant
1625 # so we deactivate all tasks that may be installed 1699 # so we deactivate all tasks that may be installed
1626 echo "none" 1700 echo "none"
1651 return 0 1725 return 0
1652 fi 1726 fi
1653} 1727}
1654 1728
1655# ------------------------------------------------------------------------------ 1729# ------------------------------------------------------------------------------
1730# @ebuild-function ejunit
1731#
1732# Junit wrapper function. Makes it easier to run the tests and checks for
1733# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1734#
1735# Examples:
1736# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1737# ejunit org.blinkenlights.jid3.test.AllTests
1738#
1739# @param $1 - -cp or -classpath
1740# @param $2 - classpath; junit and recorded dependencies get appended
1741# @param $@ - the rest of the parameters are passed to java
1742# ------------------------------------------------------------------------------
1743ejunit() {
1744 debug-print-function ${FUNCNAME} $*
1745
1746 local pkgs
1747 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1748 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1749 done
1750
1751 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1752 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1753 cp="${2}:${cp}"
1754 shift 2
1755 else
1756 cp=".:${cp}"
1757 fi
1758
1759 local runner=junit.textui.TestRunner
1760 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1761 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1762}
1763
1764# ------------------------------------------------------------------------------
1656# @section-end helper 1765# @section-end helper
1657# ------------------------------------------------------------------------------ 1766# ------------------------------------------------------------------------------
1658 1767
1659# ------------------------------------------------------------------------------ 1768# ------------------------------------------------------------------------------
1660# @section-begin build 1769# @section-begin build
1671# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1780# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1672# variables: 1781# variables:
1673# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1782# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1674# gentoo.classpath property. Be sure to call 1783# gentoo.classpath property. Be sure to call
1675# java-ant_rewrite-classpath in src_unpack. 1784# java-ant_rewrite-classpath in src_unpack.
1785# JAVA_PKG_NO_BUNDLED_SEARCH - Don't search for bundled jars or class files
1676# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1786# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1677# ------------------------------------------------------------------------------ 1787# ------------------------------------------------------------------------------
1678eant() { 1788eant() {
1679 debug-print-function ${FUNCNAME} $* 1789 debug-print-function ${FUNCNAME} $*
1680 1790
1681 # FIXME get this working 1791 if [[ ${EBUILD_PHASE} = compile ]]; then
1682# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1792 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can
1683# java-pkg_announce-qa-violation \ 1793 # finally get rid of the hooks without breaking stuff
1684# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 1794
1795 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1796 && java-ant_ignore-system-classes "${S}/build.xml"
1797
1798 if hasq java-ant-2 ${INHERITED}; then
1799 java-ant_bsfix
1800 fi
1801
1802 # eant can be called multiple times
1803 JAVA_PKG_BSFIX="off"
1804
1805 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1806 echo "Searching for bundled jars:"
1807 java-pkg_find-normal-jars || echo "None found."
1808 echo "Searching for bundled classes (no output if none found):"
1809 find "${WORKDIR}" -name "*.class"
1810 echo "Search done."
1811 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1812 fi
1685# fi 1813 fi
1686 1814
1687 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then 1815 if ! hasq java-ant-2 ${INHERITED}; then
1688 local msg="You should inherit java-ant-2 when using eant" 1816 local msg="You should inherit java-ant-2 when using eant"
1689 java-pkg_announce-qa-violation ${msg} 1817 java-pkg_announce-qa-violation "${msg}"
1690 die ${msg}
1691 fi 1818 fi
1692 1819
1693 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1820 local antflags="-Dnoget=true -Dmaven.mode.offline=true"
1694 1821
1695 java-pkg_init-compiler_ 1822 java-pkg_init-compiler_
1696 local compiler="${GENTOO_COMPILER}" 1823 local compiler="${GENTOO_COMPILER}"
1697 1824
1698 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1825 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1699
1700 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" 1826 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1701 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1827 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1702 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1828 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1703 fi 1829 fi
1704 1830
1733 echo "more info." 1859 echo "more info."
1734 fi 1860 fi
1735 fi 1861 fi
1736 done 1862 done
1737 1863
1864 # we use this in src_* so we run ant from /
1738 if has_version ">=dev-java/ant-core-1.7.0"; then 1865 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then
1739 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1866 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1740 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1867 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1741 1868
1742 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1869 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1743 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1870 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1914 unset _JAVA_OPTIONS 2041 unset _JAVA_OPTIONS
1915 # phase hooks make this run many times without this 2042 # phase hooks make this run many times without this
1916 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2043 I_WANT_GLOBAL_JAVA_OPTIONS="true"
1917 fi 2044 fi
1918 2045
2046 if java-pkg_func-exists ant_src_unpack; then
2047 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2048 fi
2049
1919 java-pkg_init_paths_ 2050 java-pkg_init_paths_
1920 java-pkg_switch-vm 2051 java-pkg_switch-vm
1921 PATH=${JAVA_HOME}/bin:${PATH} 2052 PATH=${JAVA_HOME}/bin:${PATH}
1922 2053
1923 # TODO we will probably want to set JAVAC and JAVACFLAGS 2054 # TODO we will probably want to set JAVAC and JAVACFLAGS
2085# Writes the package.env out to disk. 2216# Writes the package.env out to disk.
2086# 2217#
2087# ------------------------------------------------------------------------------ 2218# ------------------------------------------------------------------------------
2088# TODO change to do-write, to match everything else 2219# TODO change to do-write, to match everything else
2089java-pkg_do_write_() { 2220java-pkg_do_write_() {
2221 debug-print-function ${FUNCNAME} $*
2090 java-pkg_init_paths_ 2222 java-pkg_init_paths_
2091 # Create directory for package.env 2223 # Create directory for package.env
2092 dodir "${JAVA_PKG_SHAREPATH}" 2224 dodir "${JAVA_PKG_SHAREPATH}"
2093 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2225 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2226 "${JAVA_PKG_DEPEND_FILE}" || -f \
2227 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2094 # Create package.env 2228 # Create package.env
2095 ( 2229 (
2096 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2230 echo "DESCRIPTION=\"${DESCRIPTION}\""
2097 echo "GENERATION=\"2\"" 2231 echo "GENERATION=\"2\""
2098 2232
2099 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2233 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2100 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2234 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2101 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2235 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2102 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2236 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2237 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2238 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2239 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2103 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2240 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2104 ) > "${JAVA_PKG_ENV}" 2241 ) > "${JAVA_PKG_ENV}"
2105 2242
2106 # register target/source 2243 # register target/source
2107 local target="$(java-pkg_get-target)" 2244 local target="$(java-pkg_get-target)"
2118 2255
2119 2256
2120 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2257 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
2121 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2258 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
2122 2259
2260 # extra env variables
2261 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2262 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2263 # nested echo to remove leading/trailing spaces
2264 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2265 >> "${JAVA_PKG_ENV}" || die
2266 fi
2267
2123 # Strip unnecessary leading and trailing colons 2268 # Strip unnecessary leading and trailing colons
2124 # TODO try to cleanup if possible 2269 # TODO try to cleanup if possible
2125 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2270 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2271 else
2272 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2273 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2274 debug-print "write package.env."
2126 fi 2275 fi
2127} 2276}
2128 2277
2129# ------------------------------------------------------------------------------ 2278# ------------------------------------------------------------------------------
2130# @internal-function java-pkg_record-jar_ 2279# @internal-function java-pkg_record-jar_
2131# 2280#
2132# Record a dependency to the package.env 2281# Record an (optional) dependency to the package.env
2133# 2282# @param --optional - record dependency as optional
2283# @param $1 - package to record
2284# @param $2 - (optional) jar of package to record
2134# ------------------------------------------------------------------------------ 2285# ------------------------------------------------------------------------------
2135JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2286JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2287JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2136 2288
2137java-pkg_record-jar_() { 2289java-pkg_record-jar_() {
2138 debug-print-function ${FUNCNAME} $* 2290 debug-print-function ${FUNCNAME} $*
2291
2292 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2293 if [[ "${1}" == "--optional" ]]; then
2294 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2295 shift
2296 fi
2139 2297
2140 local pkg=${1} jar=${2} append 2298 local pkg=${1} jar=${2} append
2141 if [[ -z "${jar}" ]]; then 2299 if [[ -z "${jar}" ]]; then
2142 append="${pkg}" 2300 append="${pkg}"
2143 else 2301 else
2144 append="$(basename ${jar})@${pkg}" 2302 append="$(basename ${jar})@${pkg}"
2145 fi 2303 fi
2146 2304
2147 echo ${append} >> ${JAVA_PKG_DEPEND} 2305 echo "${append}" >> "${depend_file}"
2148} 2306}
2149 2307
2150# ------------------------------------------------------------------------------ 2308# ------------------------------------------------------------------------------
2151# @internal-function java-pkg_append_ 2309# @internal-function java-pkg_append_
2152# 2310#
2212# 2370#
2213# ------------------------------------------------------------------------------ 2371# ------------------------------------------------------------------------------
2214java-pkg_setup-vm() { 2372java-pkg_setup-vm() {
2215 debug-print-function ${FUNCNAME} $* 2373 debug-print-function ${FUNCNAME} $*
2216 2374
2375 export LANG="C" LC_ALL="C"
2376
2217 local vendor="$(java-pkg_get-vm-vendor)" 2377 local vendor="$(java-pkg_get-vm-vendor)"
2218 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2378 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2219 addpredict "/dev/random" 2379 addpredict "/dev/random"
2220 elif [[ "${vendor}" == "ibm" ]]; then 2380 elif [[ "${vendor}" == "ibm" ]]; then
2221 addpredict "/proc/self/maps" 2381 addpredict "/proc/self/maps"
2222 addpredict "/proc/cpuinfo" 2382 addpredict "/proc/cpuinfo"
2223 export LANG="C" LC_ALL="C"
2224 elif [[ "${vendor}" == "jrockit" ]]; then 2383 elif [[ "${vendor}" == "jrockit" ]]; then
2225 addpredict "/proc/cpuinfo" 2384 addpredict "/proc/cpuinfo"
2226 fi 2385 fi
2227} 2386}
2228 2387
2332 2491
2333 #TODO If you know a better solution let us know. 2492 #TODO If you know a better solution let us know.
2334 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2493 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2335 2494
2336 local tann="${T}/announced-vm" 2495 local tann="${T}/announced-vm"
2496 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2497 # if people have for example modified eclasses some where
2337 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2498 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
2338 # Add a check for setup/preinst phase... to avoid duplicate outputs
2339 # for when FEATURES=buildpkg
2340 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
2341 then
2342 einfo "Using: $(java-config -f)" 2499 einfo "Using: $(java-config -f)"
2343 [[ ! -f "${tann}" ]] && touch "${tann}" 2500 [[ ! -f "${tann}" ]] && touch "${tann}"
2344 fi
2345 fi 2501 fi
2346 2502
2347 else 2503 else
2348 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2504 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2349 fi 2505 fi
2416# Check that a package being used in jarfrom, getjars and getjar is contained 2572# Check that a package being used in jarfrom, getjars and getjar is contained
2417# within DEPEND or RDEPEND. 2573# within DEPEND or RDEPEND.
2418# @param $1 - empty - check both vars; "runtime" or "build" - check only 2574# @param $1 - empty - check both vars; "runtime" or "build" - check only
2419# RDEPEND, resp. DEPEND 2575# RDEPEND, resp. DEPEND
2420# @param $2 - Package name and slot. 2576# @param $2 - Package name and slot.
2577
2421java-pkg_ensure-dep() { 2578java-pkg_ensure-dep() {
2422 debug-print-function ${FUNCNAME} $* 2579 debug-print-function ${FUNCNAME} $*
2423 2580
2424 local limit_to="${1}" 2581 local limit_to="${1}"
2425 local target_pkg="${2}" 2582 local target_pkg="${2}"
2426 local dev_error="" 2583 local dev_error=""
2427 2584
2428 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2585 local stripped_pkg=$(echo "${target_pkg}" | sed \
2429 's/-[0-9]*\(\.[0-9]\)*$//') 2586 's/-[0-9]*\(\.[0-9]\)*$//')
2587
2588 debug-print "Matching against: ${stripped_pkg}"
2430 2589
2431 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2590 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2432 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2591 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2433 dev_error="${dev_error} declared in DEPEND." 2592 dev_error="${dev_error} declared in DEPEND."
2434 if is-java-strict; then 2593 if is-java-strict; then
2594 eerror "${dev_error}"
2435 die "${dev_error}" 2595 die "${dev_error}"
2436 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2596 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2437 eerror "${dev_error}" 2597 eerror "${dev_error}"
2438 elog "Because you have this package installed the package will" 2598 elog "Because you have this package installed the package will"
2439 elog "build without problems, but please report this to" 2599 elog "build without problems, but please report this to"
2440 elog "http://bugs.gentoo.org" 2600 elog "http://bugs.gentoo.org"
2441 fi 2601 fi
2442 fi 2602 fi
2443 2603
2604 if [[ ${limit_to} != build ]]; then
2444 if [[ ${limit_to} != build && ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then 2605 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2606 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2445 dev_error="The ebuild is attempting to use ${target_pkg}," 2607 dev_error="The ebuild is attempting to use ${target_pkg},"
2446 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND." 2608 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2609 dev_error="${dev_error} or PDEPEND."
2447 if is-java-strict; then 2610 if is-java-strict; then
2611 eerror "${dev_error}"
2448 die "${dev_error}" 2612 die "${dev_error}"
2449 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2613 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2450 eerror "${dev_error}" 2614 eerror "${dev_error}"
2451 elog "The package will build without problems, but may fail to run" 2615 elog "The package will build without problems, but may fail to run"
2452 elog "if you don't have ${target_pkg} installed, so please report" 2616 elog "if you don't have ${target_pkg} installed, so please report"
2453 elog "this to http://bugs.gentoo.org" 2617 elog "this to http://bugs.gentoo.org"
2618 fi
2619 fi
2454 fi 2620 fi
2455 fi 2621 fi
2456} 2622}
2457 2623
2458# ------------------------------------------------------------------------------ 2624# ------------------------------------------------------------------------------
2459# @section-end internal 2625# @section-end internal
2460# ------------------------------------------------------------------------------ 2626# ------------------------------------------------------------------------------
2461 2627
2462java-pkg_check-phase() { 2628java-pkg_check-phase() {
2463 local phase=${1} 2629 local phase=${1}
2464 local funcname=${2} 2630 local funcname=${FUNCNAME[1]}
2465 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then 2631 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
2466 java-pkg_announce-qa-violation \
2467 "${funcname} used outside of src_${phase}" 2632 local msg="${funcname} used outside of src_${phase}"
2633 java-pkg_announce-qa-violation "${msg}"
2468 fi 2634 fi
2469} 2635}
2470 2636
2471java-pkg_check-versioned-jar() { 2637java-pkg_check-versioned-jar() {
2472 local jar=${1} 2638 local jar=${1}
2481 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2647 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2482 fi 2648 fi
2483} 2649}
2484 2650
2485java-pkg_announce-qa-violation() { 2651java-pkg_announce-qa-violation() {
2486 if is-java-strict; then 2652 local nodie
2653 if [[ ${1} == "--nodie" ]]; then
2654 nodie="true"
2655 shift
2656 fi
2487 echo "Java QA Notice: $@" >&2 2657 echo "Java QA Notice: $@" >&2
2488 increment-qa-violations 2658 increment-qa-violations
2489 fi 2659 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
2490} 2660}
2491 2661
2492increment-qa-violations() { 2662increment-qa-violations() {
2493 let "JAVA_PKG_QA_VIOLATIONS+=1" 2663 let "JAVA_PKG_QA_VIOLATIONS+=1"
2494 export JAVA_PKG_QA_VIOLATIONS 2664 export JAVA_PKG_QA_VIOLATIONS

Legend:
Removed from v.1.80  
changed lines
  Added in v.1.92

  ViewVC Help
Powered by ViewVC 1.1.20