From 522fd2a0af591c12e2089601c0aab4097cc749c1 Mon Sep 17 00:00:00 2001 From: Vadim Bendebury Date: Sat, 23 Mar 2019 13:06:32 -0700 Subject: sign_cr50_firmware: improve error reporting In case jq does not find a node in the JSON file, it still returns with exit code of 0, it just prints 'null' instead of the expected node value. This patch adds processing this error condition, which makes it easier to troubleshoot the case of misconfigured Cr50 signing manifest. BRANCH=none BUG=b:74100307 TEST=tried using the script with a manifest which does not have the node of board_id_flags defined. Observed error message of ...sign_cr50_firmware.sh: ERROR : bid_flags not found in... instead of previous error reported as ...sign_cr50_firmware.sh: line 53: null: unbound variable Change-Id: I70acff7a3331b01f0f964f2942bf2806a2af8691 Signed-off-by: Vadim Bendebury Reviewed-on: https://chromium-review.googlesource.com/1537260 Reviewed-by: Mike Frysinger --- scripts/image_signing/sign_cr50_firmware.sh | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/scripts/image_signing/sign_cr50_firmware.sh b/scripts/image_signing/sign_cr50_firmware.sh index b39babac..1616e49b 100755 --- a/scripts/image_signing/sign_cr50_firmware.sh +++ b/scripts/image_signing/sign_cr50_firmware.sh @@ -43,7 +43,14 @@ verify_cr50_manifest() { local bid_flags major="$(jq '.major' "${manifest_json}")" + if [[ ${major} == null ]]; then + die "Major version number not found in ${manifest_json}" + fi + bid_flags="$(jq '.board_id_flags' "${manifest_json}")" + if [[ ${bid_flags} == null ]]; then + die "bid_flags not found in ${manifest_json}" + fi if (( major & 1 )); then if (( bid_flags & MP_BID_FLAG )); then -- cgit v1.2.1