summaryrefslogtreecommitdiff
path: root/type
diff options
context:
space:
mode:
authorDennis Camera <cdist@dtnr.ch>2021-03-21 18:37:34 +0100
committerDennis Camera <cdist@dtnr.ch>2021-03-21 18:37:34 +0100
commit31aadffa592b483e32399504454733d444a8a47d (patch)
tree425eebd96dc5fb10e7cca10fa47c9cceb0eac5a5 /type
parent824a9f25166a45deb083a2657e5affc091905b57 (diff)
parenta7385a53faa2411eb9d3c850eabd32f3eadff167 (diff)
download__dtnrch_egov-31aadffa592b483e32399504454733d444a8a47d.tar.gz
__dtnrch_egov-31aadffa592b483e32399504454733d444a8a47d.zip
Merge branch 'feature/macosx-support'
Diffstat (limited to 'type')
-rwxr-xr-xtype/__dtnrch_etax_sgnp/explorer/jvms78
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2007/META.ini2
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2008/META.ini2
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2009/META.ini2
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2010/META.ini2
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2011/META.ini2
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2012/META.ini2
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2013/META.ini2
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2014/META.ini2
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2015/META.ini2
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2016/META.ini2
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2017/META.ini2
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2018/META.ini2
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2019/META.ini2
-rw-r--r--type/__dtnrch_etax_sgnp/files/versions/2020/META.ini2
-rwxr-xr-xtype/__dtnrch_etax_sgnp/gencode-remote20
-rwxr-xr-xtype/__dtnrch_etax_sgnp/manifest96
-rw-r--r--type/__dtnrch_install4j/explorer/state9
-rw-r--r--type/__dtnrch_install4j/files/find_uninstaller.awk58
-rwxr-xr-xtype/__dtnrch_install4j/gencode-remote106
-rw-r--r--type/__dtnrch_install4j/man.rst4
-rw-r--r--type/__dtnrch_install4j/parameter/optional1
22 files changed, 338 insertions, 62 deletions
diff --git a/type/__dtnrch_etax_sgnp/explorer/jvms b/type/__dtnrch_etax_sgnp/explorer/jvms
index c58025b..eb91583 100755
--- a/type/__dtnrch_etax_sgnp/explorer/jvms
+++ b/type/__dtnrch_etax_sgnp/explorer/jvms
@@ -23,17 +23,41 @@ 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
+ 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/')
+ $(
+ printf '%s\n' "${java_version}" | awk '
+ {
+ split($0, chars, "")
+ p = 1
+ for (i = 1; i in chars; i++) {
+ c = chars[i]
+ if (c ~ /[0-9]/) {
+ v[p] = v[p] c
+ } else if (p < 4 && c == ".") {
+ p++
+ } else if (c == "_") {
+ p = 4; v[p] = ""
+ } else if (chars[i] chars[i+1] == "-b") {
+ p = 5; v[p] = ""; i++
+ } else if (c == "+") {
+ p = 5; v[p] = ""
+ } else if (p == 5 && c == "-") {
+ p = 6; v[p] = ""
+ } else
+ break
+ }
+
+ for (i = 1; i <= 6; i++)
+ printf "%s%s", (i > 1 ? " " : ""), v[i]+0
+ printf "\n"
+ }')
EOF
if test $((ver_major)) -eq 1
@@ -44,20 +68,58 @@ jvm_ver() (
fi
)
+os=$("${__explorer:?}/os")
case ${os}
in
(debian|devuan)
- jvm_locations='/usr/lib/jvm/*'
+ set -- /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'
+ set -- /Library/Java/JavaVirtualMachines/*.jdk/Contents/Home/jre \
+ /Library/Java/JavaVirtualMachines/*.jre/Contents/Home \
+ /Library/Java/JavaVirtualMachines/*.jdk/Contents/Home \
+ /System/Library/Frameworks/JavaVM.framework/Versions/1.?/Home \
+ /Library/Internet\ Plug-Ins/JavaAppletPlugin.plugin/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*'
+ # Just guessing...
+ set -- /usr/bin/java* \
+ /usr/bin/jre* \
+ /usr/bin/jdk* \
+ /usr/bin/j2*re* \
+ /usr/bin/j2sdk* \
+ /usr/java*/jre \
+ /usr/java* \
+ /usr/jre* \
+ /usr/jdk* \
+ /usr/j2*re* \
+ /usr/j2sdk* \
+ /usr/java/j2*re* \
+ /usr/java/j2sdk* \
+ /opt/java* \
+ /usr/java/jre* \
+ /usr/java/jdk* \
+ /usr/lib/java/jre \
+ /usr/local/java* \
+ /usr/local/jre* \
+ /usr/local/jdk* \
+ /usr/local/j2*re* \
+ /usr/local/j2sdk* \
+ /usr/jdk/java* \
+ /usr/jdk/jre* \
+ /usr/jdk/jdk* \
+ /usr/jdk/j2*re* \
+ /usr/jdk/j2sdk* \
+ /usr/lib/jvm/* \
+ /usr/lib/java* \
+ /usr/lib/jre* \
+ /usr/lib/jdk* \
+ /usr/lib/j2*re* \
+ /usr/lib/j2sdk*
;;
esac
-for jvm_loc in ${jvm_locations}
+for jvm_loc
do
test -d "${jvm_loc}" -a ! -h "${jvm_loc}" || continue
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2007/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2007/META.ini
index bb1d779..0073189 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2007/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2007/META.ini
@@ -20,6 +20,8 @@ url_archive = https://web.archive.org/web/20210217174151/https://steuersoftware.
filename = SGnP2007_installieren_macos.dmg
cksum = 1640729764 9574400
sha256sum = 143d23f65a81b5ca853abd29ec8f4ebb9593cbe0ef9e194cc022ed03e6fa1721
+default_install_dir = /Applications/Steuer SGnP2007
+no_jre = 1
[unix]
url = https://steuersoftware.sg.oca.ch/Steuern_2007/SGnP2007_installieren_unix.sh
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2008/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2008/META.ini
index f007686..4350be9 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2008/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2008/META.ini
@@ -20,6 +20,8 @@ url_archive = https://web.archive.org/web/20210217174100/https://steuersoftware.
filename = SGnP2008_installieren_macos.dmg
cksum = 2637495216 10973184
sha256sum = cbc38f9d0b1ed33b8b569f663d368a52b908ce04a9592298f547076123e9b58c
+default_install_dir = /Applications/Steuer SGnP2008
+no_jre = 1
[unix]
url = https://steuersoftware.sg.oca.ch/Steuern_2008/SGnP2008_installieren_unix.sh
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2009/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2009/META.ini
index 8ae4e96..aa5d33f 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2009/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2009/META.ini
@@ -20,6 +20,8 @@ url_archive = https://web.archive.org/web/20210217174054/https://steuersoftware.
filename = SGnP2009_installieren_macos.dmg
cksum = 2875358710 12449792
sha256sum = 0c7fde05077a604a15472b32cc52b22f704571e1710b8442ba27840aab063fa0
+default_install_dir = /Applications/Steuer SGnP2009
+no_jre = 1
[unix]
url = https://steuersoftware.sg.oca.ch/Steuern_2009/SGnP2009_installieren_unix.sh
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2010/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2010/META.ini
index a44cf69..fb033a7 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2010/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2010/META.ini
@@ -20,6 +20,8 @@ url_archive = https://web.archive.org/web/20210217173737/https://steuersoftware.
filename = SGnP2010_installieren_macos.dmg
cksum = 3833315260 13928448
sha256sum = 9c47bf1ef35a13a8baab8d853b41b6391b3c09b384328486302cc0adb867be93
+default_install_dir = /Applications/Steuer SGnP2010
+no_jre = 1
[unix32]
url = https://steuersoftware.sg.oca.ch/Steuern_2010/SGnP2010_installieren_unix_jvm.sh
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2011/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2011/META.ini
index bcfe1fd..7edf036 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2011/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2011/META.ini
@@ -20,6 +20,8 @@ url_archive = https://web.archive.org/web/20210217173728/https://steuersoftware.
filename = SGnP2011_installieren_macos.dmg
cksum = 1048515727 14313472
sha256sum = 234da64627e9fbbb6082d1c9a0e41457c3ffa83140f1e5f577cfc41f34b1631b
+default_install_dir = /Applications/Steuer SGnP2011
+no_jre = 1
[unix]
url = https://steuersoftware.sg.oca.ch/Steuern_2011/SGnP2011_installieren_unix.sh
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2012/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2012/META.ini
index 1ea3216..635195c 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2012/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2012/META.ini
@@ -21,6 +21,8 @@ filename = SGnP2012_installieren_macos.dmg
cksum = 3373270392 13987840
sha256sum = ca890f9a64e962504594fcee31dffa031a3ae4aa0a6916be160c2affc60aad40
java_min = 1.5.0
+default_install_dir = /Applications/Steuer SGnP2012
+no_jre = 1
[unix32]
url = https://steuersoftware.sg.oca.ch/Steuern_2012/SGnP2012_installieren_unix_jvm.sh
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2013/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2013/META.ini
index 5a804e5..ad3194b 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2013/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2013/META.ini
@@ -21,6 +21,8 @@ filename = SGnP2013_installieren_macos.dmg
cksum = 4208351550 15009792
sha256sum = ec7ac4704ce2d92db90ea088328aff908988c9a87f83f4ef6152831623447c43
java_min = 1.5.0
+default_install_dir = /Applications/Steuer SGnP2013
+no_jre = 1
[unix32]
url = https://steuersoftware.sg.oca.ch/Steuern_2013/SGnP2013_installieren_unix_jvm.sh
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2014/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2014/META.ini
index fafdf27..3bba164 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2014/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2014/META.ini
@@ -20,6 +20,8 @@ filename = SGnP2014_installieren_macos_mit_JRE.dmg
cksum = 3721729951 14804992
sha256sum = 89fcf5537287262636e109a4fb9621fa09dc6b41ac0313a81e97172d8747c50f
java_min = 1.5.0
+default_install_dir = /Applications/Steuer SGnP2014
+no_jre = 1
[unix64]
url =
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2015/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2015/META.ini
index d44eba9..082c31d 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2015/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2015/META.ini
@@ -21,6 +21,8 @@ url_archive = https://web.archive.org/web/20210217125521/https://steuersoftware.
filename = SGnP2015_installieren_macos.dmg
cksum = 3661466952 52822151
sha256sum = 6d61f150a859d11dccc3f8794d122819e896556a894c930bc7d39f1bdfe25d75
+default_install_dir = /Applications/Steuer St.Gallen 2015 nP
+java = 1.7.0_80-b15
[unix64]
url = https://steuersoftware.sg.oca.ch/Steuern_2015/SGnP2015_installieren_unix_64bit.sh
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2016/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2016/META.ini
index 1d83f35..1eeab31 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2016/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2016/META.ini
@@ -21,6 +21,8 @@ url_archive = https://web.archive.org/web/20210217125615/https://steuersoftware.
filename = SGnP2016_installieren_macos.dmg
cksum = 4132300120 68907750
sha256sum = 15e1fafcb8f62dbe47c2906f406b5734e5c07d1904308e711c217610614ca384
+default_install_dir = /Applications/Steuer St.Gallen 2016 nP
+java = 1.8.0_102-b14
[unix64]
url = https://steuersoftware.sg.oca.ch/Steuern_2016/SGnP2016_installieren_unix_64bit.sh
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2017/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2017/META.ini
index 67a4844..2b4aabc 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2017/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2017/META.ini
@@ -21,6 +21,8 @@ url_archive = https://web.archive.org/web/20210216210644/https://steuersoftware.
filename = SGnP2017_installieren_macos.dmg
cksum = 2883234609 71762725
sha256sum = 0f1425a32e541004e89bcaed90b28a89b19d0ecc262218a63d8dbb80f77bd2e6
+default_install_dir = /Applications/Steuer St.Gallen 2017 nP
+java = 1.8.0_102-b14
[unix64]
url = https://steuersoftware.sg.oca.ch/Steuern_2017/SGnP2017_installieren_unix_64bit.sh
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2018/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2018/META.ini
index b2953ae..7607690 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2018/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2018/META.ini
@@ -21,6 +21,8 @@ url_archive = https://web.archive.org/web/20210216205619/https://steuersoftware.
filename = SGnP2018_installieren_macos.dmg
cksum = 3422651662 85521189
sha256sum = 8ad189e9cd6480e0d7e30d49e7ff7fdb1428dbf143b2fa269bb829de653aaf7b
+default_install_dir = /Applications/Steuer St.Gallen 2018 nP
+java = 1.8.0_181-b13
[unix64]
url = https://steuersoftware.sg.oca.ch/Steuern_2018/SGnP2018_installieren_unix_64bit.sh
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2019/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2019/META.ini
index 55dccc5..29dbee2 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2019/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2019/META.ini
@@ -21,6 +21,8 @@ url_archive = https://web.archive.org/web/20210212133647/https://steuersoftware.
filename = SGnP2019_installieren_macos.dmg
cksum = 1027117629 88728028
sha256sum = 60e3004431f13b93fc84a354146eea6c052a31225f4ba9e271e1f95920371f8f
+default_install_dir = /Applications/Steuer St.Gallen 2019 nP
+java = 1.8.0_181-b13
[unix64]
url = https://steuersoftware.sg.oca.ch/Steuern_2019/SGnP2019_installieren_unix_64bit.sh
diff --git a/type/__dtnrch_etax_sgnp/files/versions/2020/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2020/META.ini
index 3bb441e..56bf6bf 100644
--- a/type/__dtnrch_etax_sgnp/files/versions/2020/META.ini
+++ b/type/__dtnrch_etax_sgnp/files/versions/2020/META.ini
@@ -19,6 +19,8 @@ url_archive = https://web.archive.org/web/20210320204744/https://steuersoftware.
filename = SGnP2020_installieren_macos.dmg
sha256sum = 6415406d362f6fa949f6cb93504d31e0eb9731d5b35c18aa9bddd8884a2af4c8
cksum = 1812106978 98398768
+default_install_dir = /Applications/Steuer St.Gallen 2020 nP
+java = 1.8.0_181-b13
[unix64]
url = https://steuersoftware.sg.oca.ch/Steuern_2020/SGnP2020_installieren_unix_64bit.sh
diff --git a/type/__dtnrch_etax_sgnp/gencode-remote b/type/__dtnrch_etax_sgnp/gencode-remote
index a4898b1..215f66b 100755
--- a/type/__dtnrch_etax_sgnp/gencode-remote
+++ b/type/__dtnrch_etax_sgnp/gencode-remote
@@ -25,6 +25,21 @@ then
prefix=$(cat "${__object:?}/parameter/prefix")
fi
+
+os=$(cat "${__global:?}/explorer/os")
+case ${os}
+in
+ (debian|devuan|ubuntu)
+ is_freedesktop=true
+ ;;
+ (macosx)
+ is_freedesktop=false
+ ;;
+ (*)
+ exit 1
+ ;;
+esac
+
if release=$(sh -e "${__type:?}/files/find_release.sh")
then
rel_props=$("${__type:?}/files/get_release_props.sh" "${release}")
@@ -48,7 +63,10 @@ then
install_dir="${prefix}/${install_dir##*/}"
fi
-if grep -q "^__dtnrch_install4j${install_dir:?}:installed" "${__messages_in:?}"
+i4j_object_name=$(printf '%s\n' "${install_dir}" | tr ' ' '_')
+
+if grep -q "^__dtnrch_install4j${i4j_object_name}:installed" "${__messages_in:?}" \
+ && ${is_freedesktop}
then
# Post-install routine
diff --git a/type/__dtnrch_etax_sgnp/manifest b/type/__dtnrch_etax_sgnp/manifest
index 1d273f5..0aff839 100755
--- a/type/__dtnrch_etax_sgnp/manifest
+++ b/type/__dtnrch_etax_sgnp/manifest
@@ -74,22 +74,34 @@ fi
################################################################################
-# Download tax application
-
+# Parameters
case ${os}
in
(debian|devuan|ubuntu)
download_dir="/var/cache/cdist/${__type##*/}"
-
- __directory "${download_dir}" --state present \
- --owner 0 --group 0 --mode 0755 --parents
+ bundled_java_path="jre"
+ is_freedesktop=true
+ ;;
+ (macosx)
+ download_dir="/var/tmp/cdist/${__type##*/}"
+ bundled_java_path=".install4j/jre.bundle"
+ is_freedesktop=false
;;
(*)
- # TODO: error message
+ : "${__type:?}" # make shellcheck happy
+ echo "Your operating system (${os}) is currently not supported by this type (${__type##*/})." >&2
+ echo "Please contribute an implementation for it if you can." >&2
exit 1
;;
esac
+
+################################################################################
+# Download tax application
+
+__directory "${download_dir}" --state present \
+ --owner 0 --group 0 --mode 0755 --parents
+
remote_file="${download_dir}/${FILENAME:?}"
if test "${state_should}" != 'absent'
@@ -141,7 +153,7 @@ then
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
+ "${java_min_ver}" "${jvm_ver:-(none)}" >&2
exit 1
}
@@ -167,14 +179,18 @@ then
set -- "$@" --java-home "${jvm_path}"
fi
+i4j_object_name=$(printf '%s\n' "${install_dir}" | tr ' ' '_')
+
require="${require}${require32:+ }${require32-}" \
-__dtnrch_install4j "${install_dir}" \
+__dtnrch_install4j "${i4j_object_name}" \
--state "${state_should}" \
+ --install-dir "${install_dir}" \
--installer "${remote_file}" "$@"
-if ${set_jre_symlink:-false}
+if ${set_jre_symlink:-false} && ! expr "${install_dir}" : '.* ' >/dev/null
then
- require="__dtnrch_install4j${install_dir}" \
+ # FIXME: Fails if install dir contains spaces
+ require="__dtnrch_install4j${i4j_object_name}" \
__file "${install_dir:?}/.install4j/pref_jre.cfg" \
--state "${state_should}" \
--owner 0 --group 0 --mode 0644 \
@@ -182,15 +198,11 @@ then
${jvm_path:?}
EOF
- # __link "${install_dir:?}/jre" \
- # --state "${state_should}" \
- # --type symbolic \
- # --source "${jvm_path:?}"
require="__file${install_dir:?}/.install4j/pref_jre.cfg" \
- __directory "${install_dir:?}/jre" --state absent
+ __directory "${install_dir:?}/${bundled_java_path}" --state absent
fi
-export require="__dtnrch_install4j${install_dir}"
+export require="__dtnrch_install4j${i4j_object_name}"
################################################################################
@@ -205,30 +217,32 @@ else
custom_mime_state=absent
fi
-version=$(cat "${__object:?}/parameter/version")
-if test "${custom_mime_state}" = 'present'
+if ${is_freedesktop}
then
- # Generate custom MIME declaration for SGnP application
- mkdir "${__object:?}/files"
- "${__type:?}/files/mkmime.xml.sh" >"${__object:?}/files/mime-sgnp-${version}.xml"
-fi
+ if test "${custom_mime_state}" = 'present'
+ then
+ # Generate custom MIME declaration for SGnP application
+ mkdir "${__object:?}/files"
+ "${__type:?}/files/mkmime.xml.sh" >"${__object:?}/files/mime-sgnp-${version}.xml"
+ fi
+
+ __line /etc/mime.types:"application_x-sgnp-${version}" \
+ --state "$(case ${custom_mime_state} in (present) echo replace;; (*) echo "${custom_mime_state}";; esac)" \
+ --file /etc/mime.types \
+ --line "application/x-sgnp${version} sgnp${version}" \
+ --regex "^application/x-sgnp${version} "
-__line /etc/mime.types:"application_x-sgnp-${version}" \
- --state "$(case ${custom_mime_state} in (present) echo replace;; (*) echo "${custom_mime_state}";; esac)" \
- --file /etc/mime.types \
- --line "application/x-sgnp${version} sgnp${version}" \
- --regex "^application/x-sgnp${version} "
-
-xdg_mime_dir=/usr/share/mime
-__file "${xdg_mime_dir}/packages/sgnp-${version}.xml" \
- --state "${custom_mime_state}" \
- --owner 0 --group 0 --mode 0644 \
- --source "${__object:?}/files/mime-sgnp-${version}.xml"
-
-# NOTE/HACK: We try to work around the broken dependency resolver by pushing
-# this object back to be executed after this object, hoping that cdist will
-# execute other tax objects before updating the MIME database.
-require="${__object_name:?} __file${xdg_mime_dir}/packages/sgnp-${version}.xml" \
-__check_messages update_mime_database \
- --pattern "^__file${xdg_mime_dir}" \
- --execute "update-mime-database '${xdg_mime_dir}'"
+ xdg_mime_dir=/usr/share/mime
+ __file "${xdg_mime_dir}/packages/sgnp-${version}.xml" \
+ --state "${custom_mime_state}" \
+ --owner 0 --group 0 --mode 0644 \
+ --source "${__object:?}/files/mime-sgnp-${version}.xml"
+
+ # NOTE/HACK: We try to work around the broken dependency resolver by pushing
+ # this object back to be executed after this object, hoping that cdist will
+ # execute other tax objects before updating the MIME database.
+ require="${__object_name:?} __file${xdg_mime_dir}/packages/sgnp-${version}.xml" \
+ __check_messages update_mime_database \
+ --pattern "^__file${xdg_mime_dir}" \
+ --execute "update-mime-database '${xdg_mime_dir}'"
+fi
diff --git a/type/__dtnrch_install4j/explorer/state b/type/__dtnrch_install4j/explorer/state
index 4d3c9d3..32f41fb 100644
--- a/type/__dtnrch_install4j/explorer/state
+++ b/type/__dtnrch_install4j/explorer/state
@@ -20,8 +20,15 @@
# Print the current installation state of the install4j "package".
#
+if test -s "${__object:?}/parameter/install-dir"
+then
+ destination=$(cat "${__object:?}/parameter/install-dir")
+else
+ destination=/${__object_id:?}
+fi
+
installer=$(cat "${__object:?}/parameter/installer")
-destination=/${__object_id:?}
+
if test -d "${destination}/.install4j"
then
diff --git a/type/__dtnrch_install4j/files/find_uninstaller.awk b/type/__dtnrch_install4j/files/find_uninstaller.awk
new file mode 100644
index 0000000..374c81a
--- /dev/null
+++ b/type/__dtnrch_install4j/files/find_uninstaller.awk
@@ -0,0 +1,58 @@
+#!/usr/bin/awk -f
+# Usage: awk -f find_uninstaller.awk ${install_dir}/.install4j/i4jparams.conf
+
+function post(uninst, inst_dir) {
+ inst_dir = FILENAME
+ sub(FILESMATCH, "", inst_dir)
+
+ if (!system("cd '" inst_dir "' && test -e '" uninst "'")) {
+ if (uninst !~ /^\//)
+ printf "%s/%s\n", inst_dir, uninst
+ else
+ print uninst
+ }
+}
+
+BEGIN {
+ FILESMATCH = "(^|/).install4j/i4jparams\.conf$"
+
+ "uname -s" | getline kernel_name
+ close("uname -s")
+}
+
+/\r$/ { sub(/\r$/, "") }
+
+FNR == 1 {
+ if (!/^<\?xml version="1\.0".*\?>$/)
+ exit (e=1)
+
+ if (FILENAME !~ FILESMATCH)
+ exit (e=2)
+}
+
+/^<config.*>$/ {
+ in_config = 1
+ next
+}
+
+/^<\/config>$/ {
+ in_config = 0
+ post(UNINST)
+ next
+}
+
+in_config && /^[ ]*<general.*\/>$/ {
+ if (match($0, /uninstallerDirectory="[^"]*"/)) {
+ prefix_len = length("uninstallerDirectory=\"")
+ uninst_dir = substr($0, RSTART + prefix_len, RLENGTH - prefix_len - 1)
+ }
+ if (match($0, /uninstallerFilename="[^"]*"/)) {
+ prefix_len = length("uninstallerFilename=\"")
+ uninst_name = substr($0, RSTART + prefix_len, RLENGTH - prefix_len - 1)
+ }
+
+ UNINST = sprintf("%s/%s", (uninst_dir ? uninst_dir : "."), uninst_name)
+ uninst_dir = uninst_name = ""
+ if (kernel_name == "Darwin" && UNINST !~ /\/$/)
+ UNINST = UNINST ".app/Contents/MacOS/JavaApplicationStub"
+}
diff --git a/type/__dtnrch_install4j/gencode-remote b/type/__dtnrch_install4j/gencode-remote
index d472f95..363c6f2 100755
--- a/type/__dtnrch_install4j/gencode-remote
+++ b/type/__dtnrch_install4j/gencode-remote
@@ -18,19 +18,27 @@
# along with cdist. If not, see <http://www.gnu.org/licenses/>.
#
-quote() { printf "'%s'" "$(echo "$*" | sed -e "s/'/'\\\\''/g")"; }
+quote() { printf "'%s'" "$(printf '%s\n' "$*" | sed -e "s/'/'\\\\''/g")"; }
+drop_awk_comments() { quote "$(sed '/^[[:blank:]]*#.*$/d;/^$/d' "$@")"; }
target_setenv() {
printf '%s=%s\nexport %s\n' "$1" "$(quote "$2")" "$1"
}
+os=$(cat "${__global:?}/explorer/os")
+
state_is=$(cat "${__object:?}/explorer/state")
state_should=$(cat "${__object:?}/parameter/state")
test "${state_is}" != "${state_should}" || exit 0
-destination=/${__object_id:?}
+if test -s "${__object:?}/parameter/install-dir"
+then
+ destination=$(cat "${__object:?}/parameter/install-dir")
+else
+ destination=/${__object_id:?}
+fi
# Always enable unattended mode
i4j_opts='-q'
@@ -38,6 +46,8 @@ i4j_opts='-q'
case ${state_should}
in
(present)
+ printf 'set -e\n'
+
if test -s "${__object:?}/parameter/java-home"
then
java_home=$(cat "${__object:?}/parameter/java-home")
@@ -47,7 +57,7 @@ in
i4j_opts="${i4j_opts} -manual $(quote "${java_home}")"
fi
- i4j_script=$(cat "${__object:?}/parameter/installer")
+ i4j_installer=$(cat "${__object:?}/parameter/installer")
i4j_vm_opts='-Dinstall4j.suppressUnattendedReboot=true'
i4j_opts="${i4j_opts} -dir '${destination}'"
@@ -65,21 +75,82 @@ in
i4j_opts="${i4j_opts} -overwrite"
fi
- printf "/bin/sh '%s' %s %s\\n" "${i4j_script}" "${i4j_opts}" "${i4j_vm_opts}"
- printf "cksum '%s' | cut -d ' ' -f 1,2 >'%s'\\n" "${i4j_script}" "${destination}/.install4j/inst_cksum"
+ # Prepare installer
+ if expr "${i4j_installer}" : '.*\.sh$' >/dev/null
+ then
+ cat <<-EOF
+ pre() {
+ installer_exe=$(quote "${i4j_installer}")
+ }
+ run() {
+ /bin/sh "\${installer_exe}" ${i4j_opts} ${i4j_vm_opts}
+ }
+ post() { :; }
+
+ EOF
+ elif test "${os}" = 'macosx' && expr "${i4j_installer}" : '.*\.dmg$' >/dev/null
+ then
+ cat <<-EOF
+ pre() {
+ # Mount DMG first
+ dmg_path=$(quote "${i4j_installer}")
+ mountpoint_tmp=\$(mktemp)
+ hdiutil attach "\${dmg_path}" >"\${mountpoint_tmp}" || hdirc=$?
+ cat "\${mountpoint_tmp}"
+ dmg_mountpoint=\$(sed -n -e '\$s#^/dev/[^ ]*[[:space:]]*\(/Volumes/.*\)\$#\1#p' "\${mountpoint_tmp}")
+ rm "\${mountpoint_tmp}"
+ if test -n "\${hdirc-}"; then exit \$((hdirc)); fi
+
+ # Find installer
+ test -d "\${dmg_mountpoint}" || {
+ printf 'Failed to mount DMG %s\n' "\${dmg_path}" >&2
+ exit 1
+ }
+
+ installer_bundle=\$(
+ find "\${dmg_mountpoint}" -type d -name '*.app' -exec grep -q -F com.install4j.runtime {}/Contents/Info.plist \; -print |
+ awk '1;NR>1{e="Found more than one potential installer"} END{if(e){print e|"cat >&2";exit 1}}'
+ )
+ }
+ run() {
+ test -d "\${installer_bundle}" || {
+ printf 'Cannot find installer: %s\n' "\${installer_bundle}" >&2
+ exit 1
+ }
+ "\${installer_bundle}"/Contents/MacOS/JavaApplicationStub ${i4j_opts} ${i4j_vm_opts}
+ }
+ post() {
+ if test -d "\${dmg_mountpoint}"
+ then
+ hdiutil detach "\${dmg_mountpoint}"
+ fi
+ }
+
+ EOF
+ else
+ printf 'Unsupported install4j installer format: %s\n' "${i4j_installer}" >&2
+ exit 1
+ fi
+
+ # Run installer
+ printf 'trap post EXIT\n'
+ echo pre
+ echo run
+ printf "cksum '%s' | cut -d ' ' -f 1,2 >%s\\n" \
+ "${i4j_installer}" "$(quote "${destination}/.install4j/inst_cksum")"
echo 'installed' >>"${__messages_out:?}"
;;
(absent)
remote_logs_dir='${__object:?}/logs'
cat <<-EOF
- if test -f '${destination}/.install4j/inst_jre.cfg'
+ if test -f $(quote "${destination}/.install4j/inst_jre.cfg")
then
- read INSTALL4J_JAVA_HOME_OVERRIDE <'${destination}/.install4j/inst_jre.cfg'
+ read INSTALL4J_JAVA_HOME_OVERRIDE <$(quote "${destination}/.install4j/inst_jre.cfg")
test -d "\${INSTALL4J_JAVA_HOME_OVERRIDE}" || {
- if test -f '${destination}/.install4j/pref_jre.cfg'
+ if test -f $(quote "${destination}/.install4j/pref_jre.cfg")
then
- read INSTALL4J_JAVA_HOME_OVERRIDE <'${destination}/.install4j/pref_jre.cfg'
+ read INSTALL4J_JAVA_HOME_OVERRIDE <$(quote "${destination}/.install4j/pref_jre.cfg")
fi
}
if test -d "\${INSTALL4J_JAVA_HOME_OVERRIDE}"
@@ -90,12 +161,25 @@ in
fi
fi
+ if test -x $(quote "${destination}/.install4j/uninstall")
+ then
+ uninstaller=$(quote "${destination}/.install4j/uninstall")
+ elif test -f $(quote "${destination}/.install4j/i4jparams.conf")
+ then
+ uninstaller=\$(
+ awk $(drop_awk_comments "${__type:?}/files/find_uninstaller.awk") $(quote "${destination}/.install4j/i4jparams.conf"))
+ test -x "\${uninstaller}" || {
+ echo 'Cannot find uninstaller.' >&2
+ exit 1
+ }
+ fi
+
mkdir "${remote_logs_dir}" || exit 1
- rm -f '${destination}/.install4j/inst_cksum'
+ rm -f $(quote "${destination}/.install4j/inst_cksum")
i4j_exit=0
- /bin/sh '${destination}/uninstall' ${i4j_opts} >"${remote_logs_dir}/i4j_stdout" 2>"${remote_logs_dir}/i4j_stderr" || i4j_exit=$?
+ "\${uninstaller}" ${i4j_opts} >"${remote_logs_dir}/i4j_stdout" 2>"${remote_logs_dir}/i4j_stderr" || i4j_exit=$?
cat <"${remote_logs_dir}/i4j_stdout"
cat >&2 <"${remote_logs_dir}/i4j_stderr"
diff --git a/type/__dtnrch_install4j/man.rst b/type/__dtnrch_install4j/man.rst
index 77cfc53..efddf4e 100644
--- a/type/__dtnrch_install4j/man.rst
+++ b/type/__dtnrch_install4j/man.rst
@@ -19,6 +19,10 @@ installer
OPTIONAL PARAMETERS
-------------------
+install-dir
+ The directory to which the application should be installed.
+
+ Defaults to ``${__object_id}``.
java-home
Path to the ``JAVA_HOME`` (=JVM) to use for the installer.
diff --git a/type/__dtnrch_install4j/parameter/optional b/type/__dtnrch_install4j/parameter/optional
index 59ebefb..0fc7d89 100644
--- a/type/__dtnrch_install4j/parameter/optional
+++ b/type/__dtnrch_install4j/parameter/optional
@@ -1,3 +1,4 @@
+install-dir
java-home
state
temp