/[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.22 Revision 1.29
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.29 2006/12/03 13:05:06 betelgeuse 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
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}"
434
433 # TODO-nichoj find out what exactly -f package-list does 435 # TODO-nichoj find out what exactly -f package-list does
434 dohtml -f package-list "$@" 436 dohtml -f package-list "$@"
435 # this probably shouldn't be here but it provides 437 # this probably shouldn't be here but it provides
436 # a reasonable way to catch # docs for all of the 438 # a reasonable way to catch # docs for all of the
437 # old ebuilds. 439 # old ebuilds.
518# @ebuild-function java-pkg_dolauncher 520# @ebuild-function java-pkg_dolauncher
519# 521#
520# Make a wrapper script to lauch/start this package 522# Make a wrapper script to lauch/start this package
521# If necessary, the wrapper will switch to the appropriate VM. 523# If necessary, the wrapper will switch to the appropriate VM.
522# 524#
525# Can be called without parameters if the package installs only one jar
526# that has the Main-class attribute set. The wrapper will be named ${PN}.
527#
523# @param $1 - filename of launcher to create 528# @param $1 - filename of launcher to create
524# @param $2 - options, as follows: 529# @param $2 - options, as follows:
525# --main the.main.class.too.start 530# --main the.main.class.too.start
526# --jar /the/jar/too/launch.jar 531# --jar /the/jar/too/launch.jar or just <name>.jar
527# --java_args 'Extra arguments to pass to java' 532# --java_args 'Extra arguments to pass to java'
528# --pkg_args 'Extra arguments too pass to the package' 533# --pkg_args 'Extra arguments too pass to the package'
529# --pwd 534# --pwd
530# -into 535# -into
531# -pre 536# -pre
532# ------------------------------------------------------------------------------ 537# ------------------------------------------------------------------------------
533java-pkg_dolauncher() { 538java-pkg_dolauncher() {
534 debug-print-function ${FUNCNAME} $* 539 debug-print-function ${FUNCNAME} $*
535 540
536 java-pkg_check-phase install 541 java-pkg_check-phase install
537
538 [[ ${#} -lt 1 ]] && die "Need at least one argument"
539
540 java-pkg_init_paths_ 542 java-pkg_init_paths_
541 543
544 if [[ ${#} = 0 ]]; then
545 local name="${PN}"
546 else
542 local name="${1}" 547 local name="${1}"
548 shift
549 fi
550
543 # TODO rename to launcher 551 # TODO rename to launcher
544 local target="${T}/${name}" 552 local target="${T}/${name}"
545 local var_tmp="${T}/launcher_variables_tmp" 553 local var_tmp="${T}/launcher_variables_tmp"
546 local target_dir pre 554 local target_dir pre
547 shift
548 555
549 # Process the other the rest of the arguments 556 # Process the other the rest of the arguments
550 while [[ -n "${1}" && -n "${2}" ]]; do 557 while [[ -n "${1}" && -n "${2}" ]]; do
551 local var=${1} value=${2} 558 local var=${1} value=${2}
552 if [[ "${var:0:2}" == "--" ]]; then 559 if [[ "${var:0:2}" == "--" ]]; then
560 local var=${var:2}
553 echo "gjl_${var:2}=\"${value}\"" >> "${var_tmp}" 561 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
562 local gjl_${var}="${value}"
554 elif [[ "${var}" == "-into" ]]; then 563 elif [[ "${var}" == "-into" ]]; then
555 target_dir="${value}" 564 target_dir="${value}"
556 elif [[ "${var}" == "-pre" ]]; then 565 elif [[ "${var}" == "-pre" ]]; then
557 pre="${value}" 566 pre="${value}"
558 fi 567 fi
559 shift 2 568 shift 2
560 done 569 done
570
571 # Test if no --jar and --main arguments were given and
572 # in that case check if the package only installs one jar
573 # and use that jar.
574 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
575 local cp="${JAVA_PKG_CLASSPATH}"
576 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
577 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
578 else
579 local msg="Not enough information to create a launcher given."
580 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
581 die "${msg}"
582 fi
583 fi
561 584
562 # Write the actual script 585 # Write the actual script
563 echo "#!/bin/bash" > "${target}" 586 echo "#!/bin/bash" > "${target}"
564 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 587 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}"
565 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 588 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
1160} 1183}
1161 1184
1162java-pkg_get-javac() { 1185java-pkg_get-javac() {
1163 debug-print-function ${FUNCNAME} $* 1186 debug-print-function ${FUNCNAME} $*
1164 1187
1165 java-pkg_init-compiler_ 1188
1166 local compiler="${GENTOO_COMPILER}" 1189 local compiler="${GENTOO_COMPILER}"
1167 1190
1168 local compiler_executable 1191 local compiler_executable
1169 if [[ "${compiler}" = "javac" ]]; then 1192 if [[ "${compiler}" = "javac" ]]; then
1170 # nothing fancy needs to be done for javac 1193 # nothing fancy needs to be done for javac
1178 unset JAVAC 1201 unset JAVAC
1179 # try to get value of JAVAC 1202 # try to get value of JAVAC
1180 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1203 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1181 export JAVAC=${old_javac} 1204 export JAVAC=${old_javac}
1182 1205
1183 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1206 if [[ -z ${compiler_executable} ]]; then
1207 echo "JAVAC is empty or undefined in ${compiler_env}"
1208 return 1
1209 fi
1184 1210
1185 # check that it's executable 1211 # check that it's executable
1186 if [[ ! -x ${compiler_executable} ]]; then 1212 if [[ ! -x ${compiler_executable} ]]; then
1187 eerror "Could not find ${compiler_executable}!"
1188 die "${compiler_executable} doesn't exist, or isn't executable" 1213 echo "${compiler_executable} doesn't exist, or isn't executable"
1214 return 1
1189 fi 1215 fi
1190 else 1216 else
1191 eerror "Could not find environment file for ${compiler}" 1217 echo "Could not find environment file for ${compiler}"
1192 die "Could not find ${compiler_env}" 1218 return 1
1193 fi 1219 fi
1194 fi 1220 fi
1195 echo ${compiler_executable} 1221 echo ${compiler_executable}
1196} 1222}
1197 1223
1214 1240
1215 debug-print "want source: ${want_source}" 1241 debug-print "want source: ${want_source}"
1216 debug-print "want target: ${want_target}" 1242 debug-print "want target: ${want_target}"
1217 1243
1218 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1244 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1219 debug-print "could not find valid -source/-target values" 1245 debug-print "could not find valid -source/-target values for javac"
1220 die "Could not find valid -source/-target values" 1246 echo "Could not find valid -source/-target values for javac"
1247 return 1
1221 else 1248 else
1222 if java-pkg_is-vm-version-ge "1.4"; then 1249 if java-pkg_is-vm-version-ge "1.4"; then
1223 echo "${source_str} ${target_str}" 1250 echo "${source_str} ${target_str}"
1224 else 1251 else
1225 echo "${target_str}" 1252 echo "${target_str}"
1330# @param $@ - Arguments to be passed to the compiler 1357# @param $@ - Arguments to be passed to the compiler
1331# ------------------------------------------------------------------------------ 1358# ------------------------------------------------------------------------------
1332ejavac() { 1359ejavac() {
1333 debug-print-function ${FUNCNAME} $* 1360 debug-print-function ${FUNCNAME} $*
1334 1361
1335 # FIXME using get-javac ends up printing stuff with einfo 1362 java-pkg_init-compiler_
1363
1364 local compiler_executable
1336# local compiler_executable=$(java-pkg_get-javac) 1365 compiler_executable=$(java-pkg_get-javac)
1337 local compiler_executable="javac" 1366 if [[ ${?} != 0 ]]; then
1367 eerror "There was a problem determining compiler: ${compiler_executable}"
1368 die "get-javac failed"
1369 fi
1338 1370
1371 local javac_args
1372 javac_args="$(java-pkg_javac-args)"
1373 if [[ ${?} != 0 ]]; then
1374 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1375 die "java-pkg_javac-args failed"
1376 fi
1377
1339 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1378 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1340 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1379 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1341} 1380}
1342 1381
1343# ------------------------------------------------------------------------------ 1382# ------------------------------------------------------------------------------
1344# @ebuild-function java-pkg_filter-compiler 1383# @ebuild-function java-pkg_filter-compiler
1345# 1384#
1577# Writes the package.env out to disk. 1616# Writes the package.env out to disk.
1578# 1617#
1579# ------------------------------------------------------------------------------ 1618# ------------------------------------------------------------------------------
1580# TODO change to do-write, to match everything else 1619# TODO change to do-write, to match everything else
1581java-pkg_do_write_() { 1620java-pkg_do_write_() {
1621 java-pkg_init_paths_
1582 # Create directory for package.env 1622 # Create directory for package.env
1583 dodir "${JAVA_PKG_SHAREPATH}" 1623 dodir "${JAVA_PKG_SHAREPATH}"
1584 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then 1624 if [[ -n "${JAVA_PKG_CLASSPATH}" || -n "${JAVA_PKG_LIBRARY}" || -f "${JAVA_PKG_DEPEND}" ]]; then
1585 # Create package.env 1625 # Create package.env
1586 ( 1626 (
1614 # Strip unnecessary leading and trailing colons 1654 # Strip unnecessary leading and trailing colons
1615 # TODO try to cleanup if possible 1655 # TODO try to cleanup if possible
1616 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?" 1656 sed -e "s/=\":/=\"/" -e "s/:\"$/\"/" -i "${JAVA_PKG_ENV}" || die "Did you forget to call java_init ?"
1617 fi 1657 fi
1618} 1658}
1619
1620 1659
1621# ------------------------------------------------------------------------------ 1660# ------------------------------------------------------------------------------
1622# @internal-function java-pkg_record-jar_ 1661# @internal-function java-pkg_record-jar_
1623# 1662#
1624# Record a dependency to the package.env 1663# Record a dependency to the package.env
1705# ------------------------------------------------------------------------------ 1744# ------------------------------------------------------------------------------
1706java-pkg_setup-vm() { 1745java-pkg_setup-vm() {
1707 debug-print-function ${FUNCNAME} $* 1746 debug-print-function ${FUNCNAME} $*
1708 1747
1709 local vendor="$(java-pkg_get-vm-vendor)" 1748 local vendor="$(java-pkg_get-vm-vendor)"
1710 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 1749 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1711 addpredict "/dev/random" 1750 addpredict "/dev/random"
1712 elif [[ "${vendor}" == "ibm" ]]; then 1751 elif [[ "${vendor}" == "ibm" ]]; then
1713 addpredict "/proc/self/maps" 1752 addpredict "/proc/self/maps"
1714 addpredict "/proc/cpuinfo" 1753 addpredict "/proc/cpuinfo"
1715 export LANG="C" LC_ALL="C" 1754 export LANG="C" LC_ALL="C"
1784 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 1823 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1785 # if we're allowed to switch the vm... 1824 # if we're allowed to switch the vm...
1786 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 1825 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1787 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 1826 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1788 if [[ -n ${JAVA_PKG_VNEED} ]]; then 1827 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1789 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1828 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1790 else 1829 else
1791 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1830 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1831 fi
1832 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
1833 eerror "Unable to determine VM for building from dependencies."
1834 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
1835 echo "VNEED: ${JAVA_PKG_VNEED}"
1836 else
1837 export GENTOO_VM
1792 fi 1838 fi
1793 # otherwise just make sure the current VM is sufficient 1839 # otherwise just make sure the current VM is sufficient
1794 else 1840 else
1795 java-pkg_ensure-vm-version-sufficient 1841 java-pkg_ensure-vm-version-sufficient
1796 fi 1842 fi
1798 1844
1799 java-pkg_setup-vm 1845 java-pkg_setup-vm
1800 1846
1801 export JAVA=$(java-config --java) 1847 export JAVA=$(java-config --java)
1802 export JAVAC=$(java-config --javac) 1848 export JAVAC=$(java-config --javac)
1803 export JAVACFLAGS="$(java-pkg_javac-args)" 1849 JAVACFLAGS="$(java-pkg_javac-args)"
1850 if [[ ${?} != 0 ]]; then
1851 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
1852 die "java-pkg_javac-args failed"
1853 fi
1804 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1854 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1855 export JAVACFLAGS
1805 1856
1806 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1857 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1807 export JDK_HOME=${JAVA_HOME} 1858 export JDK_HOME=${JAVA_HOME}
1808 1859
1809 #TODO If you know a better solution let us know. 1860 #TODO If you know a better solution let us know.
1871 ewarn "Possible problem" 1922 ewarn "Possible problem"
1872 die "Bad class files found" 1923 die "Bad class files found"
1873 fi 1924 fi
1874} 1925}
1875 1926
1876
1877# ------------------------------------------------------------------------------ 1927# ------------------------------------------------------------------------------
1878# @section-end internal 1928# @section-end internal
1879# ------------------------------------------------------------------------------ 1929# ------------------------------------------------------------------------------
1880 1930
1881java-pkg_check-phase() { 1931java-pkg_check-phase() {

Legend:
Removed from v.1.22  
changed lines
  Added in v.1.29

  ViewVC Help
Powered by ViewVC 1.1.20