summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVlastimil Babka <caster@gentoo.org>2007-05-28 19:28:22 +0000
committerVlastimil Babka <caster@gentoo.org>2007-05-28 19:28:22 +0000
commit23dcdd77f88215ba9704e1ea18987e39d8db1bc0 (patch)
treea7038a379dc39cb499aa509e293c6ed2bb1886dd /eclass/java-utils-2.eclass
parentsources are already on mirrors, updated SRC_URI (diff)
downloadgentoo-2-23dcdd77f88215ba9704e1ea18987e39d8db1bc0.tar.gz
gentoo-2-23dcdd77f88215ba9704e1ea18987e39d8db1bc0.tar.bz2
gentoo-2-23dcdd77f88215ba9704e1ea18987e39d8db1bc0.zip
Support for OPTIONAL_DEPEND in package.env, via new function java-pkg_register-optional-dependency, bug #176182.
Diffstat (limited to 'eclass/java-utils-2.eclass')
-rw-r--r--eclass/java-utils-2.eclass78
1 files changed, 69 insertions, 9 deletions
diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass
index 75c44bb81567..eb6d82bc8ec5 100644
--- a/eclass/java-utils-2.eclass
+++ b/eclass/java-utils-2.eclass
@@ -6,7 +6,7 @@
#
# Licensed under the GNU General Public License, v2
#
-# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.87 2007/05/27 11:09:11 betelgeuse Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.88 2007/05/28 19:28:22 caster Exp $
# -----------------------------------------------------------------------------
# @eclass-begin
@@ -1078,7 +1078,6 @@ java-pkg_getjar() {
# Intended for binary packages where you don't need to symlink the jars or get
# their classpath during build. As such, the dependencies only need to be
# specified in ebuild's RDEPEND, and should be omitted in DEPEND.
-# Get the classpath provided by any number of packages.
#
# @param $1 - comma-separated list of packages, or a single package
# @param $2 - if param $1 is a single package, optionally specify the jar
@@ -1123,6 +1122,55 @@ java-pkg_register-dependency() {
}
# ------------------------------------------------------------------------------
+# @ebuild-function java-pkg_register-optional-dependency
+#
+# Registers optional runtime dependency on a package, list of packages, or a
+# single jar from a package, into package.env OPTIONAL_DEPEND line. Can only be
+# called in src_install phase.
+# Intended for packages that can use other packages when those are in classpath.
+# Will be put on classpath by launcher if they are installed. Typical case is
+# JDBC implementations for various databases. It's better than having USE flag
+# for each implementation triggering hard dependency.
+#
+# @param $1 - comma-separated list of packages, or a single package
+# @param $2 - if param $1 is a single package, optionally specify the jar
+# to depend on
+#
+# Example: Record the optional dependency on some jdbc providers
+# java-pkg_register-optional-dependency jdbc-jaybird,jtds-1.2,jdbc-mysql
+#
+# Note: Passing both list of packages as the first parameter AND specifying the
+# jar as the second is not allowed and will cause the function to die. We assume
+# that there's more chance one passes such combination as a mistake, than that
+# there are more packages providing identically named jar without class
+# collisions.
+# ------------------------------------------------------------------------------
+java-pkg_register-optional-dependency() {
+ debug-print-function ${FUNCNAME} $*
+
+ java-pkg_check-phase install
+
+ [[ ${#} -gt 2 ]] && die "${FUNCNAME} takes at most two arguments"
+
+ local pkgs="${1}"
+ local jar="${2}"
+
+ [[ -z "${pkgs}" ]] && die "${FUNCNAME} called with no package(s) specified"
+
+ if [[ -z "${jar}" ]]; then
+ for pkg in ${pkgs//,/ }; do
+ java-pkg_record-jar_ --optional "${pkg}"
+ done
+ else
+ [[ ${pkgs} == *,* ]] && \
+ die "${FUNCNAME} called with both package list and jar name"
+ java-pkg_record-jar_ --optional "${pkgs}" "${jar}"
+ fi
+
+ java-pkg_do_write_
+}
+
+# ------------------------------------------------------------------------------
# @ebuild-function java-pkg_register-environment-variable
#
# Register an arbitrary environment variable into package.env. The gjl launcher
@@ -2145,7 +2193,8 @@ java-pkg_do_write_() {
# Create directory for package.env
dodir "${JAVA_PKG_SHAREPATH}"
if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f \
- "${JAVA_PKG_DEPEND_FILE}" ]]; then
+ "${JAVA_PKG_DEPEND_FILE}" || -f \
+ "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]]; then
# Create package.env
(
echo "DESCRIPTION=\"${DESCRIPTION}\""
@@ -2155,7 +2204,9 @@ java-pkg_do_write_() {
[[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
[[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
[[ -f "${JAVA_PKG_DEPEND_FILE}" ]] \
- && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND_FILE} | uniq | tr '\n' ':')\""
+ && echo "DEPEND=\"$(cat "${JAVA_PKG_DEPEND_FILE}" | uniq | tr '\n' ':')\""
+ [[ -f "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" ]] \
+ && echo "OPTIONAL_DEPEND=\"$(cat "${JAVA_PKG_OPTIONAL_DEPEND_FILE}" | uniq | tr '\n' ':')\""
echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
) > "${JAVA_PKG_ENV}"
@@ -2188,8 +2239,8 @@ java-pkg_do_write_() {
# TODO try to cleanup if possible
sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
else
- debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY or"
- debug-print "JAVA_PKG_DEPEND_FILE not defined so can't"
+ debug-print "JAVA_PKG_CLASSPATH, JAVA_PKG_LIBRARY, JAVA_PKG_DEPEND_FILE"
+ debug-print "or JAVA_PKG_OPTIONAL_DEPEND_FILE not defined so can't"
debug-print "write package.env."
fi
}
@@ -2197,14 +2248,23 @@ java-pkg_do_write_() {
# ------------------------------------------------------------------------------
# @internal-function java-pkg_record-jar_
#
-# Record a dependency to the package.env
-#
+# Record an (optional) dependency to the package.env
+# @param --optional - record dependency as optional
+# @param $1 - package to record
+# @param $2 - (optional) jar of package to record
# ------------------------------------------------------------------------------
JAVA_PKG_DEPEND_FILE="${T}/java-pkg-depend"
+JAVA_PKG_OPTIONAL_DEPEND_FILE="${T}/java-pkg-optional-depend"
java-pkg_record-jar_() {
debug-print-function ${FUNCNAME} $*
+ local depend_file="${JAVA_PKG_DEPEND_FILE}"
+ if [[ "${1}" == "--optional" ]]; then
+ depend_file="${JAVA_PKG_OPTIONAL_DEPEND_FILE}"
+ shift
+ fi
+
local pkg=${1} jar=${2} append
if [[ -z "${jar}" ]]; then
append="${pkg}"
@@ -2212,7 +2272,7 @@ java-pkg_record-jar_() {
append="$(basename ${jar})@${pkg}"
fi
- echo ${append} >> ${JAVA_PKG_DEPEND_FILE}
+ echo "${append}" >> "${depend_file}"
}
# ------------------------------------------------------------------------------