/[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.157 Revision 1.162
1# Base eclass for Java packages 1# Base eclass for Java packages
2# 2#
3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org> 3# Copyright (c) 2004-2005, Thomas Matthijs <axxo@gentoo.org>
4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org> 4# Copyright (c) 2004, Karl Trygve Kalleberg <karltk@gentoo.org>
5# Copyright (c) 2004-2011, Gentoo Foundation 5# Copyright (c) 2004-2015, 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.157 2015/04/04 21:04:49 chewi Exp $ 9# $Header: /var/cvsroot/gentoo-x86/eclass/java-utils-2.eclass,v 1.162 2015/05/24 22:44:37 chewi Exp $
10 10
11# @ECLASS: java-utils-2.eclass 11# @ECLASS: java-utils-2.eclass
12# @MAINTAINER: 12# @MAINTAINER:
13# java@gentoo.org 13# java@gentoo.org
14# @AUTHOR: 14# @AUTHOR:
41# @INTERNAL 41# @INTERNAL
42# @DESCRIPTION: 42# @DESCRIPTION:
43# This is a convience variable to be used from the other java eclasses. This is 43# This is a convience variable to be used from the other java eclasses. This is
44# the version of java-config we want to use. Usually the latest stable version 44# the version of java-config we want to use. Usually the latest stable version
45# so that ebuilds can use new features without depending on specific versions. 45# so that ebuilds can use new features without depending on specific versions.
46JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.1.9-r1 ${JAVA_PKG_PORTAGE_DEP}" 46JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.2.0 ${JAVA_PKG_PORTAGE_DEP}"
47has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )" 47has source ${JAVA_PKG_IUSE} && JAVA_PKG_E_DEPEND="${JAVA_PKG_E_DEPEND} source? ( app-arch/zip )"
48 48
49# @ECLASS-VARIABLE: JAVA_PKG_WANT_BOOTCLASSPATH 49# @ECLASS-VARIABLE: JAVA_PKG_WANT_BOOTCLASSPATH
50# @DEFAULT_UNSET 50# @DEFAULT_UNSET
51# @DESCRIPTION: 51# @DESCRIPTION:
278 die "${jar} does not exist" 278 die "${jar} does not exist"
279 fi 279 fi
280 done 280 done
281 281
282 java-pkg_do_write_ 282 java-pkg_do_write_
283}
284
285# @FUNCTION: depend-java-query
286# @INTERNAL
287# @DESCRIPTION:
288# Wrapper for the depend-java-query binary to enable passing USE in env.
289# Using env variables keeps this eclass working with java-config versions that
290# do not handle use flags.
291depend-java-query() {
292 # Used to have a which call here but it caused endless loops for some people
293 # that had some weird bashrc voodoo for which.
294 USE="${USE}" /usr/bin/depend-java-query "${@}"
295} 283}
296 284
297# @FUNCTION: java-pkg_regjar 285# @FUNCTION: java-pkg_regjar
298# @USAGE: </path/to/installed/jar> 286# @USAGE: </path/to/installed/jar>
299# @DESCRIPTION: 287# @DESCRIPTION:
410 # if the lib exists... 398 # if the lib exists...
411 if [[ -e "${lib}" ]] ; then 399 if [[ -e "${lib}" ]] ; then
412 # install if it isn't a symlink 400 # install if it isn't a symlink
413 if [[ ! -L "${lib}" ]] ; then 401 if [[ ! -L "${lib}" ]] ; then
414 INSDESTTREE="${JAVA_PKG_LIBDEST}" \ 402 INSDESTTREE="${JAVA_PKG_LIBDEST}" \
415 INSOPTIONS="${LIBOPTIONS}" \ 403 INSOPTIONS="-m0755" \
416 doins "${lib}" || die "failed to install ${lib}" 404 doins "${lib}" || die "failed to install ${lib}"
417 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}" 405 java-pkg_append_ JAVA_PKG_LIBRARY "${JAVA_PKG_LIBDEST}"
418 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}" 406 debug-print "Installing ${lib} to ${JAVA_PKG_LIBDEST}"
419 # otherwise make a symlink to the symlink's origin 407 # otherwise make a symlink to the symlink's origin
420 else 408 else
918 java-pkg_record-jar_ "${target_pkg}" "${jar}" 906 java-pkg_record-jar_ "${target_pkg}" "${jar}"
919 else 907 else
920 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}" 908 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
921 fi 909 fi
922 fi 910 fi
923 # otherwise, if the current jar is the target jar, link it 911 # otherwise, if the current jar is the target jar, link it
924 elif [[ "${jar_name}" == "${target_jar}" ]] ; then 912 elif [[ "${jar_name}" == "${target_jar}" ]] ; then
925 [[ -f "${destjar}" ]] && rm "${destjar}" 913 [[ -f "${destjar}" ]] && rm "${destjar}"
926 ln -snf "${jar}" "${destjar}" \ 914 ln -snf "${jar}" "${destjar}" \
927 || die "Failed to make symlink from ${jar} to ${destjar}" 915 || die "Failed to make symlink from ${jar} to ${destjar}"
928 if [[ -z "${record_jar}" ]]; then 916 if [[ -z "${record_jar}" ]]; then
929 if [[ -z "${build_only}" ]]; then 917 if [[ -z "${build_only}" ]]; then
930 java-pkg_record-jar_ "${target_pkg}" "${jar}" 918 java-pkg_record-jar_ "${target_pkg}" "${jar}"
931 else 919 else
932 java-pkg_record-jar_ --build-only "${target_jar}" "${jar}" 920 java-pkg_record-jar_ --build-only "${target_pkg}" "${jar}"
933 fi 921 fi
934 fi 922 fi
935 popd > /dev/null 923 popd > /dev/null
936 return 0 924 return 0
937 fi 925 fi
1782# @DESCRIPTION: 1770# @DESCRIPTION:
1783# pkg_preinst Searches for missing and unneeded dependencies 1771# pkg_preinst Searches for missing and unneeded dependencies
1784# Don't call directly, but via java-pkg-2_pkg_preinst! 1772# Don't call directly, but via java-pkg-2_pkg_preinst!
1785java-utils-2_pkg_preinst() { 1773java-utils-2_pkg_preinst() {
1786 if is-java-strict; then 1774 if is-java-strict; then
1775 if [[ ! -e "${JAVA_PKG_ENV}" ]] || has ant-tasks ${INHERITED}; then
1776 return
1777 fi
1778
1787 if has_version dev-java/java-dep-check; then 1779 if has_version dev-java/java-dep-check; then
1788 [[ -e "${JAVA_PKG_ENV}" ]] || return
1789 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}") 1780 local output=$(GENTOO_VM= java-dep-check --image "${D}" "${JAVA_PKG_ENV}")
1790 if [[ ${output} && has_version <=dev-java/java-dep-check-0.2 ]]; then 1781 [[ ${output} ]] && ewarn "${output}"
1791 ewarn "Possibly unneeded dependencies found in package.env:"
1792 for dep in ${output}; do
1793 ewarn "\t${dep}"
1794 done
1795 fi
1796 if [[ ${output} && has_version >dev-java/java-dep-check-0.2 ]]; then
1797 ewarn "${output}"
1798 fi
1799 else 1782 else
1800 eerror "Install dev-java/java-dep-check for dependency checking" 1783 eerror "Install dev-java/java-dep-check for dependency checking"
1801 fi 1784 fi
1802 fi 1785 fi
1803} 1786}
1907 local gcp="${EANT_GENTOO_CLASSPATH}" 1890 local gcp="${EANT_GENTOO_CLASSPATH}"
1908 local getjarsarg="" 1891 local getjarsarg=""
1909 1892
1910 if [[ ${EBUILD_PHASE} = "test" ]]; then 1893 if [[ ${EBUILD_PHASE} = "test" ]]; then
1911 antflags="${antflags} -DJunit.present=true" 1894 antflags="${antflags} -DJunit.present=true"
1912 [[ ${ANT_TASKS} = *ant-junit* ]] && gcp="${gcp} junit"
1913 getjarsarg="--with-dependencies" 1895 getjarsarg="--with-dependencies"
1896
1897 local re="\bant-junit4?([-:]\S+)?\b"
1898 [[ ${ANT_TASKS} =~ ${re} ]] && gcp+=" ${BASH_REMATCH[0]}"
1914 else 1899 else
1915 antflags="${antflags} -Dmaven.test.skip=true" 1900 antflags="${antflags} -Dmaven.test.skip=true"
1916 fi 1901 fi
1917 1902
1918 local cp 1903 local cp
2671 2656
2672# @FUNCTION: java-pkg_ensure-dep 2657# @FUNCTION: java-pkg_ensure-dep
2673# @INTERNAL 2658# @INTERNAL
2674# @DESCRIPTION: 2659# @DESCRIPTION:
2675# Check that a package being used in jarfrom, getjars and getjar is contained 2660# Check that a package being used in jarfrom, getjars and getjar is contained
2676# within DEPEND or RDEPEND. 2661# within DEPEND or RDEPEND with the correct SLOT. See this mail for details:
2662# https://archives.gentoo.org/gentoo-dev/message/dcb644f89520f4bbb61cc7bbe45fdf6e
2677# @CODE 2663# @CODE
2678# Parameters: 2664# Parameters:
2679# $1 - empty - check both vars; "runtime" or "build" - check only 2665# $1 - empty - check both vars; "runtime" or "build" - check only
2680# RDEPEND, resp. DEPEND 2666# RDEPEND, resp. DEPEND
2681# $2 - Package name and slot. 2667# $2 - Package name and slot.
2685 2671
2686 local limit_to="${1}" 2672 local limit_to="${1}"
2687 local target_pkg="${2}" 2673 local target_pkg="${2}"
2688 local dev_error="" 2674 local dev_error=""
2689 2675
2690 # remove the version specification, which may include globbing (* and [123]) 2676 # Transform into a regular expression to look for a matching package
2691 local stripped_pkg=$(echo "${target_pkg}" | sed \ 2677 # and SLOT. SLOTs don't have to be numeric so foo-bar could either
2692 's/-\([0-9*]*\(\[[0-9]*\]\)*\)*\(\.\([0-9*]*\(\[[0-9]*\]\)*\)*\)*$//') 2678 # mean foo-bar:0 or foo:bar. So you want to get your head around the
2679 # line below?
2680 #
2681 # * The target package first has any dots escaped, e.g. foo-1.2
2682 # becomes foo-1\.2.
2683 #
2684 # * sed then looks at the component following the last - or :
2685 # character, or the whole string if there is no - or :
2686 # character. It uses this to build a new regexp with two
2687 # significant branches.
2688 #
2689 # * The first checks for the whole target package string, optionally
2690 # followed by a version number, and then :0.
2691 #
2692 # * The second checks for the first part of the target package
2693 # string, optionally followed by a version number, followed by the
2694 # aforementioned component, treating that as a SLOT.
2695 #
2696 local stripped_pkg=/$(sed -r 's/[-:]?([^-:]+)$/(\0(-[^:]+)?:0|(-[^:]+)?:\1)/' <<< "${target_pkg//./\\.}")\\b
2693 2697
2694 debug-print "Matching against: ${stripped_pkg}" 2698 debug-print "Matching against: ${stripped_pkg}"
2695 2699
2700 # Uncomment the lines below once we've dealt with more of these
2701 # otherwise we'll be tempted to turn JAVA_PKG_STRICT off while
2702 # getting hit with a wave of bug reports. :(
2703
2696 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ "$stripped_pkg" ) ]]; then 2704 if [[ ${limit_to} != runtime && ! ( "${DEPEND}" =~ $stripped_pkg ) ]]; then
2697 dev_error="The ebuild is attempting to use ${target_pkg} that is not" 2705 dev_error="The ebuild is attempting to use ${target_pkg}, which is not "
2698 dev_error="${dev_error} declared in DEPEND." 2706 dev_error+="declared with a SLOT in DEPEND."
2699 if is-java-strict; then 2707# if is-java-strict; then
2700 eerror "${dev_error}"
2701 die "${dev_error}" 2708# die "${dev_error}"
2702 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2709# else
2703 eerror "${dev_error}" 2710 eqawarn "java-pkg_ensure-dep: ${dev_error}"
2704 elog "Because you have this package installed the package will" 2711# eerror "Because you have ${target_pkg} installed,"
2705 elog "build without problems, but please report this to" 2712# eerror "the package will build without problems, but please"
2706 elog "http://bugs.gentoo.org" 2713# eerror "report this to http://bugs.gentoo.org."
2707 fi 2714# fi
2708 fi 2715 elif [[ ${limit_to} != build && ! ( "${RDEPEND}${PDEPEND}" =~ ${stripped_pkg} ) ]]; then
2709
2710 if [[ ${limit_to} != build ]]; then
2711 if [[ ! ( ${RDEPEND} =~ "${stripped_pkg}" ) ]]; then
2712 if [[ ! ( ${PDEPEND} =~ "${stripped_pkg}" ) ]]; then
2713 dev_error="The ebuild is attempting to use ${target_pkg}," 2716 dev_error="The ebuild is attempting to use ${target_pkg}, which is not "
2714 dev_error="${dev_error} without specifying --build-only, that is not declared in RDEPEND" 2717 dev_error+="declared with a SLOT in [RP]DEPEND and --build-only wasn't given."
2715 dev_error="${dev_error} or PDEPEND."
2716 if is-java-strict; then 2718# if is-java-strict; then
2717 eerror "${dev_error}"
2718 die "${dev_error}" 2719# die "${dev_error}"
2719 elif [[ ${BASH_SUBSHELL} = 0 ]]; then 2720# else
2720 eerror "${dev_error}" 2721 eqawarn "java-pkg_ensure-dep: ${dev_error}"
2721 elog "The package will build without problems, but may fail to run" 2722# eerror "The package will build without problems, but may fail to run"
2722 elog "if you don't have ${target_pkg} installed, so please report" 2723# eerror "if you don't have ${target_pkg} installed,"
2723 elog "this to http://bugs.gentoo.org" 2724# eerror "so please report this to http://bugs.gentoo.org."
2724 fi
2725 fi
2726 fi 2725# fi
2727 fi 2726 fi
2728} 2727}
2729 2728
2730java-pkg_check-phase() { 2729java-pkg_check-phase() {
2731 local phase=${1} 2730 local phase=${1}

Legend:
Removed from v.1.157  
changed lines
  Added in v.1.162

  ViewVC Help
Powered by ViewVC 1.1.20