picard: add variant with jvm arguments (#39204)
* picard: add variant with jvm arguments * fix variant and update wrapper script --------- Signed-off-by: Pablo <pablo.aledo@seqera.io>
This commit is contained in:
parent
77c838ca93
commit
f5888d8127
@ -156,6 +156,8 @@ class Picard(Package):
|
|||||||
)
|
)
|
||||||
version("1.140", sha256="0d27287217413db6b846284c617d502eaa578662dcb054a7017083eab9c54438")
|
version("1.140", sha256="0d27287217413db6b846284c617d502eaa578662dcb054a7017083eab9c54438")
|
||||||
|
|
||||||
|
variant("parameters", default=False, description="get java parameters in the adapter script")
|
||||||
|
|
||||||
depends_on("java@17:", type="run", when="@3.0.0:")
|
depends_on("java@17:", type="run", when="@3.0.0:")
|
||||||
depends_on("java@8:", type="run", when="@:2.27.5")
|
depends_on("java@8:", type="run", when="@:2.27.5")
|
||||||
|
|
||||||
@ -169,7 +171,12 @@ def install(self, spec, prefix):
|
|||||||
|
|
||||||
# Set up a helper script to call java on the jar file,
|
# Set up a helper script to call java on the jar file,
|
||||||
# explicitly codes the path for java and the jar file.
|
# explicitly codes the path for java and the jar file.
|
||||||
script_sh = join_path(os.path.dirname(__file__), "picard.sh")
|
|
||||||
|
script_sh = join_path(
|
||||||
|
os.path.dirname(__file__),
|
||||||
|
"picard_with_parameters.sh" if "+parameters" in spec else "picard.sh",
|
||||||
|
)
|
||||||
|
|
||||||
script = prefix.bin.picard
|
script = prefix.bin.picard
|
||||||
install(script_sh, script)
|
install(script_sh, script)
|
||||||
set_executable(script)
|
set_executable(script)
|
||||||
|
@ -0,0 +1,68 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
# Picard executable shell script
|
||||||
|
set -eu -o pipefail
|
||||||
|
|
||||||
|
export LC_ALL=en_US.UTF-8
|
||||||
|
|
||||||
|
# Find original directory of bash script, resolving symlinks
|
||||||
|
# http://stackoverflow.com/questions/59895/can-a-bash-script-tell-what-directory-its-stored-in/246128#246128
|
||||||
|
SOURCE="${BASH_SOURCE[0]}"
|
||||||
|
while [ -h "$SOURCE" ]; do # resolve $SOURCE until the file is no longer a symlink
|
||||||
|
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||||
|
SOURCE="$(readlink "$SOURCE")"
|
||||||
|
[[ $SOURCE != /* ]] && SOURCE="$DIR/$SOURCE" # if $SOURCE was a relative symlink, we need to resolve it relative to the path where the symlink file was located
|
||||||
|
done
|
||||||
|
DIR="$( cd -P "$( dirname "$SOURCE" )" && pwd )"
|
||||||
|
|
||||||
|
JAR_DIR=$DIR
|
||||||
|
ENV_PREFIX="$(dirname $(dirname $DIR))"
|
||||||
|
# Use Java installed with Anaconda to ensure correct version
|
||||||
|
java="$ENV_PREFIX/bin/java"
|
||||||
|
|
||||||
|
# if JAVA_HOME is set (non-empty), use it. Otherwise keep "java"
|
||||||
|
if [ -n "${JAVA_HOME:=}" ]; then
|
||||||
|
if [ -e "$JAVA_HOME/bin/java" ]; then
|
||||||
|
java="$JAVA_HOME/bin/java"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# extract memory and system property Java arguments from the list of provided arguments
|
||||||
|
# http://java.dzone.com/articles/better-java-shell-script
|
||||||
|
default_jvm_mem_opts="-Xms512m -Xmx2g"
|
||||||
|
jvm_mem_opts=""
|
||||||
|
jvm_prop_opts=""
|
||||||
|
pass_args=""
|
||||||
|
for arg in "$@"; do
|
||||||
|
case $arg in
|
||||||
|
'-D'*)
|
||||||
|
jvm_prop_opts="$jvm_prop_opts $arg"
|
||||||
|
;;
|
||||||
|
'-XX'*)
|
||||||
|
jvm_prop_opts="$jvm_prop_opts $arg"
|
||||||
|
;;
|
||||||
|
'-Xm'*)
|
||||||
|
jvm_mem_opts="$jvm_mem_opts $arg"
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
if [[ ${pass_args} == '' ]] #needed to avoid preceeding space on first arg e.g. ' MarkDuplicates'
|
||||||
|
then
|
||||||
|
pass_args="$arg"
|
||||||
|
else
|
||||||
|
pass_args="$pass_args \"$arg\"" #quotes later arguments to avoid problem with ()s in MarkDuplicates regex arg
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$jvm_mem_opts" == "" ] && [ -z ${_JAVA_OPTIONS+x} ]; then
|
||||||
|
jvm_mem_opts="$default_jvm_mem_opts"
|
||||||
|
fi
|
||||||
|
|
||||||
|
pass_arr=($pass_args)
|
||||||
|
if [[ ${pass_arr[0]:=} == org* ]]
|
||||||
|
then
|
||||||
|
eval "$java" $jvm_mem_opts $jvm_prop_opts -cp "$JAR_DIR/picard.jar" $pass_args
|
||||||
|
else
|
||||||
|
eval "$java" $jvm_mem_opts $jvm_prop_opts -jar "$JAR_DIR/picard.jar" $pass_args
|
||||||
|
fi
|
||||||
|
exit
|
Loading…
Reference in New Issue
Block a user