/[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.16 Revision 1.33
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.33 2006/12/07 02:27:22 flameeyes Exp $
9 10
10 11
11# ----------------------------------------------------------------------------- 12# -----------------------------------------------------------------------------
12# @eclass-begin 13# @eclass-begin
13# @eclass-shortdesc Java Utility eclass 14# @eclass-shortdesc Java Utility eclass
14# @eclass-maintainer java@gentoo.org 15# @eclass-maintainer java@gentoo.org
15# 16#
16# This eclass provides functionality which is used by 17# This eclass provides functionality which is used by
17# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds. 18# java-pkg.eclass and java-pkg-opt.eclass as well as from ebuilds.
18# 19#
19# @warning 20# @warning
20# You probably don't want to inherit this directly from an ebuild. Instead, 21# You probably don't want to inherit this directly from an ebuild. Instead,
21# you should inherit java-ant for Ant-based Java packages, java-pkg for other 22# you should inherit java-ant for Ant-based Java packages, java-pkg for other
22# Java packages, or java-pkg-opt for packages that have optional Java support. 23# Java packages, or java-pkg-opt for packages that have optional Java support.
23# 24#
24# ----------------------------------------------------------------------------- 25# -----------------------------------------------------------------------------
25 26
26inherit eutils versionator multilib 27inherit eutils versionator multilib
28
29IUSE="elibc_FreeBSD"
27 30
28# ----------------------------------------------------------------------------- 31# -----------------------------------------------------------------------------
29# @section-begin variables 32# @section-begin variables
30# @section-title Variables 33# @section-title Variables
31# 34#
40 43
41# ----------------------------------------------------------------------------- 44# -----------------------------------------------------------------------------
42# @variable-internal JAVA_PKG_E_DEPEND 45# @variable-internal JAVA_PKG_E_DEPEND
43# 46#
44# This is a convience variable to be used from the other java eclasses. This is 47# This is a convience variable to be used from the other java eclasses. This is
45# the version of java-config we want to use. We also need a recent version 48# the version of java-config we want to use. We also need a recent version
46# portage, that includes phase hooks. 49# portage, that includes phase hooks.
47# ----------------------------------------------------------------------------- 50# -----------------------------------------------------------------------------
48JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}" 51JAVA_PKG_E_DEPEND=">=dev-java/java-config-2.0.19-r1 ${JAVA_PKG_PORTAGE_DEP}"
49 52
50# ----------------------------------------------------------------------------- 53# -----------------------------------------------------------------------------
100# ----------------------------------------------------------------------------- 103# -----------------------------------------------------------------------------
101 104
102# ----------------------------------------------------------------------------- 105# -----------------------------------------------------------------------------
103# @variable-internal JAVA_PKG_COMPILER_DIR 106# @variable-internal JAVA_PKG_COMPILER_DIR
104# @default /usr/share/java-config-2/compiler 107# @default /usr/share/java-config-2/compiler
105# 108#
106# Directory where compiler settings are saved, without trailing slash. 109# Directory where compiler settings are saved, without trailing slash.
107# Probably shouldn't touch this variable. 110# Probably shouldn't touch this variable.
108# ----------------------------------------------------------------------------- 111# -----------------------------------------------------------------------------
109JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"} 112JAVA_PKG_COMPILER_DIR=${JAVA_PKG_COMPILER_DIR:="/usr/share/java-config-2/compiler"}
110 113
120 123
121# ----------------------------------------------------------------------------- 124# -----------------------------------------------------------------------------
122# @variable-external JAVA_PKG_FORCE_COMPILER 125# @variable-external JAVA_PKG_FORCE_COMPILER
123# 126#
124# Explicitly set a list of compilers to use. This is normally read from 127# Explicitly set a list of compilers to use. This is normally read from
125# JAVA_PKG_COMPILERS_CONF. 128# JAVA_PKG_COMPILERS_CONF.
126# 129#
127# @note This should only be used internally or for testing. 130# @note This should only be used internally or for testing.
128# @example Use jikes and javac, in that order 131# @example Use jikes and javac, in that order
129# JAVA_PKG_FORCE_COMPILER="jikes javac" 132# JAVA_PKG_FORCE_COMPILER="jikes javac"
130# ----------------------------------------------------------------------------- 133# -----------------------------------------------------------------------------
150# @ebuild-function java-pkg_dojar 153# @ebuild-function java-pkg_dojar
151# 154#
152# Installs any number of jars. 155# Installs any number of jars.
153# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default. 156# Jar's will be installed into /usr/share/${PN}(-${SLOT})/lib/ by default.
154# You can use java-pkg_jarinto to change this path. 157# You can use java-pkg_jarinto to change this path.
155# You should never install a jar with a package version in the filename. 158# You should never install a jar with a package version in the filename.
156# Instead, use java-pkg_newjar defined below. 159# Instead, use java-pkg_newjar defined below.
157# 160#
158# @example 161# @example
159# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar 162# java-pkg_dojar dist/${PN}.jar dist/${PN}-core.jar
160# 163#
222# will not work, because: 225# will not work, because:
223# * the `for jar in "$@"` can't expand the path to jar file names, as they 226# * the `for jar in "$@"` can't expand the path to jar file names, as they
224# don't exist yet 227# don't exist yet
225# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar' 228# * all `if ...` inside for will fail - the file '/opt/my-java/lib/*.jar'
226# doesn't exist 229# doesn't exist
227# 230#
228# you have to use it as: 231# you have to use it as:
229# 232#
230# java-pkg_regjar ${D}/opt/my-java/lib/*.jar 233# java-pkg_regjar ${D}/opt/my-java/lib/*.jar
231# 234#
232# @param $@ - jars to record 235# @param $@ - jars to record
287 cp "${original_jar}" "${new_jar_dest}" \ 290 cp "${original_jar}" "${new_jar_dest}" \
288 || die "Failed to copy ${original_jar} to ${new_jar_dest}" 291 || die "Failed to copy ${original_jar} to ${new_jar_dest}"
289 java-pkg_dojar "${new_jar_dest}" 292 java-pkg_dojar "${new_jar_dest}"
290} 293}
291 294
292
293# ------------------------------------------------------------------------------ 295# ------------------------------------------------------------------------------
294# @ebuild-function java-pkg_addcp 296# @ebuild-function java-pkg_addcp
295# 297#
296# Add something to the package's classpath. For jars, you should use dojar, 298# Add something to the package's classpath. For jars, you should use dojar,
297# newjar, or regjar. This is typically used to add directories to the classpath. 299# newjar, or regjar. This is typically used to add directories to the classpath.
302java-pkg_addcp() { 304java-pkg_addcp() {
303 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}" 305 java-pkg_append_ JAVA_PKG_CLASSPATH "${@}"
304 java-pkg_do_write_ 306 java-pkg_do_write_
305} 307}
306 308
307
308# ------------------------------------------------------------------------------ 309# ------------------------------------------------------------------------------
309# @ebuild-function java-pkg_doso 310# @ebuild-function java-pkg_doso
310# 311#
311# Installs any number of JNI libraries 312# Installs any number of JNI libraries
312# They will be installed into /usr/lib by default, but java-pkg_sointo 313# They will be installed into /usr/lib by default, but java-pkg_sointo
313# can be used change this path 314# can be used change this path
314# 315#
315# Example: 316# Example:
370 java-pkg_check-phase install 371 java-pkg_check-phase install
371 372
372 [[ ${#} -lt 1 ]] && "at least one argument needed" 373 [[ ${#} -lt 1 ]] && "at least one argument needed"
373 374
374 java-pkg_init_paths_ 375 java-pkg_init_paths_
375 376
376 local lib target_dir 377 local lib target_dir
377 for lib in "$@" ; do 378 for lib in "$@" ; do
378 # Check the absolute path of the lib 379 # Check the absolute path of the lib
379 if [[ -e "${lib}" ]] ; then 380 if [[ -e "${lib}" ]] ; then
380 target_dir="$(java-pkg_expand_dir_ ${lib})" 381 target_dir="$(java-pkg_expand_dir_ ${lib})"
428# ------------------------------------------------------------------------------ 429# ------------------------------------------------------------------------------
429java-pkg_dohtml() { 430java-pkg_dohtml() {
430 debug-print-function ${FUNCNAME} $* 431 debug-print-function ${FUNCNAME} $*
431 432
432 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}" 433 [[ ${#} -lt 1 ]] && die "At least one argument required for ${FUNCNAME}"
433 # TODO-nichoj find out what exactly -f package-list does 434
435 # from /usr/lib/portage/bin/dohtml -h
436 # -f Set list of allowed extensionless file names.
434 dohtml -f package-list "$@" 437 dohtml -f package-list "$@"
438
435 # this probably shouldn't be here but it provides 439 # this probably shouldn't be here but it provides
436 # a reasonable way to catch # docs for all of the 440 # a reasonable way to catch # docs for all of the
437 # old ebuilds. 441 # old ebuilds.
438 java-pkg_recordjavadoc 442 java-pkg_recordjavadoc
439} 443}
440 444
441# TODO document 445# ------------------------------------------------------------------------------
446# @ebuild-function java-pkg_dojavadoc
447#
448# Installs javadoc documentation. This should be controlled by the doc use flag.
449#
450# @param $1: - The javadoc root directory.
451#
452# @example:
453# java-pkg_dojavadoc docs/api
454#
455# ------------------------------------------------------------------------------
442java-pkg_dojavadoc() { 456java-pkg_dojavadoc() {
443 local dir="$1" 457 local dir="$1"
444 458
445 java-pkg_check-phase install 459 java-pkg_check-phase install
446 460
458} 472}
459 473
460# ------------------------------------------------------------------------------ 474# ------------------------------------------------------------------------------
461# @ebuild-function java-pkg_dosrc 475# @ebuild-function java-pkg_dosrc
462# 476#
463# Installs a zip containing the source for a package, so it can used in 477# Installs a zip containing the source for a package, so it can used in
464# from IDEs like eclipse and netbeans. 478# from IDEs like eclipse and netbeans.
465# 479#
466# Ebuild needs to DEPEND on app-arch/zip to use this. 480# Ebuild needs to DEPEND on app-arch/zip to use this.
467# 481#
468# It also should be controlled by USE=source. 482# It also should be controlled by USE=source.
469# 483#
470# @example: 484# @example:
471# java-pkg_dosrc src/* 485# java-pkg_dosrc src/*
472# 486#
473# ------------------------------------------------------------------------------ 487# ------------------------------------------------------------------------------
474# TODO change so it the arguments it takes are the base directories containing 488# TODO change so it the arguments it takes are the base directories containing
475# source -nichoj 489# source -nichoj
476# TODO should we be able to handle multiple calls to dosrc? -nichoj 490# TODO should we be able to handle multiple calls to dosrc? -nichoj
477# TODO maybe we can take an existing zip/jar? -nichoj 491# TODO maybe we can take an existing zip/jar? -nichoj
478# FIXME apparently this fails if you give it an empty directories 492# FIXME apparently this fails if you give it an empty directories
479java-pkg_dosrc() { 493java-pkg_dosrc() {
480 debug-print-function ${FUNCNAME} $* 494 debug-print-function ${FUNCNAME} $*
481 495
482 [ ${#} -lt 1 ] && die "At least one argument needed" 496 [ ${#} -lt 1 ] && die "At least one argument needed"
483 if ! hasq source ${IUSE}; then 497 if ! hasq source ${IUSE}; then
484 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE" 498 echo "Java QA Notice: ${FUNCNAME} called without source in IUSE"
485 fi 499 fi
486 500
487 java-pkg_check-phase install 501 java-pkg_check-phase install
488 502
489 [[ ${#} -lt 1 ]] && die "At least one argument needed" 503 [[ ${#} -lt 1 ]] && die "At least one argument needed"
490 504
491 java-pkg_init_paths_ 505 java-pkg_init_paths_
492 506
493 local zip_name="${PN}-src.zip" 507 local zip_name="${PN}-src.zip"
494 local zip_path="${T}/${zip_name}" 508 local zip_path="${T}/${zip_name}"
518# @ebuild-function java-pkg_dolauncher 532# @ebuild-function java-pkg_dolauncher
519# 533#
520# Make a wrapper script to lauch/start this package 534# Make a wrapper script to lauch/start this package
521# If necessary, the wrapper will switch to the appropriate VM. 535# If necessary, the wrapper will switch to the appropriate VM.
522# 536#
537# Can be called without parameters if the package installs only one jar
538# that has the Main-class attribute set. The wrapper will be named ${PN}.
539#
523# @param $1 - filename of launcher to create 540# @param $1 - filename of launcher to create
524# @param $2 - options, as follows: 541# @param $2 - options, as follows:
525# --main the.main.class.too.start 542# --main the.main.class.too.start
526# --jar /the/jar/too/launch.jar 543# --jar /the/jar/too/launch.jar or just <name>.jar
527# --java_args 'Extra arguments to pass too jave' 544# --java_args 'Extra arguments to pass to java'
528# --pkg_args 'extra arguments too pass too the package' 545# --pkg_args 'Extra arguments too pass to the package'
529# --pwd 546# --pwd
530# -into 547# -into
531# -pre 548# -pre
532# ------------------------------------------------------------------------------ 549# ------------------------------------------------------------------------------
533java-pkg_dolauncher() { 550java-pkg_dolauncher() {
534 debug-print-function ${FUNCNAME} $* 551 debug-print-function ${FUNCNAME} $*
535 552
536 java-pkg_check-phase install 553 java-pkg_check-phase install
537
538 [[ ${#} -lt 1 ]] && die "Need at least one argument"
539
540 java-pkg_init_paths_ 554 java-pkg_init_paths_
541 555
556 if [[ ${#} = 0 ]]; then
557 local name="${PN}"
558 else
542 local name="${1}" 559 local name="${1}"
560 shift
561 fi
562
543 # TODO rename to launcher 563 # TODO rename to launcher
544 local target="${T}/${name}" 564 local target="${T}/${name}"
565 local var_tmp="${T}/launcher_variables_tmp"
545 local target_dir pre 566 local target_dir pre
546 shift
547 567
548 echo "#!/bin/bash" > "${target}" 568 # Process the other the rest of the arguments
549 while [[ -n "${1}" && -n "${2}" ]]; do 569 while [[ -n "${1}" && -n "${2}" ]]; do
550 local var=${1} value=${2} 570 local var=${1} value=${2}
551 if [[ "${var:0:2}" == "--" ]]; then 571 if [[ "${var:0:2}" == "--" ]]; then
572 local var=${var:2}
552 echo "gjl_${var:2}=\"${value}\"" >> "${target}" 573 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
574 local gjl_${var}="${value}"
553 elif [[ "${var}" == "-into" ]]; then 575 elif [[ "${var}" == "-into" ]]; then
554 target_dir="${value}" 576 target_dir="${value}"
555 elif [[ "${var}" == "-pre" ]]; then 577 elif [[ "${var}" == "-pre" ]]; then
556 pre="${value}" 578 pre="${value}"
557 fi 579 fi
558 shift 2 580 shift 2
559 done 581 done
582
583 # Test if no --jar and --main arguments were given and
584 # in that case check if the package only installs one jar
585 # and use that jar.
586 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
587 local cp="${JAVA_PKG_CLASSPATH}"
588 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
589 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
590 else
591 local msg="Not enough information to create a launcher given."
592 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
593 die "${msg}"
594 fi
595 fi
596
597 # Write the actual script
598 echo "#!/bin/bash" > "${target}"
599 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}"
560 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 600 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
561 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 601 cat "${var_tmp}" >> "${target}"
602 rm -f "${var_tmp}"
562 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 603 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
563 604
564 if [[ -n "${into}" ]]; then 605 if [[ -n "${target_dir}" ]]; then
565 DESTTREE="${target_dir}" dobin "${target}" 606 DESTTREE="${target_dir}" dobin "${target}"
566 local ret=$? 607 local ret=$?
567 return ${ret} 608 return ${ret}
568 else 609 else
569 dobin "${target}" 610 dobin "${target}"
597 echo "dowar: warning, skipping directory ${war}" 638 echo "dowar: warning, skipping directory ${war}"
598 continue 639 continue
599 else 640 else
600 warpath="${war}" 641 warpath="${war}"
601 fi 642 fi
602 643
603 # Install those files like you mean it 644 # Install those files like you mean it
604 INSOPTIONS="-m 0644" \ 645 INSOPTIONS="-m 0644" \
605 INSDESTTREE=${JAVA_PKG_WARDEST} \ 646 INSDESTTREE=${JAVA_PKG_WARDEST} \
606 doins ${warpath} 647 doins ${warpath}
607 done 648 done
673 if [[ "${1}" = "--build-only" ]]; then 714 if [[ "${1}" = "--build-only" ]]; then
674 build_only="true" 715 build_only="true"
675 shift 716 shift
676 fi 717 fi
677 718
678 local target_pkg="${1}" target_jar="${2}" destjar="${3}" 719 local target_pkg="${1}" target_jar="${2}" destjar="${3}"
679 720
680 [[ -z ${target_pkg} ]] && die "Must specify a package" 721 [[ -z ${target_pkg} ]] && die "Must specify a package"
681 722
682 # default destjar to the target jar 723 # default destjar to the target jar
683 [[ -z "${destjar}" ]] && destjar="${target_jar}" 724 [[ -z "${destjar}" ]] && destjar="${target_jar}"
684 725
726 local error_msg="There was a problem getting the classpath for ${target_pkg}."
727 local classpath
685 local classpath="$(java-config --classpath=${target_pkg})" 728 classpath="$(java-config --classpath=${target_pkg})"
686 [[ $? != 0 ]] && die "There was a problem getting the classpath for ${target_pkg}" 729 [[ $? != 0 ]] && die ${error_msg}
687 730
688 local jar 731 local jar
689 for jar in ${classpath//:/ }; do 732 for jar in ${classpath//:/ }; do
690 local jar_name=$(basename "${jar}") 733 local jar_name=$(basename "${jar}")
691 if [[ ! -f "${jar}" ]] ; then 734 if [[ ! -f "${jar}" ]] ; then
732# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'. 775# Among other things, this can be passed to 'javac -classpath' or 'ant -lib'.
733# The providing packages are recorded as dependencies into package.env DEPEND 776# The providing packages are recorded as dependencies into package.env DEPEND
734# line, unless "--build-only" is passed as the very first argument, for jars 777# line, unless "--build-only" is passed as the very first argument, for jars
735# that have to be present only at build time and are not needed on runtime 778# that have to be present only at build time and are not needed on runtime
736# (junit testing etc). 779# (junit testing etc).
737# 780#
738# Example: Get the classpath for xerces-2, 781# Example: Get the classpath for xerces-2 and xalan,
739# java-pkg_getjars xerces-2 xalan 782# java-pkg_getjars xerces-2,xalan
740# Example Return: 783# Example Return:
741# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar 784# /usr/share/xerces-2/lib/xml-apis.jar:/usr/share/xerces-2/lib/xmlParserAPIs.jar:/usr/share/xalan/lib/xalan.jar
742# 785#
743# @param $1 - (optional) "--build-only" makes the jar(s) not added into 786# @param $1 - (optional) "--build-only" makes the jar(s) not added into
744# package.env DEPEND line. 787# package.env DEPEND line.
745# @param $@ - list of packages to get jars from 788# @param $2 - list of packages to get jars from
789# (passed to java-config --classpath)
746# ------------------------------------------------------------------------------ 790# ------------------------------------------------------------------------------
747java-pkg_getjars() { 791java-pkg_getjars() {
748 debug-print-function ${FUNCNAME} $* 792 debug-print-function ${FUNCNAME} $*
749 793
750 local build_only="" 794 [[ ${#} -lt 1 || ${#} -gt 2 ]] && die "${FUNCNAME} takes only one or two arguments"
751 795
752 if [[ "${1}" = "--build-only" ]]; then 796 if [[ "${1}" = "--build-only" ]]; then
753 build_only="true" 797 local build_only="true"
754 shift 798 shift
755 fi 799 fi
756 800
757 [[ ${#} -lt 1 ]] && die "At least one argument needed"
758
759 # NOTE could probably just pass $@ to java-config --classpath. and return it
760 local classpath pkg 801 local classpath pkgs="${1}"
761 for pkg in ${@//,/ }; do
762 #for pkg in $(echo "$@" | tr ',' ' '); do
763 jars="$(java-config --classpath=${pkg})" 802 jars="$(java-config --classpath=${pkgs})"
803 [[ -z "${jars}" ]] && die "java-config --classpath=${pkgs} failed"
764 debug-print "${pkg}:${jars}" 804 debug-print "${pkgs}:${jars}"
765 # TODO should we ensure jars exist? 805
766 if [[ -z "${classpath}" ]]; then 806 if [[ -z "${classpath}" ]]; then
767 classpath="${jars}" 807 classpath="${jars}"
768 else 808 else
769 classpath="${classpath}:${jars}" 809 classpath="${classpath}:${jars}"
770 fi 810 fi
811
771 # Only record jars that aren't build-only 812 # Only record jars that aren't build-only
772 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" 813 if [[ -z "${build_only}" ]]; then
814 oldifs="${IFS}"
815 IFS=","
816 for pkg in ${pkgs}; do
817 java-pkg_record-jar_ "${pkg}"
773 done 818 done
819 IFS="${oldifs}"
820 fi
821
774 echo "${classpath}" 822 echo "${classpath}"
775} 823}
776 824
777# ------------------------------------------------------------------------------ 825# ------------------------------------------------------------------------------
778# @ebuild-function java-pkg_getjar 826# @ebuild-function java-pkg_getjar
785# 833#
786# @example 834# @example
787# java-pkg_getjar xerces-2 xml-apis.jar 835# java-pkg_getjar xerces-2 xml-apis.jar
788# @example-return 836# @example-return
789# /usr/share/xerces-2/lib/xml-apis.jar 837# /usr/share/xerces-2/lib/xml-apis.jar
790# 838#
791# @param $1 - (optional) "--build-only" makes the jar not added into 839# @param $1 - (optional) "--build-only" makes the jar not added into
792# package.env DEPEND line. 840# package.env DEPEND line.
793# @param $1 - package to use 841# @param $1 - package to use
794# @param $2 - jar to get 842# @param $2 - jar to get
795# ------------------------------------------------------------------------------ 843# ------------------------------------------------------------------------------
805 853
806 local pkg="${1}" target_jar="${2}" jar 854 local pkg="${1}" target_jar="${2}" jar
807 [[ -z ${pkg} ]] && die "Must specify package to get a jar from" 855 [[ -z ${pkg} ]] && die "Must specify package to get a jar from"
808 [[ -z ${target_jar} ]] && die "Must specify jar to get" 856 [[ -z ${target_jar} ]] && die "Must specify jar to get"
809 857
810 # TODO check that package is actually installed 858 local error_msg="Could not find classpath for ${pkg}. Are you sure its installed?"
859 local classpath
811 local classpath=$(java-config --classpath=${pkg}) 860 classpath=$(java-config --classpath=${pkg})
812 [[ $? != 0 ]] && die "There could not find classpath for ${pkg}. Are you sure its installed?" 861 [[ $? != 0 ]] && die ${error_msg}
862
813 for jar in ${classpath//:/ }; do 863 for jar in ${classpath//:/ }; do
814 if [[ ! -f "${jar}" ]] ; then 864 if [[ ! -f "${jar}" ]] ; then
815 die "Installation problem with jar ${jar} in ${pkg} - is it installed?" 865 die "Installation problem with jar ${jar} in ${pkg} - is it installed?"
816 fi 866 fi
817 867
820 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}" 870 [[ -z "${build_only}" ]] && java-pkg_record-jar_ "${pkg}" "${jar}"
821 echo "${jar}" 871 echo "${jar}"
822 return 0 872 return 0
823 fi 873 fi
824 done 874 done
825 875
826 die "Could not find ${target_jar} in ${pkg}" 876 die "Could not find ${target_jar} in ${pkg}"
827 return 1 877 return 1
828} 878}
829 879
830# This function reads stdin, and based on that input, figures out how to 880# This function reads stdin, and based on that input, figures out how to
844# line="${line// /}" 894# line="${line// /}"
845# 895#
846# # format: path=jarinfo 896# # format: path=jarinfo
847# local path=${line%%=*} 897# local path=${line%%=*}
848# local jarinfo=${line##*=} 898# local jarinfo=${line##*=}
849# 899#
850# # format: jar@package 900# # format: jar@package
851# local jar=${jarinfo%%@*}.jar 901# local jar=${jarinfo%%@*}.jar
852# local package=${jarinfo##*@} 902# local package=${jarinfo##*@}
853# if [[ -n ${replace_only} ]]; then 903# if [[ -n ${replace_only} ]]; then
854# [[ ! -f $path ]] && die "No jar exists at ${path}" 904# [[ ! -f $path ]] && die "No jar exists at ${path}"
867# @section-end query 917# @section-end query
868# ------------------------------------------------------------------------------ 918# ------------------------------------------------------------------------------
869 919
870# ------------------------------------------------------------------------------ 920# ------------------------------------------------------------------------------
871# @section-begin helper 921# @section-begin helper
872# @section-summary Helper functions 922# @section-summary Helper functions
873# 923#
874# Various other functions to use from an ebuild 924# Various other functions to use from an ebuild
875# ------------------------------------------------------------------------------ 925# ------------------------------------------------------------------------------
876 926
877# ------------------------------------------------------------------------------ 927# ------------------------------------------------------------------------------
883# jdbc-stdext 933# jdbc-stdext
884# jaf 934# jaf
885# jdbc-rowset 935# jdbc-rowset
886# jms 936# jms
887# 937#
888# @param $1 - Optionally indicate that the dependencies are controlled by 938# @param $1 - Optionally indicate that the dependencies are controlled by
889# a use flag by specifying '--use' Requires $2. 939# a use flag by specifying '--use' Requires $2.
890# @param $2 - USE flag which will enable the dependencies. 940# @param $2 - USE flag which will enable the dependencies.
891# @param $@ - virtual packages to add depenedencies for 941# @param $@ - virtual packages to add depenedencies for
892# ------------------------------------------------------------------------------ 942# ------------------------------------------------------------------------------
893# TODO rewrite to parse a line based declaration file instead -- karltk 943# TODO rewrite to parse a line based declaration file instead -- karltk
987 fi 1037 fi
988} 1038}
989 1039
990# ------------------------------------------------------------------------------ 1040# ------------------------------------------------------------------------------
991# @internal-function java-pkg_is-vm-version-sufficient 1041# @internal-function java-pkg_is-vm-version-sufficient
992# 1042#
993# @return zero - VM is sufficient 1043# @return zero - VM is sufficient
994# @return non-zero - VM is not sufficient 1044# @return non-zero - VM is not sufficient
995# ------------------------------------------------------------------------------ 1045# ------------------------------------------------------------------------------
996java-pkg_is-vm-version-sufficient() { 1046java-pkg_is-vm-version-sufficient() {
997 debug-print-function ${FUNCNAME} $* 1047 debug-print-function ${FUNCNAME} $*
1017 die "Active Java VM too old" 1067 die "Active Java VM too old"
1018 fi 1068 fi
1019} 1069}
1020 1070
1021# ------------------------------------------------------------------------------ 1071# ------------------------------------------------------------------------------
1022# @internal-function java-pkg_is-vm-version-eq 1072# @internal-function java-pkg_is-vm-version-eq
1023# 1073#
1024# @param $@ - VM version to compare current VM to 1074# @param $@ - VM version to compare current VM to
1025# @return zero - VM versions are equal 1075# @return zero - VM versions are equal
1026# @return non-zero - VM version are not equal 1076# @return non-zero - VM version are not equal
1027# ------------------------------------------------------------------------------ 1077# ------------------------------------------------------------------------------
1028java-pkg_is-vm-version-eq() { 1078java-pkg_is-vm-version-eq() {
1058# 1108#
1059# @param $@ - VM version to compare current to 1109# @param $@ - VM version to compare current to
1060# ------------------------------------------------------------------------------ 1110# ------------------------------------------------------------------------------
1061java-pkg_ensure-vm-version-ge() { 1111java-pkg_ensure-vm-version-ge() {
1062 debug-print-function ${FUNCNAME} $* 1112 debug-print-function ${FUNCNAME} $*
1063 1113
1064 if ! java-pkg_is-vm-version-ge "$@" ; then 1114 if ! java-pkg_is-vm-version-ge "$@" ; then
1065 debug-print "vm is not suffient" 1115 debug-print "vm is not suffient"
1066 eerror "This package requires a Java VM version >= $@" 1116 eerror "This package requires a Java VM version >= $@"
1067 einfo "Please use java-config -S to set the correct one" 1117 einfo "Please use java-config -S to set the correct one"
1068 die "Active Java VM too old" 1118 die "Active Java VM too old"
1069 fi 1119 fi
1070} 1120}
1071 1121
1072# ------------------------------------------------------------------------------ 1122# ------------------------------------------------------------------------------
1073# @internal-function java-pkg_is-vm-version-ge 1123# @internal-function java-pkg_is-vm-version-ge
1074# 1124#
1075# @param $@ - VM version to compare current VM to 1125# @param $@ - VM version to compare current VM to
1076# @return zero - current VM version is greater than checked version 1126# @return zero - current VM version is greater than checked version
1077# @return non-zero - current VM version is not greater than checked version 1127# @return non-zero - current VM version is not greater than checked version
1078# ------------------------------------------------------------------------------ 1128# ------------------------------------------------------------------------------
1079java-pkg_is-vm-version-ge() { 1129java-pkg_is-vm-version-ge() {
1108 return $? 1158 return $?
1109} 1159}
1110 1160
1111# ------------------------------------------------------------------------------ 1161# ------------------------------------------------------------------------------
1112# @ebuild-function java-pkg_get-source 1162# @ebuild-function java-pkg_get-source
1113# 1163#
1114# Determines what source version should be used, for passing to -source. 1164# Determines what source version should be used, for passing to -source.
1115# Unless you want to break things you probably shouldn't set _WANT_SOURCE 1165# Unless you want to break things you probably shouldn't set _WANT_SOURCE
1116# 1166#
1117# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE 1167# @return string - Either the lowest possible source, or JAVA_PKG_WANT_SOURCE
1118# ------------------------------------------------------------------------------ 1168# ------------------------------------------------------------------------------
1123# ------------------------------------------------------------------------------ 1173# ------------------------------------------------------------------------------
1124# @ebuild-function java-pkg_get-target 1174# @ebuild-function java-pkg_get-target
1125# 1175#
1126# Determines what target version should be used, for passing to -target. 1176# Determines what target version should be used, for passing to -target.
1127# If you don't care about lower versions, you can set _WANT_TARGET to the 1177# If you don't care about lower versions, you can set _WANT_TARGET to the
1128# version of your JDK. 1178# version of your JDK.
1129# Remember doing this will mostly like cause things to break. 1179# Remember doing this will mostly like cause things to break.
1130# Doesn't allow it to be lower then the one in depend. 1180# Doesn't allow it to be lower then the one in depend.
1131# Doesn't allow it to be higher then the active vm. 1181# Doesn't allow it to be higher then the active vm.
1132# 1182#
1133# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET 1183# @return string - Either the lowest possible target, or JAVA_PKG_WANT_TARGET
1134# ------------------------------------------------------------------------------ 1184# ------------------------------------------------------------------------------
1135java-pkg_get-target() { 1185java-pkg_get-target() {
1136 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}") 1186 local min=$(depend-java-query --get-lowest "${DEPEND} ${RDEPEND}")
1137 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then 1187 if [[ -n "${JAVA_PKG_WANT_TARGET}" ]]; then
1138 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)" 1188 local max="$(java-config --select-vm "${GENTOO_VM}" -g PROVIDES_VERSION)"
1139 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then 1189 if version_is_at_least "${min}" "${JAVA_PKG_WANT_TARGET}" && version_is_at_least "${JAVA_PKG_WANT_TARGET}" "${max}"; then
1140 echo ${JAVA_PKG_WANT_TARGET} 1190 echo ${JAVA_PKG_WANT_TARGET}
1141 else 1191 else
1149} 1199}
1150 1200
1151java-pkg_get-javac() { 1201java-pkg_get-javac() {
1152 debug-print-function ${FUNCNAME} $* 1202 debug-print-function ${FUNCNAME} $*
1153 1203
1154 java-pkg_init-compiler_ 1204
1155 local compiler="${GENTOO_COMPILER}" 1205 local compiler="${GENTOO_COMPILER}"
1156 1206
1157 local compiler_executable 1207 local compiler_executable
1158 if [[ "${compiler}" = "javac" ]]; then 1208 if [[ "${compiler}" = "javac" ]]; then
1159 # nothing fancy needs to be done for javac 1209 # nothing fancy needs to be done for javac
1167 unset JAVAC 1217 unset JAVAC
1168 # try to get value of JAVAC 1218 # try to get value of JAVAC
1169 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1219 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1170 export JAVAC=${old_javac} 1220 export JAVAC=${old_javac}
1171 1221
1172 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1222 if [[ -z ${compiler_executable} ]]; then
1173 1223 echo "JAVAC is empty or undefined in ${compiler_env}"
1224 return 1
1225 fi
1226
1174 # check that it's executable 1227 # check that it's executable
1175 if [[ ! -x ${compiler_executable} ]]; then 1228 if [[ ! -x ${compiler_executable} ]]; then
1176 eerror "Could not find ${compiler_executable}!"
1177 die "${compiler_executable} doesn't exist, or isn't executable" 1229 echo "${compiler_executable} doesn't exist, or isn't executable"
1230 return 1
1178 fi 1231 fi
1179 else 1232 else
1180 eerror "Could not find environment file for ${compiler}" 1233 echo "Could not find environment file for ${compiler}"
1181 die "Could not find ${compiler_env}" 1234 return 1
1182 fi 1235 fi
1183 fi 1236 fi
1184 echo ${compiler_executable} 1237 echo ${compiler_executable}
1185} 1238}
1186 1239
1187# ------------------------------------------------------------------------------ 1240# ------------------------------------------------------------------------------
1188# @ebuild-function java-pkg_javac-args 1241# @ebuild-function java-pkg_javac-args
1189# 1242#
1190# If an ebuild uses javac directly, instead of using ejavac, it should call this 1243# If an ebuild uses javac directly, instead of using ejavac, it should call this
1191# to know what -source/-target to use. 1244# to know what -source/-target to use.
1192# 1245#
1193# @return string - arguments to pass to javac, complete with -target and -source 1246# @return string - arguments to pass to javac, complete with -target and -source
1196 debug-print-function ${FUNCNAME} $* 1249 debug-print-function ${FUNCNAME} $*
1197 1250
1198 local want_source="$(java-pkg_get-source)" 1251 local want_source="$(java-pkg_get-source)"
1199 local want_target="$(java-pkg_get-target)" 1252 local want_target="$(java-pkg_get-target)"
1200 1253
1201 local source_str="-source ${want_source}" 1254 local source_str="-source ${want_source}"
1202 local target_str="-target ${want_target}" 1255 local target_str="-target ${want_target}"
1203 1256
1204 debug-print "want source: ${want_source}" 1257 debug-print "want source: ${want_source}"
1205 debug-print "want target: ${want_target}" 1258 debug-print "want target: ${want_target}"
1206 1259
1207 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1260 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1208 debug-print "could not find valid -source/-target values" 1261 debug-print "could not find valid -source/-target values for javac"
1209 die "Could not find valid -source/-target values" 1262 echo "Could not find valid -source/-target values for javac"
1263 return 1
1210 else 1264 else
1211 if java-pkg_is-vm-version-ge "1.4"; then 1265 if java-pkg_is-vm-version-ge "1.4"; then
1212 echo "${source_str} ${target_str}" 1266 echo "${source_str} ${target_str}"
1213 else 1267 else
1214 echo "${target_str}" 1268 echo "${target_str}"
1218 1272
1219# TODO document 1273# TODO document
1220java-pkg_get-jni-cflags() { 1274java-pkg_get-jni-cflags() {
1221 local flags="-I${JAVA_HOME}/include" 1275 local flags="-I${JAVA_HOME}/include"
1222 1276
1277 local platform="linux"
1278 use elibc_FreeBSD && platform="freebsd"
1279
1223 # TODO do a check that the directories are valid 1280 # TODO do a check that the directories are valid
1224 # TODO figure out how to cope with other things than linux...
1225 flags="${flags} -I${JAVA_HOME}/include/linux" 1281 flags="${flags} -I${JAVA_HOME}/include/${platform}"
1226 1282
1227 echo ${flags} 1283 echo ${flags}
1228} 1284}
1229 1285
1230java-pkg_ensure-gcj() { 1286java-pkg_ensure-gcj() {
1298 1354
1299 if is-java-strict; then 1355 if is-java-strict; then
1300 einfo "Disabling system classpath for ant" 1356 einfo "Disabling system classpath for ant"
1301 antflags="${antflags} -Dbuild.sysclasspath=ignore" 1357 antflags="${antflags} -Dbuild.sysclasspath=ignore"
1302 fi 1358 fi
1303 1359
1304 if [[ -n ${JAVA_PKG_DEBUG} ]]; then 1360 if [[ -n ${JAVA_PKG_DEBUG} ]]; then
1305 antflags="${antflags} -debug" 1361 antflags="${antflags} -debug"
1306 fi 1362 fi
1307 1363
1308 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}" 1364 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ant ${antflags} "${@}"
1309 ant ${antflags} "${@}" || die "eant failed" 1365 ant ${antflags} "${@}" || die "eant failed"
1310 1366
1311} 1367}
1312 1368
1313# ------------------------------------------------------------------------------ 1369# ------------------------------------------------------------------------------
1314# @ebuild-function ejavac 1370# @ebuild-function ejavac
1315# 1371#
1316# Javac wrapper function. Will use the appropriate compiler, based on 1372# Javac wrapper function. Will use the appropriate compiler, based on
1317# /etc/java-config/compilers.conf 1373# /etc/java-config/compilers.conf
1318# 1374#
1319# @param $@ - Arguments to be passed to the compiler 1375# @param $@ - Arguments to be passed to the compiler
1320# ------------------------------------------------------------------------------ 1376# ------------------------------------------------------------------------------
1321ejavac() { 1377ejavac() {
1322 debug-print-function ${FUNCNAME} $* 1378 debug-print-function ${FUNCNAME} $*
1323 1379
1324 # FIXME using get-javac ends up printing stuff with einfo 1380 java-pkg_init-compiler_
1381
1382 local compiler_executable
1325# local compiler_executable=$(java-pkg_get-javac) 1383 compiler_executable=$(java-pkg_get-javac)
1326 local compiler_executable="javac" 1384 if [[ ${?} != 0 ]]; then
1385 eerror "There was a problem determining compiler: ${compiler_executable}"
1386 die "get-javac failed"
1387 fi
1327 1388
1389 local javac_args
1390 javac_args="$(java-pkg_javac-args)"
1391 if [[ ${?} != 0 ]]; then
1392 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1393 die "java-pkg_javac-args failed"
1394 fi
1395
1328 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1396 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1329 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1397 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1330} 1398}
1331 1399
1332# ------------------------------------------------------------------------------ 1400# ------------------------------------------------------------------------------
1333# @ebuild-function java-pkg_filter-compiler 1401# @ebuild-function java-pkg_filter-compiler
1334# 1402#
1335# Used to prevent the use of some compilers. Should be used in src_compile. 1403# Used to prevent the use of some compilers. Should be used in src_compile.
1336# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER 1404# Basically, it just appends onto JAVA_PKG_FILTER_COMPILER
1337# 1405#
1338# @param $@ - compilers to filter 1406# @param $@ - compilers to filter
1339# ------------------------------------------------------------------------------ 1407# ------------------------------------------------------------------------------
1357# ------------------------------------------------------------------------------ 1425# ------------------------------------------------------------------------------
1358# @ebuild-function use_doc 1426# @ebuild-function use_doc
1359# 1427#
1360# Helper function for getting ant to build javadocs. If the user has USE=doc, 1428# Helper function for getting ant to build javadocs. If the user has USE=doc,
1361# then 'javadoc' or the argument are returned. Otherwise, there is no return. 1429# then 'javadoc' or the argument are returned. Otherwise, there is no return.
1362# 1430#
1363# The output of this should be passed to ant. 1431# The output of this should be passed to ant.
1364# 1432#
1365# Example: build javadocs by calling 'javadoc' target 1433# Example: build javadocs by calling 'javadoc' target
1366# eant $(use_doc) 1434# eant $(use_doc)
1367# Example: build javadocs by calling 'apidoc' target 1435# Example: build javadocs by calling 'apidoc' target
1375} 1443}
1376 1444
1377# ------------------------------------------------------------------------------ 1445# ------------------------------------------------------------------------------
1378# @section-end build 1446# @section-end build
1379# ------------------------------------------------------------------------------ 1447# ------------------------------------------------------------------------------
1380 1448
1381# ------------------------------------------------------------------------------ 1449# ------------------------------------------------------------------------------
1382# @section-begin internal 1450# @section-begin internal
1383# @section-summary Internal functions 1451# @section-summary Internal functions
1384# 1452#
1385# Do __NOT__ use any of these from an ebuild! These are only to be used from 1453# Do __NOT__ use any of these from an ebuild! These are only to be used from
1386# within the java eclasses. 1454# within the java eclasses.
1387# ------------------------------------------------------------------------------ 1455# ------------------------------------------------------------------------------
1388 1456
1389# ----------------------------------------------------------------------------- 1457# -----------------------------------------------------------------------------
1390# @function-internal java-pkg_init 1458# @function-internal java-pkg_init
1391# 1459#
1392# The purpose of this function, as the name might imply, is to initialize the 1460# The purpose of this function, as the name might imply, is to initialize the
1393# Java environment. It ensures that that there aren't any environment variables 1461# Java environment. It ensures that that there aren't any environment variables
1394# that'll muss things up. It initializes some variables, which are used 1462# that'll muss things up. It initializes some variables, which are used
1395# internally. And most importantly, it'll switch the VM if necessary. 1463# internally. And most importantly, it'll switch the VM if necessary.
1396# 1464#
1408 # TODO we will probably want to set JAVAC and JAVACFLAGS 1476 # TODO we will probably want to set JAVAC and JAVACFLAGS
1409 1477
1410 # Do some QA checks 1478 # Do some QA checks
1411 java-pkg_check-jikes 1479 java-pkg_check-jikes
1412 1480
1413 # When users have crazy classpaths some packages can fail to compile. 1481 # When users have crazy classpaths some packages can fail to compile.
1414 # and everything should work with empty CLASSPATH. 1482 # and everything should work with empty CLASSPATH.
1415 # This also helps prevent unexpected dependencies on random things 1483 # This also helps prevent unexpected dependencies on random things
1416 # from the CLASSPATH. 1484 # from the CLASSPATH.
1417 unset CLASSPATH 1485 unset CLASSPATH
1418} 1486}
1419 1487
1420# ------------------------------------------------------------------------------ 1488# ------------------------------------------------------------------------------
1421# @function-internal java-pkg-init-compiler_ 1489# @function-internal java-pkg-init-compiler_
1422# 1490#
1423# This function attempts to figure out what compiler should be used. It does 1491# This function attempts to figure out what compiler should be used. It does
1424# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the 1492# this by reading the file at JAVA_PKG_COMPILERS_CONF, and checking the
1425# COMPILERS variable defined there. 1493# COMPILERS variable defined there.
1426# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER 1494# This can be overridden by a list in JAVA_PKG_FORCE_COMPILER
1427# 1495#
1428# It will go through the list of compilers, and verify that it supports the 1496# It will go through the list of compilers, and verify that it supports the
1429# target and source that are needed. If it is not suitable, then the next 1497# target and source that are needed. If it is not suitable, then the next
1430# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking 1498# compiler is checked. When JAVA_PKG_FORCE_COMPILER is defined, this checking
1431# isn't done. 1499# isn't done.
1432# 1500#
1454 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1522 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1455 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})" 1523 compilers="$(source ${JAVA_PKG_COMPILERS_CONF} 1>/dev/null 2>&1; echo ${COMPILERS})"
1456 else 1524 else
1457 compilers=${JAVA_PKG_FORCE_COMPILER} 1525 compilers=${JAVA_PKG_FORCE_COMPILER}
1458 fi 1526 fi
1459 1527
1460 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}" 1528 debug-print "Read \"${compilers}\" from ${JAVA_PKG_COMPILERS_CONF}"
1461 1529
1462 # Figure out if we should announce what compiler we're using 1530 # Figure out if we should announce what compiler we're using
1463 local compiler 1531 local compiler
1464 for compiler in ${compilers}; do 1532 for compiler in ${compilers}; do
1467 if [[ ${compiler} = "javac" ]]; then 1535 if [[ ${compiler} = "javac" ]]; then
1468 debug-print "Found javac... breaking" 1536 debug-print "Found javac... breaking"
1469 export GENTOO_COMPILER="javac" 1537 export GENTOO_COMPILER="javac"
1470 break 1538 break
1471 fi 1539 fi
1472 1540
1473 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then 1541 if has ${compiler} ${JAVA_PKG_FILTER_COMPILER}; then
1474 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then 1542 if [[ -z ${JAVA_PKG_FORCE_COMPILER} ]]; then
1475 einfo "Filtering ${compiler}" 1543 einfo "Filtering ${compiler}"
1476 continue 1544 continue
1477 fi 1545 fi
1478 fi 1546 fi
1479 1547
1480 # for non-javac, we need to make sure it supports the right target and 1548 # for non-javac, we need to make sure it supports the right target and
1481 # source 1549 # source
1482 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}" 1550 local compiler_env="${JAVA_PKG_COMPILER_DIR}/${compiler}"
1483 if [[ -f ${compiler_env} ]]; then 1551 if [[ -f ${compiler_env} ]]; then
1484 local desired_target="$(java-pkg_get-target)" 1552 local desired_target="$(java-pkg_get-target)"
1566# Writes the package.env out to disk. 1634# Writes the package.env out to disk.
1567# 1635#
1568# ------------------------------------------------------------------------------ 1636# ------------------------------------------------------------------------------
1569# TODO change to do-write, to match everything else 1637# TODO change to do-write, to match everything else
1570java-pkg_do_write_() { 1638java-pkg_do_write_() {
1639 java-pkg_init_paths_
1571 # Create directory for package.env 1640 # Create directory for package.env
1572 dodir "${JAVA_PKG_SHAREPATH}" 1641 dodir "${JAVA_PKG_SHAREPATH}"
1573 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 1642 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then
1574 # Create package.env 1643 # Create package.env
1575 ( 1644 (
1580 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\"" 1649 [[ -n "${JAVA_PKG_LIBRARY}" ]] && echo "LIBRARY_PATH=\"${JAVA_PKG_LIBRARY}\""
1581 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\"" 1650 [[ -n "${JAVA_PROVIDE}" ]] && echo "PROVIDES=\"${JAVA_PROVIDE}\""
1582 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\"" 1651 [[ -f "${JAVA_PKG_DEPEND}" ]] && echo "DEPEND=\"$(cat ${JAVA_PKG_DEPEND} | uniq | tr '\n' ':')\""
1583 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup ! 1652 echo "VM=\"$(echo ${RDEPEND} ${DEPEND} | sed -e 's/ /\n/g' | sed -n -e '/virtual\/\(jre\|jdk\)/ { p;q }')\"" # TODO cleanup !
1584 ) > "${JAVA_PKG_ENV}" 1653 ) > "${JAVA_PKG_ENV}"
1585 1654
1586 # register target/source 1655 # register target/source
1587 local target="$(java-pkg_get-target)" 1656 local target="$(java-pkg_get-target)"
1588 local source="$(java-pkg_get-source)" 1657 local source="$(java-pkg_get-source)"
1589 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}" 1658 [[ -n ${target} ]] && echo "TARGET=\"${target}\"" >> "${JAVA_PKG_ENV}"
1590 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}" 1659 [[ -n ${source} ]] && echo "SOURCE=\"${source}\"" >> "${JAVA_PKG_ENV}"
1603 # Strip unnecessary leading and trailing colons 1672 # Strip unnecessary leading and trailing colons
1604 # TODO try to cleanup if possible 1673 # TODO try to cleanup if possible
1605 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 1674 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
1606 fi 1675 fi
1607} 1676}
1608
1609 1677
1610# ------------------------------------------------------------------------------ 1678# ------------------------------------------------------------------------------
1611# @internal-function java-pkg_record-jar_ 1679# @internal-function java-pkg_record-jar_
1612# 1680#
1613# Record a dependency to the package.env 1681# Record a dependency to the package.env
1657 fi 1725 fi
1658} 1726}
1659 1727
1660# ------------------------------------------------------------------------------ 1728# ------------------------------------------------------------------------------
1661# @internal-function java-pkg_expand_dir_ 1729# @internal-function java-pkg_expand_dir_
1662# 1730#
1663# Gets the full path of the file/directory's parent. 1731# Gets the full path of the file/directory's parent.
1664# @param $1 - file/directory to find parent directory for 1732# @param $1 - file/directory to find parent directory for
1665# @return - path to $1's parent directory 1733# @return - path to $1's parent directory
1666# ------------------------------------------------------------------------------ 1734# ------------------------------------------------------------------------------
1667java-pkg_expand_dir_() { 1735java-pkg_expand_dir_() {
1694# ------------------------------------------------------------------------------ 1762# ------------------------------------------------------------------------------
1695java-pkg_setup-vm() { 1763java-pkg_setup-vm() {
1696 debug-print-function ${FUNCNAME} $* 1764 debug-print-function ${FUNCNAME} $*
1697 1765
1698 local vendor="$(java-pkg_get-vm-vendor)" 1766 local vendor="$(java-pkg_get-vm-vendor)"
1699 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 1767 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1700 addpredict "/dev/random" 1768 addpredict "/dev/random"
1701 elif [[ "${vendor}" == "ibm" ]]; then 1769 elif [[ "${vendor}" == "ibm" ]]; then
1702 addpredict "/proc/self/maps" 1770 addpredict "/proc/self/maps"
1703 addpredict "/proc/cpuinfo" 1771 addpredict "/proc/cpuinfo"
1704 export LANG="C" LC_ALL="C" 1772 export LANG="C" LC_ALL="C"
1753# @return - The version of the current VM 1821# @return - The version of the current VM
1754# ------------------------------------------------------------------------------ 1822# ------------------------------------------------------------------------------
1755java-pkg_get-vm-version() { 1823java-pkg_get-vm-version() {
1756 debug-print-function ${FUNCNAME} $* 1824 debug-print-function ${FUNCNAME} $*
1757 1825
1758 java-pkg_get-current-vm | sed -e "s/.*-\([0-9.]\+\).*/\1/" 1826 java-config -g PROVIDES_VERSION
1759} 1827}
1760 1828
1761# ------------------------------------------------------------------------------ 1829# ------------------------------------------------------------------------------
1762# @internal-function java-pkg_switch-vm 1830# @internal-function java-pkg_switch-vm
1763# 1831#
1764# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and 1832# Switch VM if we're allowed to (controlled by JAVA_PKG_ALLOW_VM_CHANGE), and
1765# verify that the current VM is sufficient. 1833# verify that the current VM is sufficient.
1766# Setup the environment for the VM being used. 1834# Setup the environment for the VM being used.
1767# ------------------------------------------------------------------------------ 1835# ------------------------------------------------------------------------------
1768java-pkg_switch-vm() { 1836java-pkg_switch-vm() {
1769 if java-pkg_needs-vm; then 1837 if java-pkg_needs-vm; then
1773 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 1841 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1774 # if we're allowed to switch the vm... 1842 # if we're allowed to switch the vm...
1775 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 1843 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1776 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 1844 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1777 if [[ -n ${JAVA_PKG_VNEED} ]]; then 1845 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1778 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1846 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1779 else 1847 else
1780 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1848 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1849 fi
1850 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
1851 eerror "Unable to determine VM for building from dependencies:"
1852 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
1853 echo "VNEED: ${JAVA_PKG_VNEED}"
1854 die "Failed to determine VM for building."
1855 else
1856 export GENTOO_VM
1781 fi 1857 fi
1782 # otherwise just make sure the current VM is sufficient 1858 # otherwise just make sure the current VM is sufficient
1783 else 1859 else
1784 java-pkg_ensure-vm-version-sufficient 1860 java-pkg_ensure-vm-version-sufficient
1785 fi 1861 fi
1786 debug-print "Using: $(java-config -f)" 1862 debug-print "Using: $(java-config -f)"
1787 1863
1788 java-pkg_setup-vm 1864 java-pkg_setup-vm
1789 1865
1790 export JAVA=$(java-config --java) 1866 export JAVA=$(java-config --java)
1791 export JAVAC=$(java-config --javac) 1867 export JAVAC=$(java-config --javac)
1792 export JAVACFLAGS="$(java-pkg_javac-args)" 1868 JAVACFLAGS="$(java-pkg_javac-args)"
1869 if [[ ${?} != 0 ]]; then
1870 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
1871 die "java-pkg_javac-args failed"
1872 fi
1793 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1873 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1874 export JAVACFLAGS
1794 1875
1795 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1876 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1796 export JDK_HOME=${JAVA_HOME} 1877 export JDK_HOME=${JAVA_HOME}
1797 1878
1798 #TODO If you know a better solution let us know. 1879 #TODO If you know a better solution let us know.
1799 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)" 1880 java-pkg_append_ LD_LIBRARY_PATH "$(java-config -g LDPATH)"
1800 1881
1801 local tann="${T}/announced-vm" 1882 local tann="${T}/announced-vm"
1802 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then 1883 if [[ -n "${JAVA_PKG_DEBUG}" ]] || [[ ! -f "${tann}" ]] ; then
1803 # Add a check for setup/preinst phase... to avoid duplicate outputs 1884 # Add a check for setup/preinst phase... to avoid duplicate outputs
1804 # for when FEATURES=buildpkg 1885 # for when FEATURES=buildpkg
1805 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]]; 1886 if [[ ${EBUILD_PHASE} != "setup" && ${EBUILD_PHASE} != "preinst" && ${EBUILD_PHASE} != "postinst" ]];
1849# TODO document 1930# TODO document
1850# Verify that the classes were compiled for the right source / target 1931# Verify that the classes were compiled for the right source / target
1851java-pkg_verify-classes() { 1932java-pkg_verify-classes() {
1852 ebegin "Verifying java class versions" 1933 ebegin "Verifying java class versions"
1853 #$(find ${D} -type f -name '*.jar' -o -name '*.class') 1934 #$(find ${D} -type f -name '*.jar' -o -name '*.class')
1854 class-version-verify.py -t $(java-pkg_get-target) -r ${D} 1935 class-version-verify.py -t $(java-pkg_get-target) -r ${D}
1855 result=$? 1936 result=$?
1856 eend ${result} 1937 eend ${result}
1857 if [[ ${result} == 0 ]]; then 1938 if [[ ${result} == 0 ]]; then
1858 einfo "All good" 1939 einfo "All good"
1859 else 1940 else
1860 ewarn "Possible problem" 1941 ewarn "Possible problem"
1861 die "Bad class files found" 1942 die "Bad class files found"
1862 fi 1943 fi
1863} 1944}
1864 1945
1865
1866# ------------------------------------------------------------------------------ 1946# ------------------------------------------------------------------------------
1867# @section-end internal 1947# @section-end internal
1868# ------------------------------------------------------------------------------ 1948# ------------------------------------------------------------------------------
1869 1949
1870java-pkg_check-phase() { 1950java-pkg_check-phase() {

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.33

  ViewVC Help
Powered by ViewVC 1.1.20