summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Camera <cdist@dtnr.ch>2021-09-01 19:10:39 +0200
committerDennis Camera <cdist@dtnr.ch>2021-09-01 21:14:52 +0200
commit5aa9e4d59e11810a9de2b080bc2d61a07e56983a (patch)
tree8c9c8772eaaee4b020695a57ff4519a74a2f9099
parentfac633a2a6e4c1027f60a336ab13cce793d1a0f8 (diff)
download__dtnrch_egov-5aa9e4d59e11810a9de2b080bc2d61a07e56983a.tar.gz
__dtnrch_egov-5aa9e4d59e11810a9de2b080bc2d61a07e56983a.zip
[type/__dtntch_egov_sgbg] New type
-rwxr-xr-xtype/__dtnrch_egov_sgbg/explorer/jvms129
-rwxr-xr-xtype/__dtnrch_egov_sgbg/files/find_release.sh94
-rwxr-xr-xtype/__dtnrch_egov_sgbg/files/get_release_props.sh41
-rwxr-xr-xtype/__dtnrch_egov_sgbg/files/ini_get_section.awk42
-rwxr-xr-xtype/__dtnrch_egov_sgbg/files/ini_sections.awk23
-rwxr-xr-xtype/__dtnrch_egov_sgbg/files/mkmime.xml.sh35
-rw-r--r--type/__dtnrch_egov_sgbg/files/versions/10.11.0/META.ini36
-rw-r--r--type/__dtnrch_egov_sgbg/files/versions/10.9.0/META.ini34
-rw-r--r--type/__dtnrch_egov_sgbg/files/versions/9.17.0/META.ini27
l---------type/__dtnrch_egov_sgbg/files/versions/latest1
-rwxr-xr-xtype/__dtnrch_egov_sgbg/gencode-remote132
-rw-r--r--type/__dtnrch_egov_sgbg/man.rst84
-rwxr-xr-xtype/__dtnrch_egov_sgbg/manifest267
-rw-r--r--type/__dtnrch_egov_sgbg/parameter/boolean2
-rw-r--r--type/__dtnrch_egov_sgbg/parameter/default/state1
-rw-r--r--type/__dtnrch_egov_sgbg/parameter/default/version1
-rw-r--r--type/__dtnrch_egov_sgbg/parameter/optional4
17 files changed, 953 insertions, 0 deletions
diff --git a/type/__dtnrch_egov_sgbg/explorer/jvms b/type/__dtnrch_egov_sgbg/explorer/jvms
new file mode 100755
index 0000000..eb91583
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/explorer/jvms
@@ -0,0 +1,129 @@
+#!/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
+
+ 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}" | 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
+ 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
+)
+
+os=$("${__explorer:?}/os")
+case ${os}
+in
+ (debian|devuan)
+ set -- /usr/lib/jvm/*
+ ;;
+ (macosx)
+ 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
+ ;;
+ (*)
+ # 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
+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_egov_sgbg/files/find_release.sh b/type/__dtnrch_egov_sgbg/files/find_release.sh
new file mode 100755
index 0000000..fc7dc66
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/files/find_release.sh
@@ -0,0 +1,94 @@
+#!/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/>.
+#
+
+
+kernel_name=$(cat "${__global:?}/explorer/kernel_name")
+machine=$(cat "${__global:?}/explorer/machine")
+os=$(cat "${__global:?}/explorer/os")
+
+version=$(cat "${__object:?}/parameter/version")
+
+# Check if the version number is valid
+test -d "${__type:?}/files/versions/${version}" \
+&& test -f "${__type:?}/files/versions/${version}/META.ini" \
+|| exit 1
+
+# Determine available "OS releases"
+case ${kernel_name}
+in
+ (Darwin)
+ options='macosx'
+ ;;
+ (*CYGWIN*|*NT*)
+ options='windows'
+ ;;
+ (*)
+ bit_suffix() {
+ case ${machine}
+ in
+ (*64*) echo "${1}64 ${1} ${1}32" ;;
+ (*) echo "${1} ${1}32" ;;
+ esac
+ }
+
+ case ${os}
+ in
+ (debian|devuan|ubuntu)
+ options=$(bit_suffix debian) ;;
+ (rhel|scientific|centos|fedora)
+ options=$(bit_suffix redhat) ;;
+ (suse)
+ options=$(bit_suffix suse) ;;
+ esac
+
+ case ${kernel_name}
+ in
+ (Linux)
+ options=${options-}${options:+ }$(bit_suffix linux)
+ ;;
+ (*BSD)
+ options=${options-}${options:+ }$(bit_suffix bsd)
+ ;;
+ esac
+
+ options=${options-}${options:+ }$(bit_suffix unix)
+ ;;
+esac
+
+metafile="${__type:?}/files/versions/${version}/META.ini"
+sections=$(command -p awk -f "${__type:?}/files/ini_sections.awk" "${metafile}")
+
+# Check if any of the available releases are compatible
+for _opt in ${options}
+do
+ if printf '%s\n' "${sections}" | grep -Fqx "${_opt}"
+ then
+ variant=${_opt}
+ break
+ fi
+done
+unset _opt
+
+test -n "${variant}" || {
+ echo 'No compatible release found.' >&2
+ exit 1
+}
+
+printf '%s\n' "${variant}"
diff --git a/type/__dtnrch_egov_sgbg/files/get_release_props.sh b/type/__dtnrch_egov_sgbg/files/get_release_props.sh
new file mode 100755
index 0000000..2cb1895
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/files/get_release_props.sh
@@ -0,0 +1,41 @@
+#!/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/>.
+#
+
+version=$(cat "${__object:?}/parameter/version")
+
+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)
+ v = substr($0, index($0, "=") + 1)
+ sub(/^ */, "", v)
+ sub(/ *$/, "", v)
+ if (v ~ /^".*"$/ || v ~ /^'\''.*'\''$/)
+ v = substr(v, 2, length(v) - 2)
+ gsub(/'\''/, "'\''\\'\'''\''", v)
+ printf "%s='\''%s'\''\n", k, v
+ }'
diff --git a/type/__dtnrch_egov_sgbg/files/ini_get_section.awk b/type/__dtnrch_egov_sgbg/files/ini_get_section.awk
new file mode 100755
index 0000000..42a9699
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/files/ini_get_section.awk
@@ -0,0 +1,42 @@
+#!/usr/bin/awk -f
+#
+# 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/>.
+#
+# Print the lines of an .ini file inside a section.
+#
+
+BEGIN {
+ SECTION = ARGV[1]
+
+ for (i = 1; i <= ARGC; ++i)
+ ARGV[i] = ARGV[i+1]
+ ARGC--
+
+ if (!SECTION) { select = 1; m++ }
+}
+
+/^[ \t]*$/ { next }
+/^\[.*\]$/ {
+ select = ($0 == "[" SECTION "]")
+ if (select) m++
+ next
+}
+
+select
+
+END { exit !m }
diff --git a/type/__dtnrch_egov_sgbg/files/ini_sections.awk b/type/__dtnrch_egov_sgbg/files/ini_sections.awk
new file mode 100755
index 0000000..7fdcec9
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/files/ini_sections.awk
@@ -0,0 +1,23 @@
+#!/usr/bin/awk -f
+#
+# 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/>.
+#
+# Prints all the sections in an .ini file.
+#
+
+/^\[.*\]$/ { print substr($0, 2, length - 2) }
diff --git a/type/__dtnrch_egov_sgbg/files/mkmime.xml.sh b/type/__dtnrch_egov_sgbg/files/mkmime.xml.sh
new file mode 100755
index 0000000..f6837d7
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/files/mkmime.xml.sh
@@ -0,0 +1,35 @@
+#!/bin/sh -e
+
+cat <<'EOF'
+<?xml version="1.0"?>
+<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
+ <!--Managed by cdist. CHANGES WILL BE OVERWRITTEN. DO NOT EDIT!-->
+EOF
+
+# Baugesuch (version 2)
+cat <<EOF
+ <mime-type type="application/x-sgbgv2">
+ <comment>Building application St.Gallen (version 2)</comment>
+ <comment xml:lang="de">Baugesuch St.Gallen (version 2)</comment>
+ <comment xml:lang="fr">Demande de construction St.Gallen (version 2)</comment>
+ <comment xml:lang="it">Domanda di costruzione St.Gallen (version 2)</comment>
+ <comment xml:lang="rm">Dumonda da construcziun St.Gallen (version 2)</comment>
+ <glob pattern="*.sgbgv2"/>
+ </mime-type>
+EOF
+
+# Baugesuch (version 1)
+cat <<EOF
+ <mime-type type="application/x-sgbgv1">
+ <comment>Building application St.Gallen (version 1)</comment>
+ <comment xml:lang="de">Baugesuch St.Gallen (version 1)</comment>
+ <comment xml:lang="fr">Demande de construction St.Gallen (version 1)</comment>
+ <comment xml:lang="it">Domanda di costruzione St.Gallen (version 1)</comment>
+ <comment xml:lang="rm">Dumonda da construcziun St.Gallen (version 1)</comment>
+ <glob pattern="*.sgbgv1"/>
+ </mime-type>
+EOF
+
+cat <<'EOF'
+</mime-info>
+EOF
diff --git a/type/__dtnrch_egov_sgbg/files/versions/10.11.0/META.ini b/type/__dtnrch_egov_sgbg/files/versions/10.11.0/META.ini
new file mode 100644
index 0000000..68c721a
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/files/versions/10.11.0/META.ini
@@ -0,0 +1,36 @@
+version = 10.11.0
+java = 1.8.0_181
+java_min = 1.8.0
+
+[win32]
+url = https://www.sg.ch/bauen/baugesuch-baubewilligung/baugesuch-einreichen/baugesuchformular/_jcr_content/Par/sgch_tab_list/RegisterListPar/sgch_tab/RegisterPar/sgch_downloadlist/DownloadListPar/sgch_download.ocFile/SGBG.exe
+url_archive = ...
+filename = SGBG.exe
+sha256sum = e364902b8cf9701babba2564083e513f27f377b6058ead132c5049208b516eac
+cksum = 155848245 79853744
+default_install_dir = C:\Program Files (x86)\Baugesuch St.Gallen
+java = 1.8.0_181-b13
+
+[macosx]
+url = https://www.sg.ch/bauen/baugesuch-baubewilligung/baugesuch-einreichen/baugesuchformular/_jcr_content/Par/sgch_tab_list/RegisterListPar/sgch_tab_1702783875_/RegisterPar/sgch_downloadlist_co/DownloadListPar/sgch_download.ocFile/SGBG.dmg
+filename = SGBG.dmg
+sha256sum = c1892256c79bfd4f7db35b15ded1f64e07a61f5fb1b3712da802868cc5b0f6b6
+cksum = 627387721 88080934
+default_install_dir = /Applications/Baugesuch St.Gallen
+java_min = 1.8.0_181-b13
+
+[unix64]
+url = https://www.sg.ch/bauen/baugesuch-baubewilligung/baugesuch-einreichen/baugesuchformular/_jcr_content/Par/sgch_tab_list/RegisterListPar/sgch_tab_1702783875/RegisterPar/sgch_downloadlist_co/DownloadListPar/sgch_download.ocFile/SGBG_64bit.sh
+filename = SGBG_64bit.sh
+sha256sum = f599f836edce34573bb3031e24e16c39d9b9c9874e62bf7578953fe15c6b9435
+cksum = 1348853245 93382556
+default_install_dir = /opt/Baugesuch_St.Gallen
+java = 1.8.0_181-b13
+
+[unix32]
+url = https://www.sg.ch/bauen/baugesuch-baubewilligung/baugesuch-einreichen/baugesuchformular/_jcr_content/Par/sgch_tab_list/RegisterListPar/sgch_tab_1702783875/RegisterPar/sgch_downloadlist_co/DownloadListPar/sgch_download_copy.ocFile/SGBG_32bit.sh
+filename = SGBG_32bit.sh
+sha256sum = 18dc0307d3b2daf43c0710df00970a7048a15b10f6814af6112193eca009baa0
+cksum = 1077037185 96531624
+default_install_dir = /opt/Baugesuch_St.Gallen
+java = 1.8.0_181-b13
diff --git a/type/__dtnrch_egov_sgbg/files/versions/10.9.0/META.ini b/type/__dtnrch_egov_sgbg/files/versions/10.9.0/META.ini
new file mode 100644
index 0000000..968df77
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/files/versions/10.9.0/META.ini
@@ -0,0 +1,34 @@
+version = 10.9.0
+java_min = 1.8.0
+
+[win32]
+url_alt = https://www.sg.ch/bauen/baugesuch-baubewilligung/baugesuch-einreichen/baugesuchformular/downloadbereich-vorgaengerversion/_jcr_content/Par/sgch_tab_list/RegisterListPar/sgch_tab/RegisterPar/sgch_downloadlist/DownloadListPar/sgch_download.ocFile/SGBG.exe
+filename = SGBG.exe
+sha256sum = 5467133be8e17e7e418905390b2dd437f977e823c8bbe8d37e8187ca875922f3
+cksum = 181160564 79497904
+default_install_dir = C:\Program Files (x86)\Baugesuch St.Gallen
+java = 1.8.0_181-b13
+
+[macosx]
+url_alt = https://www.sg.ch/bauen/baugesuch-baubewilligung/baugesuch-einreichen/baugesuchformular/downloadbereich-vorgaengerversion/_jcr_content/Par/sgch_tab_list/RegisterListPar/sgch_tab_1702783875_/RegisterPar/sgch_downloadlist_co/DownloadListPar/sgch_download.ocFile/SGBG.dmg
+filename = SGBG.dmg
+sha256sum = 304a6956ea63ddbc934a6b779743e5a8c225722578f32918892f0ba99e36c8c2
+cksum = 3822872579 87437778
+default_install_dir = /Applications/Baugesuch St.Gallen
+java = 1.8.0_181-b13
+
+[unix64]
+url_alt = https://www.sg.ch/bauen/baugesuch-baubewilligung/baugesuch-einreichen/baugesuchformular/downloadbereich-vorgaengerversion/_jcr_content/Par/sgch_tab_list/RegisterListPar/sgch_tab_1702783875/RegisterPar/sgch_downloadlist_co/DownloadListPar/sgch_download_copy.ocFile/SGBG_64bit.sh
+filename = SGBG_64bit.sh
+sha256sum = c7965038e110ce3799b9c99129e39ad7f628fe880b0ea2951137cc653317f3a9
+cksum = 2764548393 93014632
+default_install_dir = /opt/Baugesuch_St.Gallen
+java = 1.8.0_181-b13
+
+[unix32]
+url_alt = https://www.sg.ch/bauen/baugesuch-baubewilligung/baugesuch-einreichen/baugesuchformular/downloadbereich-vorgaengerversion/_jcr_content/Par/sgch_tab_list/RegisterListPar/sgch_tab_1702783875/RegisterPar/sgch_downloadlist_co/DownloadListPar/sgch_download_copy_1082448919.ocFile/SGBG_32bit.sh
+filename = SGBG_32bit.sh
+sha256sum = 00ede003a24bd3ebe19efbd276e705d4c8539b7d312515ab0505a03885c0c1f1
+cksum = 3117626193 96163865
+default_install_dir = /opt/Baugesuch_St.Gallen
+java = 1.8.0_181-b13
diff --git a/type/__dtnrch_egov_sgbg/files/versions/9.17.0/META.ini b/type/__dtnrch_egov_sgbg/files/versions/9.17.0/META.ini
new file mode 100644
index 0000000..b6f01ac
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/files/versions/9.17.0/META.ini
@@ -0,0 +1,27 @@
+version = 9.17.0
+java_min = 1.6.0
+
+[win32]
+url_alt = https://www.sg.ch/bauen/baugesuch-baubewilligung/baugesuch-einreichen/baugesuchformular/_jcr_content/Par/sgch_tab_list/RegisterListPar/sgch_tab/RegisterPar/sgch_downloadlist/DownloadListPar/sgch_download.ocFile/SGBG.exe
+filename = SGBG_installieren_windows_jre.exe
+sha256sum = 935f574816cc0099d6af339de36aa19f9d99a1530ac45821fecd4ab76b2043bb
+cksum = 722029921 45678192
+default_install_dir = C:\Program Files (x86)\Baugesuch SG
+java = 1.6.0_45-b06
+
+[macosx]
+url_alt = https://www.sg.ch/bauen/baugesuch-baubewilligung/baugesuch-einreichen/baugesuchformular/downloadbereich-vorgaengerversion/_jcr_content/Par/sgch_tab_list_copy/RegisterListPar/sgch_tab_1702783875_/RegisterPar/sgch_downloadlist_co/DownloadListPar/sgch_download.ocFile/SGBG_installieren_macos_jre.dmg
+filename = SGBG_installieren_macos_jre.dmg
+sha256sum = 394a29a8f16432357b1bf5d0616d08b135990b33d83ead84c9fa5b40ac51de2f
+cksum = 3745904517 65229555
+default_install_dir = /Applications/Baugesuch SG
+java = 1.8.0_102-b14
+java_min = 1.7.0
+
+[unix32]
+url_alt = https://www.sg.ch/bauen/baugesuch-baubewilligung/baugesuch-einreichen/baugesuchformular/downloadbereich-vorgaengerversion/_jcr_content/Par/sgch_tab_list_copy/RegisterListPar/sgch_tab_1702783875/RegisterPar/sgch_downloadlist_co/DownloadListPar/sgch_download.ocFile/SGBG_installieren_unix_jre.sh
+filename = SGBG_installieren_unix_jre.sh
+sha256sum = 99b9a51960c1286205d6931578d6163fbac829e4f89ef1eb054faaa07db3786b
+cksum = 2182246757 54659192
+default_install_dir = /opt/Baugesuch_St.Gallen
+java = 1.6.0_45-b06
diff --git a/type/__dtnrch_egov_sgbg/files/versions/latest b/type/__dtnrch_egov_sgbg/files/versions/latest
new file mode 120000
index 0000000..68d1958
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/files/versions/latest
@@ -0,0 +1 @@
+10.11.0 \ No newline at end of file
diff --git a/type/__dtnrch_egov_sgbg/gencode-remote b/type/__dtnrch_egov_sgbg/gencode-remote
new file mode 100755
index 0000000..669aa67
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/gencode-remote
@@ -0,0 +1,132 @@
+#!/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/>.
+#
+
+quote() { printf "'%s'" "$(printf '%s\n' "$*" | sed -e "s/'/'\\\\''/g")"; }
+drop_awk_comments() { quote "$(sed '/^[[:blank:]]*#.*$/d;/^$/d' "$@")"; }
+
+version=$(cat "${__object:?}/parameter/version")
+
+if test -s "${__object:?}/parameter/prefix"
+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}")
+ eval "${rel_props}"
+else
+ echo 'No release compatible for the target could be found.' >&2
+ exit 1
+fi
+
+
+if test -s "${__object:?}/parameter/install-dir"
+then
+ install_dir=$(cat "${__object:?}/parameter/install-dir")
+else
+ install_dir=${DEFAULT_INSTALL_DIR:?}
+ install_dir=${install_dir%/} # no trailing slash
+fi
+if test -s "${__object:?}/parameter/prefix"
+then
+ prefix=$(cat "${__object:?}/parameter/prefix")
+ install_dir="${prefix}/${install_dir##*/}"
+fi
+
+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
+
+ : "${__type:?}"
+
+ cat <<-EOF
+ set -e
+
+ i4j_desktop_file=\$(echo '${install_dir}'/.install4j/install4j_*-Baugesuch*.desktop)
+ desktop_file=\$(echo '${install_dir}'/Baugesuch\ *.desktop)
+
+ if test -e "\${i4j_desktop_file}" && test -e "\${desktop_file}"
+ then
+ cmp -s "\${i4j_desktop_file}" "\${desktop_file}" || {
+ echo 'Found regular and install4j .desktop file, but they differ!' >&2
+ exit 1
+ }
+
+ main_desktop_file=\${i4j_desktop_file}
+ alt_desktop_file=\${desktop_file}
+ desktop_basename=\${main_desktop_file##*/}
+ elif test -e "\${i4j_desktop_file}"
+ then
+ main_desktop_file=\${i4j_desktop_file}
+ desktop_basename=\${main_desktop_file##*/}
+ elif test -e "\${desktop_file}"
+ then
+ main_desktop_file=\${desktop_file}
+ desktop_basename=\${main_desktop_file##*/}
+ desktop_basename=\${desktop_basename%%.desktop}-0.desktop
+ else
+ echo 'Could not find .desktop file.' >&2
+ exit 1
+ fi
+
+ # Set MimeType
+ sed -i -n '/^MimeType=/!p' "\${main_desktop_file}"
+ printf 'MimeType=%s\n' 'application/x-sgbgv2;application/x-sgbgv1;' >>"\${main_desktop_file}"
+
+ # Ensure Office category is set
+ sed -i -e '/^Categories=/{/Office;/!s/$/Office;/}' "\${main_desktop_file}"
+
+ # Update alt file if they're not symlinked (i.e. they differ)
+ if test -e "\${alt_desktop_file}"
+ then
+ cmp -s "\${main_desktop_file}" "\${alt_desktop_file}" \\
+ || cat "\${main_desktop_file}" >"\${alt_desktop_file}"
+ fi
+
+ cp "\${main_desktop_file}" "/usr/share/applications/\${desktop_basename}"
+ chown 0:0 "/usr/share/applications/\${desktop_basename}"
+ chmod 0755 "/usr/share/applications/\${desktop_basename}"
+
+ update-desktop-database
+ EOF
+
+ # NOTE:
+ # xdg-desktop-menu install --mode system "\${main_desktop_file}"
+ # only works for files with no spaces
+fi
diff --git a/type/__dtnrch_egov_sgbg/man.rst b/type/__dtnrch_egov_sgbg/man.rst
new file mode 100644
index 0000000..d1c298d
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/man.rst
@@ -0,0 +1,84 @@
+cdist-type__dtnrch_egov_sgbg(7)
+===============================
+
+NAME
+----
+cdist-type__dtnrch_egov_sgbg - Install Baugesuch St.Gallen.
+
+
+DESCRIPTION
+-----------
+Installs and patches (if needed) the SGBG application.
+
+This type was written with a huge mental middle finger to
+`Information Factory <https://www.information-factory.com>`_ for their terrible
+software and fucked up release engineering.
+
+
+REQUIRED PARAMETERS
+-------------------
+version
+ The version of the SGBG application to install.
+
+
+OPTIONAL PARAMETERS
+-------------------
+install-dir
+ The directory into which the application should be installed.
+prefix
+ The prefix into which the application should be installed.
+ It will be prepended to the last component of ``--install-dir``, if set.
+
+ It will default to a "sane" value otherwise.
+state
+ One of:
+
+ present
+ Ensure the application is installed.
+ absent
+ Ensure the application is not installed.
+
+
+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
+--------
+
+.. code-block:: sh
+
+ # Install with defaults
+ __dtnrch_egov_sgbg SGBG_latest
+
+ # Install to custom location
+ __dtnrch_egov_sgbg SGBG_latest --install-dir /opt/SGBG
+
+ # Install older version
+ __dtnrch_egov_sgbg SGBG_9x --version 9.17.0 --install-dir /opt/SGBG-9.17.0
+
+ # Uninstall the application
+ __dtnrch_egov_sgbg SGBG_latest --state absent
+
+
+SEE ALSO
+--------
+None.
+
+
+AUTHORS
+-------
+Dennis Camera <cdist--@--dtnr.ch>
+
+
+COPYING
+-------
+Copyright \(C) 2021 Dennis Camera.
+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.
diff --git a/type/__dtnrch_egov_sgbg/manifest b/type/__dtnrch_egov_sgbg/manifest
new file mode 100755
index 0000000..9a3102c
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/manifest
@@ -0,0 +1,267 @@
+#!/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/>.
+#
+
+strmatch() { eval "case \$1 in ($2) return 0 ;; (*) return 1 ;; esac"; }
+
+version_ge() {
+ printf '%s\n' "$1" "$2" \
+ | tr . , \
+ | sort -t, -n -k1 -k2 -k3 \
+ | tr , . \
+ | tail -n 1 \
+ | grep -qxF "$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*' \
+ && strmatch "${release}" '*32'
+ then
+ strmatch "${os}" 'devuan|devuan|ubuntu' || {
+ printf '%s: system is 64-bit, but installer is 32-bit.\n' "${__object_name:?}" >&2
+ printf 'multi-arch has not been implemented for %s.\n' "${os}" >&2
+ exit 1
+ }
+
+ # need multi-arch
+ case ${machine_arch}
+ in
+ (x86_64)
+ __dpkg_architecture i386
+ for _p32 in libc6 libxrender1 libxtst6
+ do
+ require=__dpkg_architecture/i386 \
+ __package_apt "${_p32}:i386"
+ require32="${require32-}${require32:+ }__package_apt/${_p32}:i386"
+ done
+ ;;
+ (*)
+ printf 'Do not know the corresponding 32-bit arch to %s.\n' "${machine_arch}" >&2
+ exit 1
+ ;;
+ esac
+ fi
+
+ # Print all of the keys of the best-matching release
+ rel_props=$("${__type:?}/files/get_release_props.sh" "${release}")
+ eval "${rel_props}"
+else
+ echo 'No release compatible with the target could be found.' >&2
+ exit 1
+fi
+
+
+################################################################################
+# Parameters
+
+case ${os}
+in
+ (debian|devuan|ubuntu)
+ download_dir="/var/cache/cdist/${__type##*/}"
+ bundled_java_path="jre"
+ is_freedesktop=true
+ ;;
+ (macosx)
+ download_dir="/var/tmp/cdist/${__type##*/}"
+ bundled_java_path=".install4j/jre.bundle"
+ is_freedesktop=false
+ ;;
+ (*)
+ : "${__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 application
+
+__directory "${download_dir}" --state present \
+ --owner 0 --group 0 --mode 0755 --parents
+
+remote_file="${download_dir}/${FILENAME:?}"
+
+if test "${state_should}" != 'absent'
+then
+ # Check download URLs (to select one that works)
+
+ for _url in "${URL-}" "${URL_ALT-}" "${URL_ARCHIVE-}"
+ do
+ test -n "${_url}" || continue
+ case $(python3 -c '__import__("sys").stdout.write("%u\n" % __import__("urllib.request").request.urlopen(__import__("sys").argv[1]).getcode())' "${_url}")
+ in
+ (200) url=${_url}; break ;;
+ (404|500) continue ;;
+ esac
+ done
+ unset _url
+
+ test -n "${CKSUM}" || {
+ echo 'Do not know the correct cksum.' >&2
+ exit 1
+ }
+
+ require="__directory${remote_file%/*}" \
+ __download "${remote_file}" \
+ --url "${url}" \
+ --sum "${CKSUM}" \
+ --download remote
+
+ require="${require-}${require:+ }__download${remote_file}"
+fi
+
+
+################################################################################
+# Install 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
+ }
+
+ set_jre_symlink=true
+fi
+
+if test -s "${__object:?}/parameter/install-dir"
+then
+ install_dir=$(cat "${__object:?}/parameter/install-dir")
+else
+ install_dir=${DEFAULT_INSTALL_DIR:?}
+ install_dir=${install_dir%/} # no trailing slash
+fi
+if test -s "${__object:?}/parameter/prefix"
+then
+ prefix=$(cat "${__object:?}/parameter/prefix")
+ install_dir="${prefix}/${install_dir##*/}"
+fi
+
+set --
+if test -n "${jvm_path}"
+then
+ set -- "$@" --java-home "${jvm_path}"
+fi
+
+i4j_object_name=$(printf '%s\n' "${install_dir}" | tr ' ' '_')
+
+require="${require}${require32:+ }${require32-}" \
+__dtnrch_install4j "${i4j_object_name}" \
+ --state "${state_should}" \
+ --install-dir "${install_dir}" \
+ --installer "${remote_file}" "$@"
+
+if ${set_jre_symlink:-false}
+then
+ # FIXME: Fails if install dir contains spaces
+ if expr "${install_dir}" : '.* ' >/dev/null
+ then
+ echo 'Cannot force system JVM if the installation directory contains spaces.' >&2
+ # we hope that install4j will make proper links if no JRE was bundled.
+ test "${NO_JRE:-0}" -ne 0 || exit 1
+ else
+
+ require="__dtnrch_install4j${i4j_object_name}" \
+ __file "${install_dir:?}/.install4j/pref_jre.cfg" \
+ --state "${state_should}" \
+ --owner 0 --group 0 --mode 0644 \
+ --source - <<-EOF
+ ${jvm_path:?}
+ EOF
+
+ require="__file${install_dir:?}/.install4j/pref_jre.cfg" \
+ __directory "${install_dir:?}/${bundled_java_path}" --state absent
+
+ fi
+fi
+
+export require="__dtnrch_install4j${i4j_object_name}"
+
+
+################################################################################
+# Patch MIME
+
+if test "${state_should}" != 'absent' \
+ && test -f "${__object:?}/parameter/patch-mime" \
+ && test -z "${MIME_TYPE-}"
+then
+ custom_mime_state=present
+else
+ custom_mime_state=absent
+fi
+
+if ${is_freedesktop}
+then
+ if test "${custom_mime_state}" = 'present'
+ then
+ # Generate custom MIME declaration for SGBG application
+ mkdir "${__object:?}/files"
+ "${__type:?}/files/mkmime.xml.sh" >"${__object:?}/files/mime-sgbg.xml"
+ fi
+
+ while read -r _mime _exts
+ do
+ __line /etc/mime.types:"application_x-${_mime}" \
+ --state "$(case ${custom_mime_state} in (present) echo replace ;; (*) echo "${custom_mime_state}" ;; esac)" \
+ --file /etc/mime.types \
+ --line "application/x-${_mime} ${_exts}" \
+ --regex "^application/x-${_mime} " </dev/null
+ done <<-EOF
+ sgbgv1 sgbgv1
+ sgbgv2 sgbgv2
+ EOF
+
+ xdg_mime_dir=/usr/share/mime
+ __file "${xdg_mime_dir}/packages/sgbg.xml" \
+ --state "${custom_mime_state}" \
+ --owner 0 --group 0 --mode 0644 \
+ --source "${__object:?}/files/mime-sgbg.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/sgbg.xml" \
+ __check_messages update_mime_database \
+ --pattern "^__file${xdg_mime_dir}" \
+ --execute "update-mime-database '${xdg_mime_dir}'"
+fi
diff --git a/type/__dtnrch_egov_sgbg/parameter/boolean b/type/__dtnrch_egov_sgbg/parameter/boolean
new file mode 100644
index 0000000..b97e6bb
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/parameter/boolean
@@ -0,0 +1,2 @@
+patch-mime
+use-system-jvm
diff --git a/type/__dtnrch_egov_sgbg/parameter/default/state b/type/__dtnrch_egov_sgbg/parameter/default/state
new file mode 100644
index 0000000..e7f6134
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/parameter/default/state
@@ -0,0 +1 @@
+present
diff --git a/type/__dtnrch_egov_sgbg/parameter/default/version b/type/__dtnrch_egov_sgbg/parameter/default/version
new file mode 100644
index 0000000..a0f9a4b
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/parameter/default/version
@@ -0,0 +1 @@
+latest
diff --git a/type/__dtnrch_egov_sgbg/parameter/optional b/type/__dtnrch_egov_sgbg/parameter/optional
new file mode 100644
index 0000000..ec7d199
--- /dev/null
+++ b/type/__dtnrch_egov_sgbg/parameter/optional
@@ -0,0 +1,4 @@
+install-dir
+prefix
+state
+version