/[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.83 Revision 1.93
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.83 2007/05/04 17:20:08 caster Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.93 2007/09/27 19:47:08 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#
195# 195#
196# @example 196# @example
197# java-pkg_doexamples demo 197# java-pkg_doexamples demo
198# java-pkg_doexamples demo/* examples/* 198# java-pkg_doexamples demo/* examples/*
199# 199#
200# @param --subdir - If the examples need a certain directory structure
200# @param $* - list of files to install 201# @param $* - list of files to install
201# ------------------------------------------------------------------------------ 202# ------------------------------------------------------------------------------
202java-pkg_doexamples() { 203java-pkg_doexamples() {
203 debug-print-function ${FUNCNAME} $* 204 debug-print-function ${FUNCNAME} $*
204 205
205 [[ ${#} -lt 1 ]] && die "At least one argument needed" 206 [[ ${#} -lt 1 ]] && die "At least one argument needed"
206 207
207 java-pkg_check-phase install 208 java-pkg_check-phase install
208 209
209 local dest=/usr/share/doc/${PF}/examples 210 local dest=/usr/share/doc/${PF}/examples
211 if [[ ${1} == --subdir ]]; then
212 local dest=${dest}/${2}
213 dodir ${dest}
214 shift 2
215 fi
216
210 if [[ ${#} = 1 && -d ${1} ]]; then 217 if [[ ${#} = 1 && -d ${1} ]]; then
211 ( # dont want to pollute calling env 218 ( # dont want to pollute calling env
212 insinto "${dest}" 219 insinto "${dest}"
213 doins -r ${1}/* 220 doins -r ${1}/*
214 ) || die "Installing examples failed" 221 ) || die "Installing examples failed"
1077# from a package, into package.env DEPEND line. Can only be called in 1084# from a package, into package.env DEPEND line. Can only be called in
1078# src_install phase. 1085# src_install phase.
1079# Intended for binary packages where you don't need to symlink the jars or get 1086# 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 1087# their classpath during build. As such, the dependencies only need to be
1081# specified in ebuild's RDEPEND, and should be omitted in DEPEND. 1088# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1082# Get the classpath provided by any number of packages.
1083# 1089#
1084# @param $1 - comma-separated list of packages, or a single package 1090# @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 1091# @param $2 - if param $1 is a single package, optionally specify the jar
1086# to depend on 1092# to depend on
1087# 1093#
1118 die "${FUNCNAME} called with both package list and jar name" 1124 die "${FUNCNAME} called with both package list and jar name"
1119 java-pkg_ensure-dep runtime "${pkgs}" 1125 java-pkg_ensure-dep runtime "${pkgs}"
1120 java-pkg_record-jar_ "${pkgs}" "${jar}" 1126 java-pkg_record-jar_ "${pkgs}" "${jar}"
1121 fi 1127 fi
1122 1128
1123 java-pkg_do_write_ 1129 java-pkg_do_write_
1130}
1131
1132# ------------------------------------------------------------------------------
1133# @ebuild-function java-pkg_register-optional-dependency
1134#
1135# Registers optional runtime dependency on a package, list of packages, or a
1136# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1137# called in src_install phase.
1138# Intended for packages that can use other packages when those are in classpath.
1139# Will be put on classpath by launcher if they are installed. Typical case is
1140# JDBC implementations for various databases. It's better than having USE flag
1141# for each implementation triggering hard dependency.
1142#
1143# @param $1 - comma-separated list of packages, or a single package
1144# @param $2 - if param $1 is a single package, optionally specify the jar
1145# to depend on
1146#
1147# Example: Record the optional dependency on some jdbc providers
1148# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1149#
1150# Note: Passing both list of packages as the first parameter AND specifying the
1151# jar as the second is not allowed and will cause the function to die. We assume
1152# that there's more chance one passes such combination as a mistake, than that
1153# there are more packages providing identically named jar without class
1154# collisions.
1155# ------------------------------------------------------------------------------
1156java-pkg_register-optional-dependency() {
1157 debug-print-function ${FUNCNAME} $*
1158
1159 java-pkg_check-phase install
1160
1161 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1162
1163 local pkgs="${1}"
1164 local jar="${2}"
1165
1166 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1167
1168 if [[ -z "${jar}" ]]; then
1169 for pkg in ${pkgs//,/ }; do
1170 java-pkg_record-jar_ --optional "${pkg}"
1171 done
1172 else
1173 [[ ${pkgs} == *,* ]] && \
1174 die "${FUNCNAME} called with both package list and jar name"
1175 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1176 fi
1177
1178 java-pkg_do_write_
1179}
1180
1181# ------------------------------------------------------------------------------
1182# @ebuild-function java-pkg_register-environment-variable
1183#
1184# Register an arbitrary environment variable into package.env. The gjl launcher
1185# for this package or any package depending on this will export it into
1186# environement before executing java command.
1187# Must only be called in src_install phase.
1188#
1189# @param $1 - variable name
1190# @param $2 - variable value
1191# ------------------------------------------------------------------------------
1192JAVA_PKG_EXTRA_ENV="${T}/java-pkg-extra-env"
1193JAVA_PKG_EXTRA_ENV_VARS=""
1194java-pkg_register-environment-variable() {
1195 debug-print-function ${FUNCNAME} $*
1196
1197 java-pkg_check-phase install
1198
1199 [[ ${#} != 2 ]] && die "${FUNCNAME} takes two arguments"
1200
1201 echo "${1}=\"${2}\"" >> ${JAVA_PKG_EXTRA_ENV}
1202 JAVA_PKG_EXTRA_ENV_VARS="${JAVA_PKG_EXTRA_ENV_VARS} ${1}"
1203
1204 java-pkg_do_write_
1124} 1205}
1125 1206
1126# This function reads stdin, and based on that input, figures out how to 1207# This function reads stdin, and based on that input, figures out how to
1127# populate jars from the filesystem. 1208# populate jars from the filesystem.
1128# Need to figure out a good way of making use of this, ie be able to use a 1209# Need to figure out a good way of making use of this, ie be able to use a
1651 return 0 1732 return 0
1652 fi 1733 fi
1653} 1734}
1654 1735
1655# ------------------------------------------------------------------------------ 1736# ------------------------------------------------------------------------------
1737# @ebuild-function ejunit
1738#
1739# Junit wrapper function. Makes it easier to run the tests and checks for
1740# dev-java/junit in DEPEND. Launches the tests using junit.textui.TestRunner.
1741#
1742# Examples:
1743# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1744# ejunit org.blinkenlights.jid3.test.AllTests
1745#
1746# @param $1 - -cp or -classpath
1747# @param $2 - classpath; junit and recorded dependencies get appended
1748# @param $@ - the rest of the parameters are passed to java
1749# ------------------------------------------------------------------------------
1750ejunit() {
1751 debug-print-function ${FUNCNAME} $*
1752
1753 local pkgs
1754 for atom in $(cat ${JAVA_PKG_DEPEND_FILE} | tr : ' '); do
1755 pkgs=${pkgs},$(echo ${atom} | sed -re "s/^.*@//")
1756 done
1757
1758 local cp=$(java-pkg_getjars --with-dependencies junit${pkgs})
1759 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1760 cp="${2}:${cp}"
1761 shift 2
1762 else
1763 cp=".:${cp}"
1764 fi
1765
1766 local runner=junit.textui.TestRunner
1767 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1768 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1769}
1770
1771# ------------------------------------------------------------------------------
1656# @section-end helper 1772# @section-end helper
1657# ------------------------------------------------------------------------------ 1773# ------------------------------------------------------------------------------
1658 1774
1659# ------------------------------------------------------------------------------ 1775# ------------------------------------------------------------------------------
1660# @section-begin build 1776# @section-begin build
1671# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS, 1787# compiler. Will also set proper ANT_TASKS from the variable ANT_TASKS,
1672# variables: 1788# variables:
1673# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the 1789# EANT_GENTOO_CLASSPATH - calls java-pkg_getjars for the value and adds to the
1674# gentoo.classpath property. Be sure to call 1790# gentoo.classpath property. Be sure to call
1675# java-ant_rewrite-classpath in src_unpack. 1791# java-ant_rewrite-classpath in src_unpack.
1792# 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. 1793# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1677# ------------------------------------------------------------------------------ 1794# ------------------------------------------------------------------------------
1678eant() { 1795eant() {
1679 debug-print-function ${FUNCNAME} $* 1796 debug-print-function ${FUNCNAME} $*
1797
1798 if [[ ${EBUILD_PHASE} = compile ]]; then
1799 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can
1800 # finally get rid of the hooks without breaking stuff
1801
1802 [[ "${JAVA_ANT_IGNORE_SYSTEM_CLASSES}" && "${JAVA_PKG_BSFIX}" ]] \
1803 && java-ant_ignore-system-classes "${S}/build.xml"
1804
1805 if hasq java-ant-2 ${INHERITED}; then
1806 java-ant_bsfix
1807 fi
1808
1809 # eant can be called multiple times
1810 JAVA_PKG_BSFIX="off"
1811
1812 if [[ -z ${JAVA_PKG_NO_BUNDLED_SEARCH} ]] && is-java-strict; then
1813 echo "Searching for bundled jars:"
1814 java-pkg_find-normal-jars || echo "None found."
1815 echo "Searching for bundled classes (no output if none found):"
1816 find "${WORKDIR}" -name "*.class"
1817 echo "Search done."
1818 JAVA_PKG_NO_BUNDLED_SEARCH=true # eant can be called many times
1819 fi
1820 fi
1680 1821
1681 if ! hasq java-ant-2 ${INHERITED}; then 1822 if ! hasq java-ant-2 ${INHERITED}; then
1682 local msg="You should inherit java-ant-2 when using eant" 1823 local msg="You should inherit java-ant-2 when using eant"
1683 java-pkg_announce-qa-violation "${msg}" 1824 java-pkg_announce-qa-violation "${msg}"
1684 fi 1825 fi
1687 1828
1688 java-pkg_init-compiler_ 1829 java-pkg_init-compiler_
1689 local compiler="${GENTOO_COMPILER}" 1830 local compiler="${GENTOO_COMPILER}"
1690 1831
1691 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1832 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1692
1693 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})" 1833 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1694 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1834 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1695 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1835 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1696 fi 1836 fi
1697 1837
1726 echo "more info." 1866 echo "more info."
1727 fi 1867 fi
1728 fi 1868 fi
1729 done 1869 done
1730 1870
1871 # we use this in src_* so we run ant from /
1731 if has_version ">=dev-java/ant-core-1.7.0"; then 1872 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then
1732 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly 1873 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1733 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1874 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1734 1875
1735 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set 1876 # override ANT_TASKS with JAVA_PKG_FORCE_ANT_TASKS if it's set
1736 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1877 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1907 unset _JAVA_OPTIONS 2048 unset _JAVA_OPTIONS
1908 # phase hooks make this run many times without this 2049 # phase hooks make this run many times without this
1909 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2050 I_WANT_GLOBAL_JAVA_OPTIONS="true"
1910 fi 2051 fi
1911 2052
2053 if java-pkg_func-exists ant_src_unpack; then
2054 java-pkg_announce-qa-violation "Using old ant_src_unpack. Should be src_unpack"
2055 fi
2056
1912 java-pkg_init_paths_ 2057 java-pkg_init_paths_
1913 java-pkg_switch-vm 2058 java-pkg_switch-vm
1914 PATH=${JAVA_HOME}/bin:${PATH} 2059 PATH=${JAVA_HOME}/bin:${PATH}
1915 2060
1916 # TODO we will probably want to set JAVAC and JAVACFLAGS 2061 # TODO we will probably want to set JAVAC and JAVACFLAGS
2078# Writes the package.env out to disk. 2223# Writes the package.env out to disk.
2079# 2224#
2080# ------------------------------------------------------------------------------ 2225# ------------------------------------------------------------------------------
2081# TODO change to do-write, to match everything else 2226# TODO change to do-write, to match everything else
2082java-pkg_do_write_() { 2227java-pkg_do_write_() {
2228 debug-print-function ${FUNCNAME} $*
2083 java-pkg_init_paths_ 2229 java-pkg_init_paths_
2084 # Create directory for package.env 2230 # Create directory for package.env
2085 dodir "${JAVA_PKG_SHAREPATH}" 2231 dodir "${JAVA_PKG_SHAREPATH}"
2086 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 2232 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2233 "${JAVA_PKG_DEPEND_FILE}" || -f \
2234 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2087 # Create package.env 2235 # Create package.env
2088 ( 2236 (
2089 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2237 echo "DESCRIPTION=\"${DESCRIPTION}\""
2090 echo "GENERATION=\"2\"" 2238 echo "GENERATION=\"2\""
2091 2239
2092 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2240 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2093 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2241 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2094 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2242 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2095 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 2243 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2244 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2245 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2246 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2096 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2247 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2097 ) > "${JAVA_PKG_ENV}" 2248 ) > "${JAVA_PKG_ENV}"
2098 2249
2099 # register target/source 2250 # register target/source
2100 local target="$(java-pkg_get-target)" 2251 local target="$(java-pkg_get-target)"
2111 2262
2112 2263
2113 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2264 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
2114 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2265 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
2115 2266
2267 # extra env variables
2268 if [[ -n "${JAVA_PKG_EXTRA_ENV_VARS}" ]]; then
2269 cat "${JAVA_PKG_EXTRA_ENV}" >> "${JAVA_PKG_ENV}" || die
2270 # nested echo to remove leading/trailing spaces
2271 echo "ENV_VARS=\"$(echo ${JAVA_PKG_EXTRA_ENV_VARS})\"" \
2272 >> "${JAVA_PKG_ENV}" || die
2273 fi
2274
2116 # Strip unnecessary leading and trailing colons 2275 # Strip unnecessary leading and trailing colons
2117 # TODO try to cleanup if possible 2276 # TODO try to cleanup if possible
2118 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2277 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2278 else
2279 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2280 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2281 debug-print "write package.env."
2119 fi 2282 fi
2120} 2283}
2121 2284
2122# ------------------------------------------------------------------------------ 2285# ------------------------------------------------------------------------------
2123# @internal-function java-pkg_record-jar_ 2286# @internal-function java-pkg_record-jar_
2124# 2287#
2125# Record a dependency to the package.env 2288# Record an (optional) dependency to the package.env
2126# 2289# @param --optional - record dependency as optional
2290# @param $1 - package to record
2291# @param $2 - (optional) jar of package to record
2127# ------------------------------------------------------------------------------ 2292# ------------------------------------------------------------------------------
2128JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2293JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2294JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2129 2295
2130java-pkg_record-jar_() { 2296java-pkg_record-jar_() {
2131 debug-print-function ${FUNCNAME} $* 2297 debug-print-function ${FUNCNAME} $*
2298
2299 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2300 if [[ "${1}" == "--optional" ]]; then
2301 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2302 shift
2303 fi
2132 2304
2133 local pkg=${1} jar=${2} append 2305 local pkg=${1} jar=${2} append
2134 if [[ -z "${jar}" ]]; then 2306 if [[ -z "${jar}" ]]; then
2135 append="${pkg}" 2307 append="${pkg}"
2136 else 2308 else
2137 append="$(basename ${jar})@${pkg}" 2309 append="$(basename ${jar})@${pkg}"
2138 fi 2310 fi
2139 2311
2140 echo ${append} >> ${JAVA_PKG_DEPEND} 2312 echo "${append}" >> "${depend_file}"
2141} 2313}
2142 2314
2143# ------------------------------------------------------------------------------ 2315# ------------------------------------------------------------------------------
2144# @internal-function java-pkg_append_ 2316# @internal-function java-pkg_append_
2145# 2317#
2326 2498
2327 #TODO If you know a better solution let us know. 2499 #TODO If you know a better solution let us know.
2328 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2500 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2329 2501
2330 local tann="${T}/announced-vm" 2502 local tann="${T}/announced-vm"
2503 # With the hooks we should only get here once from pkg_setup but better safe than sorry
2504 # if people have for example modified eclasses some where
2331 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2505 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
2332 # Add a check for setup/preinst phase... to avoid duplicate outputs
2333 # for when FEATURES=buildpkg
2334 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
2335 then
2336 einfo "Using: $(java-config -f)" 2506 einfo "Using: $(java-config -f)"
2337 [[ ! -f "${tann}" ]] && touch "${tann}" 2507 [[ ! -f "${tann}" ]] && touch "${tann}"
2338 fi
2339 fi 2508 fi
2340 2509
2341 else 2510 else
2342 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!" 2511 [[ -n "${JAVA_PKG_DEBUG}" ]] && ewarn "!!! This package inherits java-pkg but doesn't depend on a JDK. -bin or broken dependency!!!"
2343 fi 2512 fi
2410# Check that a package being used in jarfrom, getjars and getjar is contained 2579# Check that a package being used in jarfrom, getjars and getjar is contained
2411# within DEPEND or RDEPEND. 2580# within DEPEND or RDEPEND.
2412# @param $1 - empty - check both vars; "runtime" or "build" - check only 2581# @param $1 - empty - check both vars; "runtime" or "build" - check only
2413# RDEPEND, resp. DEPEND 2582# RDEPEND, resp. DEPEND
2414# @param $2 - Package name and slot. 2583# @param $2 - Package name and slot.
2584
2415java-pkg_ensure-dep() { 2585java-pkg_ensure-dep() {
2416 debug-print-function ${FUNCNAME} $* 2586 debug-print-function ${FUNCNAME} $*
2417 2587
2418 local limit_to="${1}" 2588 local limit_to="${1}"
2419 local target_pkg="${2}" 2589 local target_pkg="${2}"
2420 local dev_error="" 2590 local dev_error=""
2421 2591
2422 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2592 local stripped_pkg=$(echo "${target_pkg}" | sed \
2423 's/-[0-9]*\(\.[0-9]\)*$//') 2593 's/-[0-9]*\(\.[0-9]\)*$//')
2594
2595 debug-print "Matching against: ${stripped_pkg}"
2424 2596
2425 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2597 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2426 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2598 dev_error="The ebuild is attempting to use ${target_pkg} that is not"
2427 dev_error="${dev_error} declared in DEPEND." 2599 dev_error="${dev_error} declared in DEPEND."
2428 if is-java-strict; then 2600 if is-java-strict; then
2601 eerror "${dev_error}"
2429 die "${dev_error}" 2602 die "${dev_error}"
2430 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2603 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2431 eerror "${dev_error}" 2604 eerror "${dev_error}"
2432 elog "Because you have this package installed the package will" 2605 elog "Because you have this package installed the package will"
2433 elog "build without problems, but please report this to" 2606 elog "build without problems, but please report this to"
2434 elog "http://bugs.gentoo.org" 2607 elog "http://bugs.gentoo.org"
2435 fi 2608 fi
2436 fi 2609 fi
2437 2610
2611 if [[ ${limit_to} != build ]]; then
2438 if [[ ${limit_to} != build && ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then 2612 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2613 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2439 dev_error="The ebuild is attempting to use ${target_pkg}," 2614 dev_error="The ebuild is attempting to use ${target_pkg},"
2440 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND." 2615 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2616 dev_error="${dev_error} or PDEPEND."
2441 if is-java-strict; then 2617 if is-java-strict; then
2618 eerror "${dev_error}"
2442 die "${dev_error}" 2619 die "${dev_error}"
2443 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2620 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2444 eerror "${dev_error}" 2621 eerror "${dev_error}"
2445 elog "The package will build without problems, but may fail to run" 2622 elog "The package will build without problems, but may fail to run"
2446 elog "if you don't have ${target_pkg} installed, so please report" 2623 elog "if you don't have ${target_pkg} installed, so please report"
2447 elog "this to http://bugs.gentoo.org" 2624 elog "this to http://bugs.gentoo.org"
2625 fi
2626 fi
2448 fi 2627 fi
2449 fi 2628 fi
2450} 2629}
2451 2630
2452# ------------------------------------------------------------------------------ 2631# ------------------------------------------------------------------------------

Legend:
Removed from v.1.83  
changed lines
  Added in v.1.93

  ViewVC Help
Powered by ViewVC 1.1.20