From 557272fa39e10e8cf6154f723913ab5c494c6101 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 14 May 2023 14:44:00 +0100 Subject: download/mrc: stricter error handling the cbfstool command within subshell now also exits with non-zero status, if it fails (most likely because extraction failed, for some reason, of the coreboot rom image for running through it) --- resources/scripts/download/mrc | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) (limited to 'resources/scripts/download') diff --git a/resources/scripts/download/mrc b/resources/scripts/download/mrc index 63ec0100..ed0b38f3 100755 --- a/resources/scripts/download/mrc +++ b/resources/scripts/download/mrc @@ -51,8 +51,8 @@ main() printf "Downloading Intel MRC blobs\n" check_existing && exit 0 - build_dependencies - fetch_mrc + build_dependencies || fail "could not build dependencies" + fetch_mrc || fail "could not fetch mrc.bin" } check_existing() @@ -74,16 +74,17 @@ check_existing() build_dependencies() { if [ ! -d "${cbdir}/" ]; then - ./download coreboot default + ./download coreboot default || return 1 fi if [ ! -f "${cbfstool}" ]; then - ./build module cbutils default + ./build module cbutils default || return 1 fi + return 0 } fetch_mrc() { - mkdir -p mrc/haswell/ + mkdir -p mrc/haswell/ || return 1 ( cd mrc/haswell/ @@ -102,22 +103,25 @@ fetch_mrc() extract_coreboot chromeos-firmwareupdate-${_board} ../../${cbfstool} coreboot-*.bin extract -f mrc.bin \ - -n mrc.bin -r RO_SECTION + -n mrc.bin -r RO_SECTION \ + || fail "Could not fetch mrc.bin" rm -f "chromeos-firmwareupdate-${_board}" coreboot-*.bin \ "${_file}" "root-a.ext2" printf "\n\nmrc.bin saved to ${_mrc_complete}\n\n" ) + + return 0 } download_image() { - _url=${1} + url=${1} _file=${2} _sha1sum=${3} echo "Downloading recovery image" - curl "$_url" > "$_file.zip" + curl "$url" > "$_file.zip" if [ "$(sha1sum ${_file}.zip | awk '{print $1}')" = "${_sha1sum}" ] then unzip -q "${_file}.zip" -- cgit v1.2.1