From: Vlastimil Babka Date: Tue, 24 Apr 2007 10:26:33 +0000 (+0000) Subject: Adding java-pkg_register-dependency() function. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=af6877e1233604e1cfcfa95814531aa350e63b41;p=gentoo.git Adding java-pkg_register-dependency() function. --- diff --git a/eclass/java-utils-2.eclass b/eclass/java-utils-2.eclass index 02f9da4bac80..46a44461cfa9 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.76 2007/04/20 16:17:49 caster Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.77 2007/04/24 10:26:33 caster Exp $ # ----------------------------------------------------------------------------- @@ -851,7 +851,7 @@ java-pkg_jar-from() { while [[ "${1}" == --* ]]; do if [[ "${1}" = "--build-only" ]]; then - build_only="true" + build_only="build" elif [[ "${1}" = "--with-dependencies" ]]; then deep="--with-dependencies" elif [[ "${1}" = "--into" ]]; then @@ -963,7 +963,7 @@ java-pkg_getjars() { while [[ "${1}" == --* ]]; do if [[ "${1}" = "--build-only" ]]; then - build_only="true" + build_only="build" elif [[ "${1}" = "--with-dependencies" ]]; then deep="--with-dependencies" else @@ -1031,7 +1031,7 @@ java-pkg_getjar() { while [[ "${1}" == --* ]]; do if [[ "${1}" = "--build-only" ]]; then - build_only="true" + build_only="build" else die "java-pkg_jar-from called with unknown parameter: ${1}" fi @@ -1068,6 +1068,59 @@ java-pkg_getjar() { return 1 } +# ------------------------------------------------------------------------------ +# @ebuild-function java-pkg_register-dependency +# +# Registers runtime dependency on a package, list of packages, or a single jar +# from a package, into package.env DEPEND line. Can only be called in +# src_install phase. +# 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 +# to depend on +# +# Example: Record the dependency on whole xerces-2 and xalan, +# java-pkg_register-dependency xerces-2,xalan +# Example: Record the dependency on ant.jar from ant-core +# java-pkg_register-dependency ant-core ant.jar +# +# 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-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_ensure-dep runtime "${pkg}" + java-pkg_record-jar_ "${pkg}" + done + else + [[ ${pkgs} == *,* ]] && \ + die "${FUNCNAME} called with both package list and jar name" + java-pkg_ensure-dep runtime "${pkgs}" + java-pkg_record-jar_ "${pkgs}" "${jar}" + fi + + java-pkg_do_write_ +} + # This function reads stdin, and based on that input, figures out how to # populate jars from the filesystem. # Need to figure out a good way of making use of this, ie be able to use a @@ -2360,20 +2413,20 @@ java-pkg_verify-classes() { # @internal-function java-pkg_ensure-dep # Check that a package being used in jarfrom, getjars and getjar is contained # within DEPEND or RDEPEND. -# @param $1 - Is the package a runtime dependency +# @param $1 - empty - check both vars; "runtime" or "build" - check only +# RDEPEND, resp. DEPEND # @param $2 - Package name and slot. - java-pkg_ensure-dep() { debug-print-function ${FUNCNAME} $* - local build_only="${1}" + local limit_to="${1}" local target_pkg="${2}" local dev_error="" local stripped_pkg=$(echo "${target_pkg}" | sed \ 's/-[0-9]*\(\.[0-9]\)*$//') - if [[ ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then + if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then dev_error="The ebuild is attempting to use ${target_pkg} that is not" dev_error="${dev_error} declared in DEPEND." if is-java-strict; then @@ -2386,16 +2439,16 @@ java-pkg_ensure-dep() { fi fi - if [[ -z ${build_only} && ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then + if [[ ${limit_to} != build && ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then dev_error="The ebuild is attempting to use ${target_pkg}," dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND." if is-java-strict; then die "${dev_error}" elif [[ ${BASH_SUBSHELL} = 0 ]]; then eerror "${dev_error}" - elog "Because you have this package installed the package will" - elog "build without problems, but please report this to" - elog "http://bugs.gentoo.org" + elog "The package will build without problems, but may fail to run" + elog "if you don't have ${target_pkg} installed, so please report" + elog "this to http://bugs.gentoo.org" fi fi }