From beace0166e5eb362fd39f76e2ef59dcc2cfffeab Mon Sep 17 00:00:00 2001 From: Dennis Camera Date: Sat, 20 Mar 2021 20:27:31 +0100 Subject: [type/__dtnrch_install4j] Store installer cksum to detect updates --- type/__dtnrch_install4j/explorer/state | 13 ++++++++++++- type/__dtnrch_install4j/gencode-remote | 5 ++++- 2 files changed, 16 insertions(+), 2 deletions(-) (limited to 'type') diff --git a/type/__dtnrch_install4j/explorer/state b/type/__dtnrch_install4j/explorer/state index e9b3f99..4d3c9d3 100644 --- a/type/__dtnrch_install4j/explorer/state +++ b/type/__dtnrch_install4j/explorer/state @@ -20,11 +20,22 @@ # Print the current installation state of the install4j "package". # +installer=$(cat "${__object:?}/parameter/installer") destination=/${__object_id:?} if test -d "${destination}/.install4j" then - echo 'present' + if find "${destination}/.install4j/inst_cksum" -newer "${destination}/.install4j/files.log" | grep -q . + then + if cksum "${installer}" | cut -d ' ' -f 1,2 | cmp -s "${destination}/.install4j/inst_cksum" - + then + echo 'present' + else + echo 'different' + fi + else + echo 'outdated' + fi else echo 'absent' fi diff --git a/type/__dtnrch_install4j/gencode-remote b/type/__dtnrch_install4j/gencode-remote index 784afc9..d472f95 100755 --- a/type/__dtnrch_install4j/gencode-remote +++ b/type/__dtnrch_install4j/gencode-remote @@ -66,6 +66,7 @@ in 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" echo 'installed' >>"${__messages_out:?}" ;; @@ -91,6 +92,8 @@ in mkdir "${remote_logs_dir}" || exit 1 + rm -f '${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=$? @@ -98,7 +101,7 @@ in cat >&2 <"${remote_logs_dir}/i4j_stderr" # install4j has issues with using exit codes, so we scan for errors in its output. - awk -v err=$((i4j_exit)) '/^An error occurred:/{if(!err)err=1} END{exit err}' "${remote_logs_dir}/i4j_stdout" "${remote_logs_dir}/i4j_stderr" + awk -v err=$((i4j_exit)) '/^An error occurred:/ || /^Error: A fatal exception has occurred./ {if(!err)err=1} END{exit err}' "${remote_logs_dir}/i4j_stdout" "${remote_logs_dir}/i4j_stderr" EOF echo 'uninstalled' >>"${__messages_out:?}" -- cgit v1.2.3