diff options
| author | Dennis Camera <cdist@dtnr.ch> | 2021-02-14 20:39:13 +0100 |
|---|---|---|
| committer | Dennis Camera <cdist@dtnr.ch> | 2021-03-19 11:06:07 +0100 |
| commit | 4b861191caeb46777fb93df5befe8c05bd042859 (patch) | |
| tree | f5e40ed8c1e3b1c43e5fc55efc425a104987956b /type | |
| parent | 21843997a137af0f82fe2a380628d20179841b09 (diff) | |
| download | __dtnrch_egov-4b861191caeb46777fb93df5befe8c05bd042859.tar.gz __dtnrch_egov-4b861191caeb46777fb93df5befe8c05bd042859.zip | |
[type/__dtnrch_etax_sgnp] Add parameter to add custom MIME type
Diffstat (limited to 'type')
| -rwxr-xr-x | type/__dtnrch_etax_sgnp/files/mkmime.xml.sh | 18 | ||||
| -rw-r--r-- | type/__dtnrch_etax_sgnp/man.rst | 4 | ||||
| -rwxr-xr-x | type/__dtnrch_etax_sgnp/manifest | 77 | ||||
| -rw-r--r-- | type/__dtnrch_etax_sgnp/parameter/boolean | 1 |
4 files changed, 84 insertions, 16 deletions
diff --git a/type/__dtnrch_etax_sgnp/files/mkmime.xml.sh b/type/__dtnrch_etax_sgnp/files/mkmime.xml.sh new file mode 100755 index 0000000..5d73533 --- /dev/null +++ b/type/__dtnrch_etax_sgnp/files/mkmime.xml.sh @@ -0,0 +1,18 @@ +#!/bin/sh -e + +version=$(cat "${__object:?}/parameter/version") + +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!--> + <mime-type type="application/x-sgnp${version}"> + <comment>Tax declaration St.Gallen nP ${version}</comment> + <comment xml:lang="de">Steuererklärung St.Gallen nP ${version}</comment> + <comment xml:lang="fr">Déclaration d'impôt St.Gallen nP ${version}</comment> + <comment xml:lang="it">Dichiarazione dei redditi St.Gallen nP ${version}</comment> + <comment xml:lang="rm">Decleraziun da taglia St.Gallen nP ${version}</comment> + <glob pattern="*.sgnp${version}"/> + </mime-type> +</mime-info> +EOF diff --git a/type/__dtnrch_etax_sgnp/man.rst b/type/__dtnrch_etax_sgnp/man.rst index 2667ce3..bee8e5d 100644 --- a/type/__dtnrch_etax_sgnp/man.rst +++ b/type/__dtnrch_etax_sgnp/man.rst @@ -33,7 +33,9 @@ state BOOLEAN PARAMETERS ------------------ -None. +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). EXAMPLES diff --git a/type/__dtnrch_etax_sgnp/manifest b/type/__dtnrch_etax_sgnp/manifest index d3876ab..ff51059 100755 --- a/type/__dtnrch_etax_sgnp/manifest +++ b/type/__dtnrch_etax_sgnp/manifest @@ -21,7 +21,11 @@ os=$(cat "${__global:?}/explorer/os") -prefix=$(cat "${__object:?}/parameter/prefix") +if test -s "${__object:?}/parameter/prefix" +then + prefix=$(cat "${__object:?}/parameter/prefix") +fi + state_should=$(cat "${__object:?}/parameter/state") if meta=$(sh -e "${__type:?}/files/find_release.sh") @@ -32,6 +36,25 @@ else exit 1 fi + +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: error message + exit 1 + ;; +esac + +################################################################################ +# Check download URLs (to select one that works) + for _url in "${URL-}" "${URL_ALT-}" "${URL_ARCHIVE-}" do test -n "${_url}" || continue @@ -55,20 +78,8 @@ test -n "${CKSUM}" || { } -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 +################################################################################ +# Download and install tax application remote_file="${download_dir}/${FILENAME:?}" @@ -98,7 +109,43 @@ then install_dir="${prefix}/${install_dir##*/}" fi +install_dir=${prefix:-${DEFAULT_INSTALL_DIR}} require=${require-} \ __dtnrch_install4j "${install_dir}" \ --state "${state_should}" \ --installer "${remote_file}" +export require="__dtnrch_install4j${install_dir}" + + +################################################################################ +# 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 + +version=$(cat "${__object:?}/parameter/version") +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} " + +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" \ + --onchange "update-mime-database ${xdg_mime_dir}" diff --git a/type/__dtnrch_etax_sgnp/parameter/boolean b/type/__dtnrch_etax_sgnp/parameter/boolean new file mode 100644 index 0000000..5e3edd2 --- /dev/null +++ b/type/__dtnrch_etax_sgnp/parameter/boolean @@ -0,0 +1 @@ +patch-mime |
