From 536fc8d33db571108459493d1881cdfc8371d3cc Mon Sep 17 00:00:00 2001 From: Andre Heinecke Date: Tue, 13 Aug 2024 12:30:52 +0200 Subject: [PATCH] build-aux: Add cleanup to gpg-authcode-sign.sh * tools/gpg-authcode-sign.sh (cleanup): New. -- When using osslsigncode it does not delete the output file on error. Errors or cancels there can happen easily with either timestamp problems or a wrong password. Additionally, if an output file exists, osslsigncode does not write a good error message but shows some exception. --- tools/gpg-authcode-sign.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/gpg-authcode-sign.sh b/tools/gpg-authcode-sign.sh index 171e691f5..6e623ed06 100755 --- a/tools/gpg-authcode-sign.sh +++ b/tools/gpg-authcode-sign.sh @@ -183,6 +183,16 @@ if [ ! -f $autogenrc ]; then exit 1 fi +# Define the cleanup routine for osslsigncode +cleanup() { + if [[ -n "$outname" && -f "${outname}.tmp" ]]; then + echo "Cleaning up: Removing ${outname}.tmp" + rm -f "${outname}.tmp" + fi +} + +# Trap any error to call the cleanup routine +trap cleanup ERR SIGINT SIGTERM for v in AUTHENTICODE_SIGNHOST AUTHENTICODE_TOOL AUTHENTICODE_TSURL \ AUTHENTICODE_KEY AUTHENTICODE_CERTS VERSION_SIGNKEY \