/[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.84 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.84 2007/05/06 09:47:36 betelgeuse 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
1661# Examples: 1742# Examples:
1662# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests 1743# ejunit -cp build/classes org.blinkenlights.jid3.test.AllTests
1663# ejunit org.blinkenlights.jid3.test.AllTests 1744# ejunit org.blinkenlights.jid3.test.AllTests
1664# 1745#
1665# @param $1 - -cp or -classpath 1746# @param $1 - -cp or -classpath
1666# @param $2 - classpath, junit gets appended 1747# @param $2 - classpath; junit and recorded dependencies get appended
1667# @param $@ - the rest of the parameters are passed to java 1748# @param $@ - the rest of the parameters are passed to java
1668# ------------------------------------------------------------------------------ 1749# ------------------------------------------------------------------------------
1669ejunit() { 1750ejunit() {
1670 debug-print-function ${FUNCNAME} $* 1751 debug-print-function ${FUNCNAME} $*
1671 1752
1672 local cp 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})
1673 if [[ ${1} = -cp || ${1} = -classpath ]]; then 1759 if [[ ${1} = -cp || ${1} = -classpath ]]; then
1674 cp=${2}:$(java-pkg_getjars --build-only junit) 1760 cp="${2}:${cp}"
1675 shift 2 1761 shift 2
1676 else 1762 else
1677 cp=$(java-pkg_getjars --build-only junit):. 1763 cp=".:${cp}"
1678 fi 1764 fi
1679 1765
1680 local runner=junit.textui.TestRunner 1766 local runner=junit.textui.TestRunner
1681 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}" 1767 debug-print "Calling: java -cp \"${cp}\" -Djava.awt.headless=true ${runner} ${@}"
1682 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed" 1768 java -cp "${cp}" -Djava.awt.headless=true ${runner} "${@}" || die "Running junit failed"
1701# 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,
1702# variables: 1788# variables:
1703# 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
1704# gentoo.classpath property. Be sure to call 1790# gentoo.classpath property. Be sure to call
1705# 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
1706# *ANT_TASKS - used to determine ANT_TASKS before calling Ant. 1793# *ANT_TASKS - used to determine ANT_TASKS before calling Ant.
1707# ------------------------------------------------------------------------------ 1794# ------------------------------------------------------------------------------
1708eant() { 1795eant() {
1709 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
1710 1821
1711 if ! hasq java-ant-2 ${INHERITED}; then 1822 if ! hasq java-ant-2 ${INHERITED}; then
1712 local msg="You should inherit java-ant-2 when using eant" 1823 local msg="You should inherit java-ant-2 when using eant"
1713 java-pkg_announce-qa-violation "${msg}" 1824 java-pkg_announce-qa-violation "${msg}"
1714 fi 1825 fi
1717 1828
1718 java-pkg_init-compiler_ 1829 java-pkg_init-compiler_
1719 local compiler="${GENTOO_COMPILER}" 1830 local compiler="${GENTOO_COMPILER}"
1720 1831
1721 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1832 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1722
1723 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})"
1724 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1834 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1725 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1835 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1726 fi 1836 fi
1727 1837
1756 echo "more info." 1866 echo "more info."
1757 fi 1867 fi
1758 fi 1868 fi
1759 done 1869 done
1760 1870
1871 # we use this in src_* so we run ant from /
1761 if has_version ">=dev-java/ant-core-1.7.0"; then 1872 if ROOT=/ has_version ">=dev-java/ant-core-1.7.0"; then
1762 # 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
1763 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1874 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1764 1875
1765 # 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
1766 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1877 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1937 unset _JAVA_OPTIONS 2048 unset _JAVA_OPTIONS
1938 # phase hooks make this run many times without this 2049 # phase hooks make this run many times without this
1939 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2050 I_WANT_GLOBAL_JAVA_OPTIONS="true"
1940 fi 2051 fi
1941 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
1942 java-pkg_init_paths_ 2057 java-pkg_init_paths_
1943 java-pkg_switch-vm 2058 java-pkg_switch-vm
1944 PATH=${JAVA_HOME}/bin:${PATH} 2059 PATH=${JAVA_HOME}/bin:${PATH}
1945 2060
1946 # TODO we will probably want to set JAVAC and JAVACFLAGS 2061 # TODO we will probably want to set JAVAC and JAVACFLAGS
2108# Writes the package.env out to disk. 2223# Writes the package.env out to disk.
2109# 2224#
2110# ------------------------------------------------------------------------------ 2225# ------------------------------------------------------------------------------
2111# TODO change to do-write, to match everything else 2226# TODO change to do-write, to match everything else
2112java-pkg_do_write_() { 2227java-pkg_do_write_() {
2228 debug-print-function ${FUNCNAME} $*
2113 java-pkg_init_paths_ 2229 java-pkg_init_paths_
2114 # Create directory for package.env 2230 # Create directory for package.env
2115 dodir "${JAVA_PKG_SHAREPATH}" 2231 dodir "${JAVA_PKG_SHAREPATH}"
2116 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
2117 # Create package.env 2235 # Create package.env
2118 ( 2236 (
2119 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2237 echo "DESCRIPTION=\"${DESCRIPTION}\""
2120 echo "GENERATION=\"2\"" 2238 echo "GENERATION=\"2\""
2121 2239
2122 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2240 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2123 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2241 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2124 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2242 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2125 [[ -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' ':')\""
2126 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 !
2127 ) > "${JAVA_PKG_ENV}" 2248 ) > "${JAVA_PKG_ENV}"
2128 2249
2129 # register target/source 2250 # register target/source
2130 local target="$(java-pkg_get-target)" 2251 local target="$(java-pkg_get-target)"
2141 2262
2142 2263
2143 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2264 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
2144 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2265 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
2145 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
2146 # Strip unnecessary leading and trailing colons 2275 # Strip unnecessary leading and trailing colons
2147 # TODO try to cleanup if possible 2276 # TODO try to cleanup if possible
2148 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."
2149 fi 2282 fi
2150} 2283}
2151 2284
2152# ------------------------------------------------------------------------------ 2285# ------------------------------------------------------------------------------
2153# @internal-function java-pkg_record-jar_ 2286# @internal-function java-pkg_record-jar_
2154# 2287#
2155# Record a dependency to the package.env 2288# Record an (optional) dependency to the package.env
2156# 2289# @param --optional - record dependency as optional
2290# @param $1 - package to record
2291# @param $2 - (optional) jar of package to record
2157# ------------------------------------------------------------------------------ 2292# ------------------------------------------------------------------------------
2158JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2293JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2294JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2159 2295
2160java-pkg_record-jar_() { 2296java-pkg_record-jar_() {
2161 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
2162 2304
2163 local pkg=${1} jar=${2} append 2305 local pkg=${1} jar=${2} append
2164 if [[ -z "${jar}" ]]; then 2306 if [[ -z "${jar}" ]]; then
2165 append="${pkg}" 2307 append="${pkg}"
2166 else 2308 else
2167 append="$(basename ${jar})@${pkg}" 2309 append="$(basename ${jar})@${pkg}"
2168 fi 2310 fi
2169 2311
2170 echo ${append} >> ${JAVA_PKG_DEPEND} 2312 echo "${append}" >> "${depend_file}"
2171} 2313}
2172 2314
2173# ------------------------------------------------------------------------------ 2315# ------------------------------------------------------------------------------
2174# @internal-function java-pkg_append_ 2316# @internal-function java-pkg_append_
2175# 2317#
2356 2498
2357 #TODO If you know a better solution let us know. 2499 #TODO If you know a better solution let us know.
2358 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2500 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2359 2501
2360 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
2361 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2505 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
2362 # Add a check for setup/preinst phase... to avoid duplicate outputs
2363 # for when FEATURES=buildpkg
2364 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
2365 then
2366 einfo "Using: $(java-config -f)" 2506 einfo "Using: $(java-config -f)"
2367 [[ ! -f "${tann}" ]] && touch "${tann}" 2507 [[ ! -f "${tann}" ]] && touch "${tann}"
2368 fi
2369 fi 2508 fi
2370 2509
2371 else 2510 else
2372 [[ -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!!!"
2373 fi 2512 fi
2440# 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
2441# within DEPEND or RDEPEND. 2580# within DEPEND or RDEPEND.
2442# @param $1 - empty - check both vars; "runtime" or "build" - check only 2581# @param $1 - empty - check both vars; "runtime" or "build" - check only
2443# RDEPEND, resp. DEPEND 2582# RDEPEND, resp. DEPEND
2444# @param $2 - Package name and slot. 2583# @param $2 - Package name and slot.
2584
2445java-pkg_ensure-dep() { 2585java-pkg_ensure-dep() {
2446 debug-print-function ${FUNCNAME} $* 2586 debug-print-function ${FUNCNAME} $*
2447 2587
2448 local limit_to="${1}" 2588 local limit_to="${1}"
2449 local target_pkg="${2}" 2589 local target_pkg="${2}"
2450 local dev_error="" 2590 local dev_error=""
2451 2591
2452 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2592 local stripped_pkg=$(echo "${target_pkg}" | sed \
2453 's/-[0-9]*\(\.[0-9]\)*$//') 2593 's/-[0-9]*\(\.[0-9]\)*$//')
2594
2595 debug-print "Matching against: ${stripped_pkg}"
2454 2596
2455 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2597 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2456 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"
2457 dev_error="${dev_error} declared in DEPEND." 2599 dev_error="${dev_error} declared in DEPEND."
2458 if is-java-strict; then 2600 if is-java-strict; then
2601 eerror "${dev_error}"
2459 die "${dev_error}" 2602 die "${dev_error}"
2460 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2603 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2461 eerror "${dev_error}" 2604 eerror "${dev_error}"
2462 elog "Because you have this package installed the package will" 2605 elog "Because you have this package installed the package will"
2463 elog "build without problems, but please report this to" 2606 elog "build without problems, but please report this to"
2464 elog "http://bugs.gentoo.org" 2607 elog "http://bugs.gentoo.org"
2465 fi 2608 fi
2466 fi 2609 fi
2467 2610
2611 if [[ ${limit_to} != build ]]; then
2468 if [[ ${limit_to} != build && ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then 2612 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2613 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2469 dev_error="The ebuild is attempting to use ${target_pkg}," 2614 dev_error="The ebuild is attempting to use ${target_pkg},"
2470 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."
2471 if is-java-strict; then 2617 if is-java-strict; then
2618 eerror "${dev_error}"
2472 die "${dev_error}" 2619 die "${dev_error}"
2473 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2620 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2474 eerror "${dev_error}" 2621 eerror "${dev_error}"
2475 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"
2476 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"
2477 elog "this to http://bugs.gentoo.org" 2624 elog "this to http://bugs.gentoo.org"
2625 fi
2626 fi
2478 fi 2627 fi
2479 fi 2628 fi
2480} 2629}
2481 2630
2482# ------------------------------------------------------------------------------ 2631# ------------------------------------------------------------------------------

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

  ViewVC Help
Powered by ViewVC 1.1.20