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

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

  ViewVC Help
Powered by ViewVC 1.1.20