diff options
| author | Dennis Camera <cdist@dtnr.ch> | 2021-02-12 18:08:17 +0100 |
|---|---|---|
| committer | Dennis Camera <cdist@dtnr.ch> | 2021-03-19 11:06:04 +0100 |
| commit | 21843997a137af0f82fe2a380628d20179841b09 (patch) | |
| tree | fe565bac8078d0acb0c212357d83a9a6dbbe7fdd /type | |
| parent | 5f0e6837393943720a8c5fb0b0198766b6c855c3 (diff) | |
| download | __dtnrch_egov-21843997a137af0f82fe2a380628d20179841b09.tar.gz __dtnrch_egov-21843997a137af0f82fe2a380628d20179841b09.zip | |
[type/__dtnrch_etax_sgnp] Add type to download and install Steuer St.Gallen
Diffstat (limited to 'type')
| -rwxr-xr-x | type/__dtnrch_etax_sgnp/files/find_release.sh | 108 | ||||
| -rwxr-xr-x | type/__dtnrch_etax_sgnp/files/ini_get_section.awk | 37 | ||||
| -rwxr-xr-x | type/__dtnrch_etax_sgnp/files/ini_sections.awk | 23 | ||||
| -rw-r--r-- | type/__dtnrch_etax_sgnp/files/versions/2020/META.ini | 21 | ||||
| -rwxr-xr-x | type/__dtnrch_etax_sgnp/gencode-remote | 19 | ||||
| -rw-r--r-- | type/__dtnrch_etax_sgnp/man.rst | 71 | ||||
| -rwxr-xr-x | type/__dtnrch_etax_sgnp/manifest | 104 | ||||
| -rw-r--r-- | type/__dtnrch_etax_sgnp/parameter/default/state | 1 | ||||
| -rw-r--r-- | type/__dtnrch_etax_sgnp/parameter/optional | 2 | ||||
| -rw-r--r-- | type/__dtnrch_etax_sgnp/parameter/required | 1 |
10 files changed, 387 insertions, 0 deletions
diff --git a/type/__dtnrch_etax_sgnp/files/find_release.sh b/type/__dtnrch_etax_sgnp/files/find_release.sh new file mode 100755 index 0000000..1445a32 --- /dev/null +++ b/type/__dtnrch_etax_sgnp/files/find_release.sh @@ -0,0 +1,108 @@ +#!/bin/sh -e +# +# 2021 Dennis Camera (cdist at datenrei.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 +} + +# Print all of the keys of the best-matching release +command -p awk -f "${__type:?}/files/ini_get_section.awk" \ + "${variant}" "${metafile}" \ +| command -p 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_etax_sgnp/files/ini_get_section.awk b/type/__dtnrch_etax_sgnp/files/ini_get_section.awk new file mode 100755 index 0000000..37b76ea --- /dev/null +++ b/type/__dtnrch_etax_sgnp/files/ini_get_section.awk @@ -0,0 +1,37 @@ +#!/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-- +} + +/^[ \t]*$/ { next } +/^\[.*\]$/ { + select = ($0 == "[" SECTION "]") + next +} + +select diff --git a/type/__dtnrch_etax_sgnp/files/ini_sections.awk b/type/__dtnrch_etax_sgnp/files/ini_sections.awk new file mode 100755 index 0000000..7fdcec9 --- /dev/null +++ b/type/__dtnrch_etax_sgnp/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_etax_sgnp/files/versions/2020/META.ini b/type/__dtnrch_etax_sgnp/files/versions/2020/META.ini new file mode 100644 index 0000000..54c1fb8 --- /dev/null +++ b/type/__dtnrch_etax_sgnp/files/versions/2020/META.ini @@ -0,0 +1,21 @@ +version = 2020 + +[windows] +url = https://steuersoftware.sg.oca.ch/Steuern_2020/SGnP2020_installieren_windows.exe +url_archive = https://web.archive.org/web/20210212133230/https://steuersoftware.sg.oca.ch/Steuern_2020/SGnP2020_installieren_windows.exe +sha256sum = 737660362e2c508b40691c4ab3647f0715a50d7e358990375af541c7360a63d9 +cksum = 1590977203 89746608 + +[macosx] +url = https://steuersoftware.sg.oca.ch/Steuern_2020/SGnP2020_installieren_macos.dmg +url_archive = https://web.archive.org/web/20210212133246/https://steuersoftware.sg.oca.ch/Steuern_2020/SGnP2020_installieren_macos.dmg +sha256sum = d386c08a4d5b94bbfc8e86cfb50e4b998168c1467833eacc0adbf56ff16f545a +cksum = 14425228 98005552 + +[unix64] +url = https://steuersoftware.sg.oca.ch/Steuern_2020/SGnP2020_installieren_unix_64bit.sh +url_archive = https://web.archive.org/web/20210212133323/https://steuersoftware.sg.oca.ch/Steuern_2020/SGnP2020_installieren_unix_64bit.sh +filename = SGnP2020_installieren_unix_64bit.sh +sha526sum = 339236f0b0447c354e4850c598d0f569ec87ba720a3522e07621c3757325ed05 +cksum = 3388288660 103061518 +default_install_dir = /opt/Steuer_St.Gallen_2020_nP diff --git a/type/__dtnrch_etax_sgnp/gencode-remote b/type/__dtnrch_etax_sgnp/gencode-remote new file mode 100755 index 0000000..6a7d9fd --- /dev/null +++ b/type/__dtnrch_etax_sgnp/gencode-remote @@ -0,0 +1,19 @@ +#!/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/>. +# diff --git a/type/__dtnrch_etax_sgnp/man.rst b/type/__dtnrch_etax_sgnp/man.rst new file mode 100644 index 0000000..2667ce3 --- /dev/null +++ b/type/__dtnrch_etax_sgnp/man.rst @@ -0,0 +1,71 @@ +cdist-type__dtnrch_etax_sgnp(7) +=============================== + +NAME +---- +cdist-type__dtnrch_etax_sgnp - Install Steuer St.Gallen natürliche Personen. + + +DESCRIPTION +----------- +This space intentionally left blank. + + +REQUIRED PARAMETERS +------------------- +version + The version (year number) of the SGnP application to install. + + +OPTIONAL PARAMETERS +------------------- +prefix + The directory into which the application should be installed. + Defaults to ``__object_id``. +state + One of: + + present + Ensure the application is installed. + absent + Ensure the application is not installed. + + +BOOLEAN PARAMETERS +------------------ +None. + + +EXAMPLES +-------- + +.. code-block:: sh + + # Install with defaults + __dtnrch_etax_sgnp Steuer_St.Gallen_2020_nP --version 2020 + + # Install to custom location + __dtnrch_etax_sgnp Steuer_St.Gallen_2020_nP \ + --version 2019 \ + --prefix /opt/taxes/SGnP/2020 + + # Uninstall the application + __dtnrch_etax_sgnp Steuer_St.Gallen_2020_nP --version 2020 --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_etax_sgnp/manifest b/type/__dtnrch_etax_sgnp/manifest new file mode 100755 index 0000000..d3876ab --- /dev/null +++ b/type/__dtnrch_etax_sgnp/manifest @@ -0,0 +1,104 @@ +#!/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/>. +# + + +os=$(cat "${__global:?}/explorer/os") + +prefix=$(cat "${__object:?}/parameter/prefix") +state_should=$(cat "${__object:?}/parameter/state") + +if meta=$(sh -e "${__type:?}/files/find_release.sh") +then + eval "${meta}" +else + echo 'No release compatible for the target could be found.' >&2 + exit 1 +fi + +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 +} + + +case ${os} +in + (debian|devuan|ubuntu) + download_dir=/var/cache/cdist/__dtnrch_etax_sgnp + + __directory "${download_dir}" --state present \ + --owner 0 --group 0 --mode 0755 --parents + export require="__directory${download_dir}" + ;; + (*) + # TODO + exit 1 + ;; +esac + +remote_file="${download_dir}/${FILENAME:?}" + +if test "${state_should}" != 'absent' +then + __download "${remote_file}" \ + --url "${url}" --sum "${CKSUM}" \ + --download remote + + require="${require-}${require:+ }__download${remote_file}" +fi + + +################################################################################ +# Install tax application + +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 + +require=${require-} \ +__dtnrch_install4j "${install_dir}" \ + --state "${state_should}" \ + --installer "${remote_file}" diff --git a/type/__dtnrch_etax_sgnp/parameter/default/state b/type/__dtnrch_etax_sgnp/parameter/default/state new file mode 100644 index 0000000..e7f6134 --- /dev/null +++ b/type/__dtnrch_etax_sgnp/parameter/default/state @@ -0,0 +1 @@ +present diff --git a/type/__dtnrch_etax_sgnp/parameter/optional b/type/__dtnrch_etax_sgnp/parameter/optional new file mode 100644 index 0000000..e1a358e --- /dev/null +++ b/type/__dtnrch_etax_sgnp/parameter/optional @@ -0,0 +1,2 @@ +prefix +state diff --git a/type/__dtnrch_etax_sgnp/parameter/required b/type/__dtnrch_etax_sgnp/parameter/required new file mode 100644 index 0000000..088eda4 --- /dev/null +++ b/type/__dtnrch_etax_sgnp/parameter/required @@ -0,0 +1 @@ +version |
