From c884ddf1e1e319cae309612902b4eaf3ca8be076 Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Sun, 14 Mar 2021 12:32:57 +0100 Subject: [type/__dtnrch_etax_sgnp] Reorganize download code --- type/__dtnrch_etax_sgnp/manifest | 71 ++++++++++++++-------------------------- 1 file changed, 24 insertions(+), 47 deletions(-) (limited to 'type') diff --git a/type/__dtnrch_etax_sgnp/manifest b/type/__dtnrch_etax_sgnp/manifest index fe97508..428206f 100755 --- a/type/__dtnrch_etax_sgnp/manifest +++ b/type/__dtnrch_etax_sgnp/manifest @@ -64,6 +64,9 @@ else fi +################################################################################ +# Download tax application + case ${os} in (debian|devuan|ubuntu) @@ -71,7 +74,6 @@ in __directory "${download_dir}" --state present \ --owner 0 --group 0 --mode 0755 --parents - export require="__directory${download_dir}" ;; (*) # TODO: error message @@ -79,63 +81,38 @@ in ;; esac -################################################################################ -# 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 -} - - -################################################################################ -# Download tax application - 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}" \ + --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 - ################################################################################ # Install tax application -- cgit v1.2.3