/[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.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.80 2007/04/26 23:32:12 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"
995 classpath="${classpath}:${jars}" 1002 classpath="${classpath}:${jars}"
996 fi 1003 fi
997 1004
998 # Only record jars that aren't build-only 1005 # Only record jars that aren't build-only
999 if [[ -z "${build_only}" ]]; then 1006 if [[ -z "${build_only}" ]]; then
1000 for pkg in ${pkgs//:/ }; do 1007 for pkg in ${pkgs//,/ }; do
1001 java-pkg_record-jar_ "${pkg}" 1008 java-pkg_record-jar_ "${pkg}"
1002 done 1009 done
1003 fi 1010 fi
1004 1011
1005 echo "${classpath}" 1012 echo "${classpath}"
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
1616 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true 1697 [[ "${ant}" == "dev-java/ant" ]] && found_ant=true
1617 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true 1698 [[ "${dep}" == *"ant-tasks"* ]] && found_ant_tasks=true
1618 done 1699 done
1619 1700
1620 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then 1701 if [[ -n "${found_ant}" || -n "${found_ant_tasks}" ]]; then
1621 java-pkg_announce-qa-violation "The ebuild DEPENDS on deprecated ant or ant-tasks" 1702 java-pkg_announce-qa-violation --nodie "The ebuild DEPENDS on deprecated ant or ant-tasks"
1622 echo "all" 1703 echo "all"
1623 else 1704 else
1624 # ebuild doesn't set ANT_TASKS and doesn't depend on ant-tasks or ant 1705 # 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 1706 # so we deactivate all tasks that may be installed
1626 echo "none" 1707 echo "none"
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} $*
1680 1797
1681 # FIXME get this working 1798 if [[ ${EBUILD_PHASE} = compile ]]; then
1682# if is-java-strict && [[ ! ${DEPEND} =~ "dev-java/ant" ]]; then 1799 # Used to be done in hooks in java-ant-2.eclass but moved here so that we can
1683# java-pkg_announce-qa-violation \ 1800 # finally get rid of the hooks without breaking stuff
1684# "Using eant, but not depending on dev-java/ant or dev-java/ant-core" 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
1685# fi 1820 fi
1686 1821
1687 if ! hasq java-ant-2 ${INHERITED} && is-java-strict; then 1822 if ! hasq java-ant-2 ${INHERITED}; then
1688 local msg="You should inherit java-ant-2 when using eant" 1823 local msg="You should inherit java-ant-2 when using eant"
1689 java-pkg_announce-qa-violation ${msg} 1824 java-pkg_announce-qa-violation "${msg}"
1690 die ${msg}
1691 fi 1825 fi
1692 1826
1693 local antflags="-Dnoget=true -Dmaven.mode.offline=true" 1827 local antflags="-Dnoget=true -Dmaven.mode.offline=true"
1694 1828
1695 java-pkg_init-compiler_ 1829 java-pkg_init-compiler_
1696 local compiler="${GENTOO_COMPILER}" 1830 local compiler="${GENTOO_COMPILER}"
1697 1831
1698 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1832 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})" 1833 local build_compiler="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${ANT_BUILD_COMPILER})"
1701 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then 1834 if [[ "${compiler}" != "javac" && -z "${build_compiler}" ]]; then
1702 die "ANT_BUILD_COMPILER undefined in ${compiler_env}" 1835 die "ANT_BUILD_COMPILER undefined in ${compiler_env}"
1703 fi 1836 fi
1704 1837
1733 echo "more info." 1866 echo "more info."
1734 fi 1867 fi
1735 fi 1868 fi
1736 done 1869 done
1737 1870
1871 # we use this in src_* so we run ant from /
1738 if has_version ">=dev-java/ant-core-1.7.0"; then 1872 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 1873 # default ANT_TASKS to WANT_ANT_TASKS, if ANT_TASKS is not set explicitly
1740 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}" 1874 ANT_TASKS="${ANT_TASKS:-${WANT_ANT_TASKS}}"
1741 1875
1742 # 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
1743 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}" 1877 ANT_TASKS="${JAVA_PKG_FORCE_ANT_TASKS:-${ANT_TASKS}}"
1914 unset _JAVA_OPTIONS 2048 unset _JAVA_OPTIONS
1915 # phase hooks make this run many times without this 2049 # phase hooks make this run many times without this
1916 I_WANT_GLOBAL_JAVA_OPTIONS="true" 2050 I_WANT_GLOBAL_JAVA_OPTIONS="true"
1917 fi 2051 fi
1918 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
1919 java-pkg_init_paths_ 2057 java-pkg_init_paths_
1920 java-pkg_switch-vm 2058 java-pkg_switch-vm
1921 PATH=${JAVA_HOME}/bin:${PATH} 2059 PATH=${JAVA_HOME}/bin:${PATH}
1922 2060
1923 # TODO we will probably want to set JAVAC and JAVACFLAGS 2061 # TODO we will probably want to set JAVAC and JAVACFLAGS
2085# Writes the package.env out to disk. 2223# Writes the package.env out to disk.
2086# 2224#
2087# ------------------------------------------------------------------------------ 2225# ------------------------------------------------------------------------------
2088# TODO change to do-write, to match everything else 2226# TODO change to do-write, to match everything else
2089java-pkg_do_write_() { 2227java-pkg_do_write_() {
2228 debug-print-function ${FUNCNAME} $*
2090 java-pkg_init_paths_ 2229 java-pkg_init_paths_
2091 # Create directory for package.env 2230 # Create directory for package.env
2092 dodir "${JAVA_PKG_SHAREPATH}" 2231 dodir "${JAVA_PKG_SHAREPATH}"
2093 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
2094 # Create package.env 2235 # Create package.env
2095 ( 2236 (
2096 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2237 echo "DESCRIPTION=\"${DESCRIPTION}\""
2097 echo "GENERATION=\"2\"" 2238 echo "GENERATION=\"2\""
2098 2239
2099 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2240 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2100 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2241 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2101 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2242 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2102 [[ -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' ':')\""
2103 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 !
2104 ) > "${JAVA_PKG_ENV}" 2248 ) > "${JAVA_PKG_ENV}"
2105 2249
2106 # register target/source 2250 # register target/source
2107 local target="$(java-pkg_get-target)" 2251 local target="$(java-pkg_get-target)"
2118 2262
2119 2263
2120 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}" 2264 echo "MERGE_VM=\"${GENTOO_VM}\"" >> "${JAVA_PKG_ENV}"
2121 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}" 2265 [[ -n ${GENTOO_COMPILER} ]] && echo "MERGE_COMPILER=\"${GENTOO_COMPILER}\"" >> "${JAVA_PKG_ENV}"
2122 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
2123 # Strip unnecessary leading and trailing colons 2275 # Strip unnecessary leading and trailing colons
2124 # TODO try to cleanup if possible 2276 # TODO try to cleanup if possible
2125 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."
2126 fi 2282 fi
2127} 2283}
2128 2284
2129# ------------------------------------------------------------------------------ 2285# ------------------------------------------------------------------------------
2130# @internal-function java-pkg_record-jar_ 2286# @internal-function java-pkg_record-jar_
2131# 2287#
2132# Record a dependency to the package.env 2288# Record an (optional) dependency to the package.env
2133# 2289# @param --optional - record dependency as optional
2290# @param $1 - package to record
2291# @param $2 - (optional) jar of package to record
2134# ------------------------------------------------------------------------------ 2292# ------------------------------------------------------------------------------
2135JAVA_PKG_DEPEND="${T}/java-pkg-depend" 2293JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2294JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2136 2295
2137java-pkg_record-jar_() { 2296java-pkg_record-jar_() {
2138 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
2139 2304
2140 local pkg=${1} jar=${2} append 2305 local pkg=${1} jar=${2} append
2141 if [[ -z "${jar}" ]]; then 2306 if [[ -z "${jar}" ]]; then
2142 append="${pkg}" 2307 append="${pkg}"
2143 else 2308 else
2144 append="$(basename ${jar})@${pkg}" 2309 append="$(basename ${jar})@${pkg}"
2145 fi 2310 fi
2146 2311
2147 echo ${append} >> ${JAVA_PKG_DEPEND} 2312 echo "${append}" >> "${depend_file}"
2148} 2313}
2149 2314
2150# ------------------------------------------------------------------------------ 2315# ------------------------------------------------------------------------------
2151# @internal-function java-pkg_append_ 2316# @internal-function java-pkg_append_
2152# 2317#
2212# 2377#
2213# ------------------------------------------------------------------------------ 2378# ------------------------------------------------------------------------------
2214java-pkg_setup-vm() { 2379java-pkg_setup-vm() {
2215 debug-print-function ${FUNCNAME} $* 2380 debug-print-function ${FUNCNAME} $*
2216 2381
2382 export LANG="C" LC_ALL="C"
2383
2217 local vendor="$(java-pkg_get-vm-vendor)" 2384 local vendor="$(java-pkg_get-vm-vendor)"
2218 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then 2385 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
2219 addpredict "/dev/random" 2386 addpredict "/dev/random"
2220 elif [[ "${vendor}" == "ibm" ]]; then 2387 elif [[ "${vendor}" == "ibm" ]]; then
2221 addpredict "/proc/self/maps" 2388 addpredict "/proc/self/maps"
2222 addpredict "/proc/cpuinfo" 2389 addpredict "/proc/cpuinfo"
2223 export LANG="C" LC_ALL="C"
2224 elif [[ "${vendor}" == "jrockit" ]]; then 2390 elif [[ "${vendor}" == "jrockit" ]]; then
2225 addpredict "/proc/cpuinfo" 2391 addpredict "/proc/cpuinfo"
2226 fi 2392 fi
2227} 2393}
2228 2394
2332 2498
2333 #TODO If you know a better solution let us know. 2499 #TODO If you know a better solution let us know.
2334 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 2500 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
2335 2501
2336 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
2337 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 2505 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)" 2506 einfo "Using: $(java-config -f)"
2343 [[ ! -f "${tann}" ]] && touch "${tann}" 2507 [[ ! -f "${tann}" ]] && touch "${tann}"
2344 fi
2345 fi 2508 fi
2346 2509
2347 else 2510 else
2348 [[ -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!!!"
2349 fi 2512 fi
2416# 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
2417# within DEPEND or RDEPEND. 2580# within DEPEND or RDEPEND.
2418# @param $1 - empty - check both vars; "runtime" or "build" - check only 2581# @param $1 - empty - check both vars; "runtime" or "build" - check only
2419# RDEPEND, resp. DEPEND 2582# RDEPEND, resp. DEPEND
2420# @param $2 - Package name and slot. 2583# @param $2 - Package name and slot.
2584
2421java-pkg_ensure-dep() { 2585java-pkg_ensure-dep() {
2422 debug-print-function ${FUNCNAME} $* 2586 debug-print-function ${FUNCNAME} $*
2423 2587
2424 local limit_to="${1}" 2588 local limit_to="${1}"
2425 local target_pkg="${2}" 2589 local target_pkg="${2}"
2426 local dev_error="" 2590 local dev_error=""
2427 2591
2428 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2592 local stripped_pkg=$(echo "${target_pkg}" | sed \
2429 's/-[0-9]*\(\.[0-9]\)*$//') 2593 's/-[0-9]*\(\.[0-9]\)*$//')
2594
2595 debug-print "Matching against: ${stripped_pkg}"
2430 2596
2431 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2597 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then
2432 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"
2433 dev_error="${dev_error} declared in DEPEND." 2599 dev_error="${dev_error} declared in DEPEND."
2434 if is-java-strict; then 2600 if is-java-strict; then
2601 eerror "${dev_error}"
2435 die "${dev_error}" 2602 die "${dev_error}"
2436 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2603 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2437 eerror "${dev_error}" 2604 eerror "${dev_error}"
2438 elog "Because you have this package installed the package will" 2605 elog "Because you have this package installed the package will"
2439 elog "build without problems, but please report this to" 2606 elog "build without problems, but please report this to"
2440 elog "http://bugs.gentoo.org" 2607 elog "http://bugs.gentoo.org"
2441 fi 2608 fi
2442 fi 2609 fi
2443 2610
2611 if [[ ${limit_to} != build ]]; then
2444 if [[ ${limit_to} != build && ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then 2612 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2613 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2445 dev_error="The ebuild is attempting to use ${target_pkg}," 2614 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." 2615 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND"
2616 dev_error="${dev_error} or PDEPEND."
2447 if is-java-strict; then 2617 if is-java-strict; then
2618 eerror "${dev_error}"
2448 die "${dev_error}" 2619 die "${dev_error}"
2449 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2620 elif [[ ${BASH_SUBSHELL} = 0 ]]; then
2450 eerror "${dev_error}" 2621 eerror "${dev_error}"
2451 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"
2452 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"
2453 elog "this to http://bugs.gentoo.org" 2624 elog "this to http://bugs.gentoo.org"
2625 fi
2626 fi
2454 fi 2627 fi
2455 fi 2628 fi
2456} 2629}
2457 2630
2458# ------------------------------------------------------------------------------ 2631# ------------------------------------------------------------------------------
2459# @section-end internal 2632# @section-end internal
2460# ------------------------------------------------------------------------------ 2633# ------------------------------------------------------------------------------
2461 2634
2462java-pkg_check-phase() { 2635java-pkg_check-phase() {
2463 local phase=${1} 2636 local phase=${1}
2464 local funcname=${2} 2637 local funcname=${FUNCNAME[1]}
2465 if is-java-strict && [[ ${EBUILD_PHASE} != ${phase} ]]; then 2638 if [[ ${EBUILD_PHASE} != ${phase} ]]; then
2466 java-pkg_announce-qa-violation \
2467 "${funcname} used outside of src_${phase}" 2639 local msg="${funcname} used outside of src_${phase}"
2640 java-pkg_announce-qa-violation "${msg}"
2468 fi 2641 fi
2469} 2642}
2470 2643
2471java-pkg_check-versioned-jar() { 2644java-pkg_check-versioned-jar() {
2472 local jar=${1} 2645 local jar=${1}
2481 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE" 2654 java-pkg_announce-qa-violation "deprecated USE flag 'jikes' in IUSE"
2482 fi 2655 fi
2483} 2656}
2484 2657
2485java-pkg_announce-qa-violation() { 2658java-pkg_announce-qa-violation() {
2486 if is-java-strict; then 2659 local nodie
2660 if [[ ${1} == "--nodie" ]]; then
2661 nodie="true"
2662 shift
2663 fi
2487 echo "Java QA Notice: $@" >&2 2664 echo "Java QA Notice: $@" >&2
2488 increment-qa-violations 2665 increment-qa-violations
2489 fi 2666 [[ -z "${nodie}" ]] && is-java-strict && die "${@}"
2490} 2667}
2491 2668
2492increment-qa-violations() { 2669increment-qa-violations() {
2493 let "JAVA_PKG_QA_VIOLATIONS+=1" 2670 let "JAVA_PKG_QA_VIOLATIONS+=1"
2494 export JAVA_PKG_QA_VIOLATIONS 2671 export JAVA_PKG_QA_VIOLATIONS

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

  ViewVC Help
Powered by ViewVC 1.1.20