/[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.87 Revision 1.88
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.87 2007/05/27 11:09:11 betelgeuse Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.88 2007/05/28 19:28:22 caster Exp $
10 10
11# ----------------------------------------------------------------------------- 11# -----------------------------------------------------------------------------
12# @eclass-begin 12# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 13# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 14# @eclass-maintainer java@gentoo.org
1076# from a package, into package.env DEPEND line. Can only be called in 1076# from a package, into package.env DEPEND line. Can only be called in
1077# src_install phase. 1077# src_install phase.
1078# Intended for binary packages where you don't need to symlink the jars or get 1078# Intended for binary packages where you don't need to symlink the jars or get
1079# their classpath during build. As such, the dependencies only need to be 1079# their classpath during build. As such, the dependencies only need to be
1080# specified in ebuild's RDEPEND, and should be omitted in DEPEND. 1080# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
1081# Get the classpath provided by any number of packages.
1082# 1081#
1083# @param $1 - comma-separated list of packages, or a single package 1082# @param $1 - comma-separated list of packages, or a single package
1084# @param $2 - if param $1 is a single package, optionally specify the jar 1083# @param $2 - if param $1 is a single package, optionally specify the jar
1085# to depend on 1084# to depend on
1086# 1085#
1115 else 1114 else
1116 [[ ${pkgs} == *,* ]] && \ 1115 [[ ${pkgs} == *,* ]] && \
1117 die "${FUNCNAME} called with both package list and jar name" 1116 die "${FUNCNAME} called with both package list and jar name"
1118 java-pkg_ensure-dep runtime "${pkgs}" 1117 java-pkg_ensure-dep runtime "${pkgs}"
1119 java-pkg_record-jar_ "${pkgs}" "${jar}" 1118 java-pkg_record-jar_ "${pkgs}" "${jar}"
1119 fi
1120
1121 java-pkg_do_write_
1122}
1123
1124# ------------------------------------------------------------------------------
1125# @ebuild-function java-pkg_register-optional-dependency
1126#
1127# Registers optional runtime dependency on a package, list of packages, or a
1128# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
1129# called in src_install phase.
1130# Intended for packages that can use other packages when those are in classpath.
1131# Will be put on classpath by launcher if they are installed. Typical case is
1132# JDBC implementations for various databases. It's better than having USE flag
1133# for each implementation triggering hard dependency.
1134#
1135# @param $1 - comma-separated list of packages, or a single package
1136# @param $2 - if param $1 is a single package, optionally specify the jar
1137# to depend on
1138#
1139# Example: Record the optional dependency on some jdbc providers
1140# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
1141#
1142# Note: Passing both list of packages as the first parameter AND specifying the
1143# jar as the second is not allowed and will cause the function to die. We assume
1144# that there's more chance one passes such combination as a mistake, than that
1145# there are more packages providing identically named jar without class
1146# collisions.
1147# ------------------------------------------------------------------------------
1148java-pkg_register-optional-dependency() {
1149 debug-print-function ${FUNCNAME} $*
1150
1151 java-pkg_check-phase install
1152
1153 [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
1154
1155 local pkgs="${1}"
1156 local jar="${2}"
1157
1158 [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
1159
1160 if [[ -z "${jar}" ]]; then
1161 for pkg in ${pkgs//,/ }; do
1162 java-pkg_record-jar_ --optional "${pkg}"
1163 done
1164 else
1165 [[ ${pkgs} == *,* ]] && \
1166 die "${FUNCNAME} called with both package list and jar name"
1167 java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
1120 fi 1168 fi
1121 1169
1122 java-pkg_do_write_ 1170 java-pkg_do_write_
1123} 1171}
1124 1172
2143 debug-print-function ${FUNCNAME} $* 2191 debug-print-function ${FUNCNAME} $*
2144 java-pkg_init_paths_ 2192 java-pkg_init_paths_
2145 # Create directory for package.env 2193 # Create directory for package.env
2146 dodir "${JAVA_PKG_SHAREPATH}" 2194 dodir "${JAVA_PKG_SHAREPATH}"
2147 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \ 2195 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
2196 "${JAVA_PKG_DEPEND_FILE}" || -f \
2148 "${JAVA_PKG_DEPEND_FILE}" ]]; then 2197 "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
2149 # Create package.env 2198 # Create package.env
2150 ( 2199 (
2151 echo "DESCRIPTION=\"${DESCRIPTION}\"" 2200 echo "DESCRIPTION=\"${DESCRIPTION}\""
2152 echo "GENERATION=\"2\"" 2201 echo "GENERATION=\"2\""
2153 2202
2154 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\"" 2203 [[ -n "${JAVA_PKG_CLASSPATH}" ]] && echo "CLASSPATH=\"${JAVA_PKG_CLASSPATH}\""
2155 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 2204 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
2156 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 2205 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
2157 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \ 2206 [[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
2158 && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND_FILE} | uniq | tr '\n' ':')\"" 2207 && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2208 [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
2209 && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
2159 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 2210 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
2160 ) > "${JAVA_PKG_ENV}" 2211 ) > "${JAVA_PKG_ENV}"
2161 2212
2162 # register target/source 2213 # register target/source
2163 local target="$(java-pkg_get-target)" 2214 local target="$(java-pkg_get-target)"
2186 2237
2187 # Strip unnecessary leading and trailing colons 2238 # Strip unnecessary leading and trailing colons
2188 # TODO try to cleanup if possible 2239 # TODO try to cleanup if possible
2189 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 2240 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
2190 else 2241 else
2191 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY or" 2242 debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
2192 debug-print "JAVA_PKG_DEPEND_FILE not defined so can't" 2243 debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
2193 debug-print "write package.env." 2244 debug-print "write package.env."
2194 fi 2245 fi
2195} 2246}
2196 2247
2197# ------------------------------------------------------------------------------ 2248# ------------------------------------------------------------------------------
2198# @internal-function java-pkg_record-jar_ 2249# @internal-function java-pkg_record-jar_
2199# 2250#
2200# Record a dependency to the package.env 2251# Record an (optional) dependency to the package.env
2201# 2252# @param --optional - record dependency as optional
2253# @param $1 - package to record
2254# @param $2 - (optional) jar of package to record
2202# ------------------------------------------------------------------------------ 2255# ------------------------------------------------------------------------------
2203JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend" 2256JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
2257JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
2204 2258
2205java-pkg_record-jar_() { 2259java-pkg_record-jar_() {
2206 debug-print-function ${FUNCNAME} $* 2260 debug-print-function ${FUNCNAME} $*
2261
2262 local depend_file="${JAVA_PKG_DEPEND_FILE}"
2263 if [[ "${1}" == "--optional" ]]; then
2264 depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
2265 shift
2266 fi
2207 2267
2208 local pkg=${1} jar=${2} append 2268 local pkg=${1} jar=${2} append
2209 if [[ -z "${jar}" ]]; then 2269 if [[ -z "${jar}" ]]; then
2210 append="${pkg}" 2270 append="${pkg}"
2211 else 2271 else
2212 append="$(basename ${jar})@${pkg}" 2272 append="$(basename ${jar})@${pkg}"
2213 fi 2273 fi
2214 2274
2215 echo ${append} >> ${JAVA_PKG_DEPEND_FILE} 2275 echo "${append}" >> "${depend_file}"
2216} 2276}
2217 2277
2218# ------------------------------------------------------------------------------ 2278# ------------------------------------------------------------------------------
2219# @internal-function java-pkg_append_ 2279# @internal-function java-pkg_append_
2220# 2280#

Legend:
Removed from v.1.87  
changed lines
  Added in v.1.88

  ViewVC Help
Powered by ViewVC 1.1.20