/[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.24 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}"

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

  ViewVC Help
Powered by ViewVC 1.1.20