From: Marc Kleine-Budde <m...@pengutronix.de>

This patch changes cs_get_ca() to only output the CA if it actually
exists, or print an error and return 1 instead. This makes it possible
to use make's $(if $(filter-out, ERROR_CA_NOT_YET_SET, ...))
conditional.

Co-authored-by: Roland Hieber <r...@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <m...@pengutronix.de>
Signed-off-by: Roland Hieber <r...@pengutronix.de>
---
PATCH v3:
 - correctly check for existence of ${keydir} instead of ${ca} (feedback
   from Michael Olbrich)
 - drop controversial re-indentation patches 6/7 and 7/7 from the series

PATCH v2 (rhi): 
https://lore.ptxdist.org/ptxdist/20210627231121.28313-1-...@pengutronix.de
 - reorder from PATCH 3/n to PATCH 1/n
 - echo "ERROR_CA_NOT_YET_SET" in case of error (feedback from Michael
   Olbrich) and also return 1

PATCH v1 (mkl): 
https://lore.ptxdist.org/ptxdist/20210412161900.2376802-3-...@pengutronix.de
---
 scripts/lib/ptxd_lib_code_signing.sh | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/scripts/lib/ptxd_lib_code_signing.sh 
b/scripts/lib/ptxd_lib_code_signing.sh
index 3e1654bb36e4..199f679ef828 100644
--- a/scripts/lib/ptxd_lib_code_signing.sh
+++ b/scripts/lib/ptxd_lib_code_signing.sh
@@ -243,7 +243,13 @@ cs_get_ca() {
     local role="${1}"
     cs_init_variables
 
-    echo "${keydir}/${role}/ca.pem"
+    local ca="${keydir}/${role}/ca.pem"
+
+    if [ ! -d "${keydir}" ]; then
+       echo "ERROR_CA_NOT_YET_SET"
+       return 1
+    fi
+    echo "${ca}"
 }
 export -f cs_get_ca
 
-- 
2.30.2


_______________________________________________
ptxdist mailing list
ptxdist@pengutronix.de
To unsubscribe, send a mail with subject "unsubscribe" to 
ptxdist-requ...@pengutronix.de

Reply via email to