/[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.20 Revision 1.25
518# @ebuild-function java-pkg_dolauncher 518# @ebuild-function java-pkg_dolauncher
519# 519#
520# Make a wrapper script to lauch/start this package 520# Make a wrapper script to lauch/start this package
521# If necessary, the wrapper will switch to the appropriate VM. 521# If necessary, the wrapper will switch to the appropriate VM.
522# 522#
523# Can be called without parameters if the package installs only one jar
524# that has the Main-class attribute set. The wrapper will be named ${PN}.
525#
523# @param $1 - filename of launcher to create 526# @param $1 - filename of launcher to create
524# @param $2 - options, as follows: 527# @param $2 - options, as follows:
525# --main the.main.class.too.start 528# --main the.main.class.too.start
526# --jar /the/jar/too/launch.jar 529# --jar /the/jar/too/launch.jar or just <name>.jar
527# --java_args 'Extra arguments to pass to java' 530# --java_args 'Extra arguments to pass to java'
528# --pkg_args 'Extra arguments too pass to the package' 531# --pkg_args 'Extra arguments too pass to the package'
529# --pwd 532# --pwd
530# -into 533# -into
531# -pre 534# -pre
532# ------------------------------------------------------------------------------ 535# ------------------------------------------------------------------------------
533java-pkg_dolauncher() { 536java-pkg_dolauncher() {
534 debug-print-function ${FUNCNAME} $* 537 debug-print-function ${FUNCNAME} $*
535 538
536 java-pkg_check-phase install 539 java-pkg_check-phase install
537
538 [[ ${#} -lt 1 ]] && die "Need at least one argument"
539
540 java-pkg_init_paths_ 540 java-pkg_init_paths_
541 541
542 if [[ ${#} = 0 ]]; then
543 local name="${PN}"
544 else
542 local name="${1}" 545 local name="${1}"
546 shift
547 fi
548
543 # TODO rename to launcher 549 # TODO rename to launcher
544 local target="${T}/${name}" 550 local target="${T}/${name}"
545 local var_tmp="${T}/launcher_variables_tmp" 551 local var_tmp="${T}/launcher_variables_tmp"
546 local target_dir pre 552 local target_dir pre
547 shift
548 553
549 # Process the other the rest of the arguments 554 # Process the other the rest of the arguments
550 while [[ -n "${1}" && -n "${2}" ]]; do 555 while [[ -n "${1}" && -n "${2}" ]]; do
551 local var=${1} value=${2} 556 local var=${1} value=${2}
552 if [[ "${var:0:2}" == "--" ]]; then 557 if [[ "${var:0:2}" == "--" ]]; then
558 local var=${var:2}
553 echo "gjl_${var:2}=\"${value}\"" >> "${var_tmp}" 559 echo "gjl_${var}=\"${value}\"" >> "${var_tmp}"
560 local gjl_${var}=${value}
554 elif [[ "${var}" == "-into" ]]; then 561 elif [[ "${var}" == "-into" ]]; then
555 target_dir="${value}" 562 target_dir="${value}"
556 elif [[ "${var}" == "-pre" ]]; then 563 elif [[ "${var}" == "-pre" ]]; then
557 pre="${value}" 564 pre="${value}"
558 fi 565 fi
559 shift 2 566 shift 2
560 done 567 done
568
569 # Test if no --jar and --main arguments were given and
570 # in that case check if the package only installs one jar
571 # and use that jar.
572 if [[ -z "${gjl_jar}" && -z "${gjl_main}" ]]; then
573 local cp="${JAVA_PKG_CLASSPATH}"
574 if [[ "${cp/:}" = "${cp}" && "${cp%.jar}" != "${cp}" ]]; then
575 echo "gjl_jar=\"${JAVA_PKG_CLASSPATH}\"" >> "${var_tmp}"
576 else
577 local msg="Not enough information to create a launcher given."
578 msg="${msg} Please give --jar or --main argument to ${FUNCNAME}."
579 die "${msg}"
580 fi
581 fi
561 582
562 # Write the actual script 583 # Write the actual script
563 echo "#!/bin/bash" > "${target}" 584 echo "#!/bin/bash" > "${target}"
564 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}" 585 [[ -n "${pre}" ]] && [[ -f "${pre}" ]] && cat "${pre}" >> "${target}"
565 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}" 586 echo "gjl_package=${JAVA_PKG_NAME}" >> "${target}"
566 cat "${var_tmp}" >> "${target}" 587 cat "${var_tmp}" >> "${target}"
588 rm -f "${var_tmp}"
567 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}" 589 echo "source /usr/share/java-config-2/launcher/launcher.bash" >> "${target}"
568 590
569 if [[ -n "${target_dir}" ]]; then 591 if [[ -n "${target_dir}" ]]; then
570 DESTTREE="${target_dir}" dobin "${target}" 592 DESTTREE="${target_dir}" dobin "${target}"
571 local ret=$? 593 local ret=$?
1159} 1181}
1160 1182
1161java-pkg_get-javac() { 1183java-pkg_get-javac() {
1162 debug-print-function ${FUNCNAME} $* 1184 debug-print-function ${FUNCNAME} $*
1163 1185
1164 java-pkg_init-compiler_ 1186
1165 local compiler="${GENTOO_COMPILER}" 1187 local compiler="${GENTOO_COMPILER}"
1166 1188
1167 local compiler_executable 1189 local compiler_executable
1168 if [[ "${compiler}" = "javac" ]]; then 1190 if [[ "${compiler}" = "javac" ]]; then
1169 # nothing fancy needs to be done for javac 1191 # nothing fancy needs to be done for javac
1177 unset JAVAC 1199 unset JAVAC
1178 # try to get value of JAVAC 1200 # try to get value of JAVAC
1179 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})" 1201 compiler_executable="$(source ${compiler_env} 1>/dev/null 2>&1; echo ${JAVAC})"
1180 export JAVAC=${old_javac} 1202 export JAVAC=${old_javac}
1181 1203
1182 [[ -z ${compiler_executable} ]] && die "JAVAC is empty or undefined in ${compiler_env}" 1204 if [[ -z ${compiler_executable} ]]; then
1205 echo "JAVAC is empty or undefined in ${compiler_env}"
1206 return 1
1207 fi
1183 1208
1184 # check that it's executable 1209 # check that it's executable
1185 if [[ ! -x ${compiler_executable} ]]; then 1210 if [[ ! -x ${compiler_executable} ]]; then
1186 eerror "Could not find ${compiler_executable}!"
1187 die "${compiler_executable} doesn't exist, or isn't executable" 1211 echo "${compiler_executable} doesn't exist, or isn't executable"
1212 return 1
1188 fi 1213 fi
1189 else 1214 else
1190 eerror "Could not find environment file for ${compiler}" 1215 echo "Could not find environment file for ${compiler}"
1191 die "Could not find ${compiler_env}" 1216 return 1
1192 fi 1217 fi
1193 fi 1218 fi
1194 echo ${compiler_executable} 1219 echo ${compiler_executable}
1195} 1220}
1196 1221
1213 1238
1214 debug-print "want source: ${want_source}" 1239 debug-print "want source: ${want_source}"
1215 debug-print "want target: ${want_target}" 1240 debug-print "want target: ${want_target}"
1216 1241
1217 if [[ -z "${want_source}" || -z "${want_target}" ]]; then 1242 if [[ -z "${want_source}" || -z "${want_target}" ]]; then
1218 debug-print "could not find valid -source/-target values" 1243 debug-print "could not find valid -source/-target values for javac"
1219 die "Could not find valid -source/-target values" 1244 echo "Could not find valid -source/-target values for javac"
1245 return 1
1220 else 1246 else
1221 if java-pkg_is-vm-version-ge "1.4"; then 1247 if java-pkg_is-vm-version-ge "1.4"; then
1222 echo "${source_str} ${target_str}" 1248 echo "${source_str} ${target_str}"
1223 else 1249 else
1224 echo "${target_str}" 1250 echo "${target_str}"
1329# @param $@ - Arguments to be passed to the compiler 1355# @param $@ - Arguments to be passed to the compiler
1330# ------------------------------------------------------------------------------ 1356# ------------------------------------------------------------------------------
1331ejavac() { 1357ejavac() {
1332 debug-print-function ${FUNCNAME} $* 1358 debug-print-function ${FUNCNAME} $*
1333 1359
1334 # FIXME using get-javac ends up printing stuff with einfo 1360 java-pkg_init-compiler_
1361
1362 local compiler_executable
1335# local compiler_executable=$(java-pkg_get-javac) 1363 compiler_executable=$(java-pkg_get-javac)
1336 local compiler_executable="javac" 1364 if [[ ${?} != 0 ]]; then
1365 eerror "There was a problem determining compiler: ${compiler_executable}"
1366 die "get-javac failed"
1367 fi
1337 1368
1369 local javac_args
1370 javac_args="$(java-pkg_javac-args)"
1371 if [[ ${?} != 0 ]]; then
1372 eerror "There was a problem determining JAVACFLAGS: ${javac_args}"
1373 die "java-pkg_javac-args failed"
1374 fi
1375
1338 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} $(java-pkg_javac-args) "${@}" 1376 [[ -n ${JAVA_PKG_DEBUG} ]] && echo ${compiler_executable} ${javac_args} "${@}"
1339 ${compiler_executable} $(java-pkg_javac-args) "${@}" || die "ejavac failed" 1377 ${compiler_executable} ${javac_args} "${@}" || die "ejavac failed"
1340} 1378}
1341 1379
1342# ------------------------------------------------------------------------------ 1380# ------------------------------------------------------------------------------
1343# @ebuild-function java-pkg_filter-compiler 1381# @ebuild-function java-pkg_filter-compiler
1344# 1382#
1704# ------------------------------------------------------------------------------ 1742# ------------------------------------------------------------------------------
1705java-pkg_setup-vm() { 1743java-pkg_setup-vm() {
1706 debug-print-function ${FUNCNAME} $* 1744 debug-print-function ${FUNCNAME} $*
1707 1745
1708 local vendor="$(java-pkg_get-vm-vendor)" 1746 local vendor="$(java-pkg_get-vm-vendor)"
1709 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge 1 5; then 1747 if [[ "${vendor}" == "sun" ]] && java-pkg_is-vm-version-ge "1.5" ; then
1710 addpredict "/dev/random" 1748 addpredict "/dev/random"
1711 elif [[ "${vendor}" == "ibm" ]]; then 1749 elif [[ "${vendor}" == "ibm" ]]; then
1712 addpredict "/proc/self/maps" 1750 addpredict "/proc/self/maps"
1713 addpredict "/proc/cpuinfo" 1751 addpredict "/proc/cpuinfo"
1714 export LANG="C" LC_ALL="C" 1752 export LANG="C" LC_ALL="C"
1763# @return - The version of the current VM 1801# @return - The version of the current VM
1764# ------------------------------------------------------------------------------ 1802# ------------------------------------------------------------------------------
1765java-pkg_get-vm-version() { 1803java-pkg_get-vm-version() {
1766 debug-print-function ${FUNCNAME} $* 1804 debug-print-function ${FUNCNAME} $*
1767 1805
1768 java-pkg_get-current-vm | sed -e "s/.*-\([0-9.]\+\).*/\1/" 1806 java-config -g PROVIDES_VERSION
1769} 1807}
1770 1808
1771# ------------------------------------------------------------------------------ 1809# ------------------------------------------------------------------------------
1772# @internal-function java-pkg_switch-vm 1810# @internal-function java-pkg_switch-vm
1773# 1811#
1783 export GENTOO_VM="${JAVA_PKG_FORCE_VM}" 1821 export GENTOO_VM="${JAVA_PKG_FORCE_VM}"
1784 # if we're allowed to switch the vm... 1822 # if we're allowed to switch the vm...
1785 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then 1823 elif [[ "${JAVA_PKG_ALLOW_VM_CHANGE}" == "yes" ]]; then
1786 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}" 1824 debug-print "depend-java-query: NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}} VNEED: ${JAVA_PKG_VNEED}"
1787 if [[ -n ${JAVA_PKG_VNEED} ]]; then 1825 if [[ -n ${JAVA_PKG_VNEED} ]]; then
1788 export GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1826 GENTOO_VM="$(depend-java-query --need-virtual "${JAVA_PKG_VNEED}" --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1789 else 1827 else
1790 export GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")" 1828 GENTOO_VM="$(depend-java-query --get-vm "${JAVA_PKG_NV_DEPEND:-${DEPEND}}")"
1829 fi
1830 if [[ -z "${GENTOO_VM}" || "${GENTOO_VM}" == "None" ]]; then
1831 eerror "Unable to determine VM for building from dependencies."
1832 echo "NV_DEPEND: ${JAVA_PKG_NV_DEPEND:-${DEPEND}}"
1833 echo "VNEED: ${JAVA_PKG_VNEED}"
1834 else
1835 export GENTOO_VM
1791 fi 1836 fi
1792 # otherwise just make sure the current VM is sufficient 1837 # otherwise just make sure the current VM is sufficient
1793 else 1838 else
1794 java-pkg_ensure-vm-version-sufficient 1839 java-pkg_ensure-vm-version-sufficient
1795 fi 1840 fi
1797 1842
1798 java-pkg_setup-vm 1843 java-pkg_setup-vm
1799 1844
1800 export JAVA=$(java-config --java) 1845 export JAVA=$(java-config --java)
1801 export JAVAC=$(java-config --javac) 1846 export JAVAC=$(java-config --javac)
1802 export JAVACFLAGS="$(java-pkg_javac-args)" 1847 JAVACFLAGS="$(java-pkg_javac-args)"
1848 if [[ ${?} != 0 ]]; then
1849 eerror "There was a problem determining JAVACFLAGS: ${JAVACFLAGS}"
1850 die "java-pkg_javac-args failed"
1851 fi
1803 [[ -n ${JAVACFLAGS_EXTRA} ]] && export JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}" 1852 [[ -n ${JAVACFLAGS_EXTRA} ]] && JAVACFLAGS="${JAVACFLAGS_EXTRA} ${JAVACFLAGS}"
1853 export JAVACFLAGS
1804 1854
1805 export JAVA_HOME="$(java-config -g JAVA_HOME)" 1855 export JAVA_HOME="$(java-config -g JAVA_HOME)"
1806 export JDK_HOME=${JAVA_HOME} 1856 export JDK_HOME=${JAVA_HOME}
1807 1857
1808 #TODO If you know a better solution let us know. 1858 #TODO If you know a better solution let us know.

Legend:
Removed from v.1.20  
changed lines
  Added in v.1.25

  ViewVC Help
Powered by ViewVC 1.1.20