diff options
| author | Dennis Camera <cdist@dtnr.ch> | 2021-03-19 17:57:29 +0100 |
|---|---|---|
| committer | Dennis Camera <cdist@dtnr.ch> | 2021-03-20 20:31:35 +0100 |
| commit | 5b3b0e798443f36681e688a5cfaa4ec9816ef61b (patch) | |
| tree | 515035e6f96f273e4e4a9f293f26a09cdf2cd053 /type | |
| parent | cc4c96911ff94af329a8d7d2dab43bee68d50817 (diff) | |
| download | __dtnrch_egov-5b3b0e798443f36681e688a5cfaa4ec9816ef61b.tar.gz __dtnrch_egov-5b3b0e798443f36681e688a5cfaa4ec9816ef61b.zip | |
[type/__dtnrch_etax_sgnp] Add --use-system-jvm
Diffstat (limited to 'type')
| -rwxr-xr-x | type/__dtnrch_etax_sgnp/explorer/jvms | 67 | ||||
| -rwxr-xr-x | type/__dtnrch_etax_sgnp/files/get_release_props.sh | 12 | ||||
| -rwxr-xr-x | type/__dtnrch_etax_sgnp/files/ini_get_section.awk | 2 | ||||
| -rw-r--r-- | type/__dtnrch_etax_sgnp/man.rst | 2 | ||||
| -rwxr-xr-x | type/__dtnrch_etax_sgnp/manifest | 41 | ||||
| -rw-r--r-- | type/__dtnrch_etax_sgnp/parameter/boolean | 1 |
6 files changed, 119 insertions, 6 deletions
diff --git a/type/__dtnrch_etax_sgnp/explorer/jvms b/type/__dtnrch_etax_sgnp/explorer/jvms new file mode 100755 index 0000000..c58025b --- /dev/null +++ b/type/__dtnrch_etax_sgnp/explorer/jvms @@ -0,0 +1,67 @@ +#!/bin/sh -e +# +# 2021 Dennis Camera (cdist at dtnr.ch) +# +# This file is part of cdist. +# +# cdist is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cdist is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with cdist. If not, see <http://www.gnu.org/licenses/>. +# +# Finds all installed JVMs + +jvm_ver() ( + jvm_dir=${1:?} + test -x "${jvm_dir}/bin/java" || return 1 + + #check_date_output?? + + version_output=$("${jvm_dir}/bin/java" -version 2>&1) + + # ignore gcj + test $(expr "${version_output}" : '.*gcj') = 0 || return 1 + + java_version=$(expr "${version_output}" : '.*"\(.*\)".*') + + read -r ver_major ver_minor ver_micro ver_patch ver_b <<-EOF + $(printf '%s\n' "${java_version}" | sed 's/^\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\.\([0-9]\{1,\}\)\([\._]\([0-9]\{1,\}\)\(-b\([0-9]\{1,\}\)\{,1\}\)\{,1\}\)\{,1\}.*/\1 \2 \3 \5 \7/') + EOF + + if test $((ver_major)) -eq 1 + then + printf '%u 0 %u %u\n' $((ver_minor)) $((ver_micro)) $((ver_patch)) + else + printf '%u %u %u %u\n' $((ver_major)) $((ver_minor)) $((ver_micro)) $((ver_patch)) + fi +) + +case ${os} +in + (debian|devuan) + jvm_locations='/usr/lib/jvm/*' + ;; + (macosx) + jvm_locations='/System/Library/Frameworks/JavaVM.framework/Versions/1.?/Home /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/Contents/Home /Library/Java/JavaVirtualMachines/*.jdk/Contents/Home/jre /Library/Java/JavaVirtualMachines/*.jre/Contents/Home /Library/Java/JavaVirtualMachines/*.jdk/Contents/Home' + ;; + (*) + jvm_locations='/usr/bin/java* /usr/bin/jdk* /usr/bin/jre* /usr/bin/j2*re* /usr/bin/j2sdk* /usr/java* /usr/java*/jre /usr/jdk* /usr/jre* /usr/j2*re* /usr/j2sdk* /usr/java/j2*re* /usr/java/j2sdk* /opt/java* /usr/java/jdk* /usr/java/jre* /usr/lib/java/jre /usr/local/java* /usr/local/jdk* /usr/local/jre* /usr/local/j2*re* /usr/local/j2sdk* /usr/jdk/java* /usr/jdk/jdk* /usr/jdk/jre* /usr/jdk/j2*re* /usr/jdk/j2sdk* /usr/lib/jvm/* /usr/lib/java* /usr/lib/jdk* /usr/lib/jre* /usr/lib/j2*re* /usr/lib/j2sdk*' + ;; +esac + +for jvm_loc in ${jvm_locations} +do + test -d "${jvm_loc}" -a ! -h "${jvm_loc}" || continue + + printf '%s %s\n' "$(jvm_ver "${jvm_loc}")" "${jvm_loc}" +done \ +| LC_ALL=C sort -t ' ' -k 1n -k 2nr -k 3nr -k 4nr \ +| cut -d ' ' -f 1,2,5- diff --git a/type/__dtnrch_etax_sgnp/files/get_release_props.sh b/type/__dtnrch_etax_sgnp/files/get_release_props.sh index 8c54031..2cb1895 100755 --- a/type/__dtnrch_etax_sgnp/files/get_release_props.sh +++ b/type/__dtnrch_etax_sgnp/files/get_release_props.sh @@ -20,10 +20,14 @@ version=$(cat "${__object:?}/parameter/version") -command -p awk -f "${__type:?}/files/ini_get_section.awk" \ - "${1:?}" \ - "${__type:?}/files/versions/${version}/META.ini" \ -| command -p awk ' +AWK=$(command -p -v awk) +for sect in '' "${1:?no release given}" +do + "${AWK}" -f "${__type:?}/files/ini_get_section.awk" \ + "${sect}" \ + "${__type:?}/files/versions/${version}/META.ini" +done \ +| "${AWK}" ' /=/ { k = toupper(substr($0, 1, index($0, "=") - 1)) sub(/ *$/, "", k) diff --git a/type/__dtnrch_etax_sgnp/files/ini_get_section.awk b/type/__dtnrch_etax_sgnp/files/ini_get_section.awk index c9f99bb..42a9699 100755 --- a/type/__dtnrch_etax_sgnp/files/ini_get_section.awk +++ b/type/__dtnrch_etax_sgnp/files/ini_get_section.awk @@ -26,6 +26,8 @@ BEGIN { for (i = 1; i <= ARGC; ++i) ARGV[i] = ARGV[i+1] ARGC-- + + if (!SECTION) { select = 1; m++ } } /^[ \t]*$/ { next } diff --git a/type/__dtnrch_etax_sgnp/man.rst b/type/__dtnrch_etax_sgnp/man.rst index 656b78c..132e9b2 100644 --- a/type/__dtnrch_etax_sgnp/man.rst +++ b/type/__dtnrch_etax_sgnp/man.rst @@ -40,6 +40,8 @@ BOOLEAN PARAMETERS patch-mime Install a custom MIME type for tax declarations created with this this version of the application (unless the application installs one by itself). +use-system-jvm + Delete the bundled JRE and use a system JRE instead. EXAMPLES diff --git a/type/__dtnrch_etax_sgnp/manifest b/type/__dtnrch_etax_sgnp/manifest index 3c015f9..86b1c6d 100755 --- a/type/__dtnrch_etax_sgnp/manifest +++ b/type/__dtnrch_etax_sgnp/manifest @@ -20,11 +20,20 @@ strmatch() { eval "case \$1 in ($2) return 0 ;; (*) return 1 ;; esac"; } +version_ge() { + test "$1" = "$( + printf '%s\n' "$1" "$2" | tr . , \ + | sort -t, -n -k1 -k2 -k3 | tr , . | tail -n 1)" +} + + os=$(cat "${__global:?}/explorer/os") machine_arch=$(cat "${__global:?}/explorer/machine") state_should=$(cat "${__object:?}/parameter/state") +version=$(cat "${__object:?}/parameter/version") + if release=$(sh -e "${__type:?}/files/find_release.sh") then if strmatch "${machine_arch}" '*64*' \ @@ -59,7 +68,7 @@ then rel_props=$("${__type:?}/files/get_release_props.sh" "${release}") eval "${rel_props}" else - echo 'No release compatible for the target could be found.' >&2 + echo 'No release compatible with the target could be found.' >&2 exit 1 fi @@ -116,6 +125,27 @@ fi ################################################################################ # Install tax application +if test -f "${__object:?}/parameter/use-system-jvm" \ + || test "${NO_JRE:-0}" -ne 0 +then + java_min_ver=${JAVA_MIN:?no java_min defined for version ${version}} + exec 3<"${__object:?}/explorer/jvms" + while read -r v1 v2 jvm_path <&3 + do + jvm_ver=1.$((v1)).$((v2)) + unset v1 v2 + + if version_ge "${jvm_ver:-0}" "${java_min_ver}"; then break; fi + done + exec 3<&- + + version_ge "${jvm_ver:-0}" "${java_min_ver}" || { + printf 'No JVM found matching minimum requirement (%s). Found only %s.\n' \ + "${java_min_ver}" "${jvm_ver:-none}" >&2 + exit 1 + } +fi + if test -s "${__object:?}/parameter/install-dir" then install_dir=$(cat "${__object:?}/parameter/install-dir") @@ -129,10 +159,17 @@ then install_dir="${prefix}/${install_dir##*/}" fi +set -- +if test -n "${jvm_path}" +then + set -- "$@" --java-home "${jvm_path}" +fi + require="${require}${require32:+ }${require32-}" \ __dtnrch_install4j "${install_dir}" \ --state "${state_should}" \ - --installer "${remote_file}" + --installer "${remote_file}" "$@" + export require="__dtnrch_install4j${install_dir}" diff --git a/type/__dtnrch_etax_sgnp/parameter/boolean b/type/__dtnrch_etax_sgnp/parameter/boolean index 5e3edd2..b97e6bb 100644 --- a/type/__dtnrch_etax_sgnp/parameter/boolean +++ b/type/__dtnrch_etax_sgnp/parameter/boolean @@ -1 +1,2 @@ patch-mime +use-system-jvm |
