[PATCH 12/13] scripts/k3img: remove temporary files
Sascha Hauer
s.hauer at pengutronix.de
Thu Feb 27 23:17:00 PST 2025
Remove temporary files when exiting the script. While at it add a "set
-e" to exit the script when a command fails.
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
scripts/k3img | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/scripts/k3img b/scripts/k3img
index 048da82b92..a514852fcd 100755
--- a/scripts/k3img
+++ b/scripts/k3img
@@ -1,5 +1,7 @@
#!/bin/bash
+set -e
+
TEMP=$(getopt -o '' --long 'sysfw:,sysfwdata:,dmdata:,out:,sbl:,key:,innerdata:' -n 'k3img' -- "$@")
if [ $? -ne 0 ]; then
@@ -76,8 +78,11 @@ dmdatasize=$(stat -c%s $dmdata)
total=$(($sblsize + $sysfwsize + $sysfwdatasize + $dmdatasize))
-certcfg=$(mktemp k3img.XXXXXXX)
-cert=$(mktemp k3img.XXXXXXX)
+TMPDIR="$(mktemp -d)"
+trap 'rm -rf -- "$TMPDIR"' EXIT
+
+certcfg=${TMPDIR}/certcfg
+cert=${TMPDIR}/cert
num_comp=4
--
2.39.5
More information about the barebox
mailing list