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)
fsdg20230625
Leah Rowe 2023-05-14 14:44:00 +01:00
parent 7b36ffc1e5
commit 557272fa39
1 changed files with 12 additions and 8 deletions

View File

@ -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"