diff options
Diffstat (limited to 'script/update/blobs/mrc')
-rwxr-xr-x | script/update/blobs/mrc | 53 |
1 files changed, 11 insertions, 42 deletions
diff --git a/script/update/blobs/mrc b/script/update/blobs/mrc index 4db603cd..f6c81390 100755 --- a/script/update/blobs/mrc +++ b/script/update/blobs/mrc @@ -9,6 +9,7 @@ set -u -e . "include/err.sh" +. "include/fetch.sh" export PATH="${PATH}:/sbin" @@ -43,20 +44,10 @@ main() sname=${0} printf "Downloading Intel MRC blobs\n" - check_existing || return 0 + vendor_checksum "${_mrc_complete_hash}" "${_mrc_complete}" && return 0 build_dependencies - fetch_mrc || err "could not fetch mrc.bin" -} - -check_existing() -{ - [ -f "${_mrc_complete}" ] || \ - return 0 - printf "found existing mrc.bin\n" 1>&2 - [ "$(sha512sum "${_mrc_complete}" | awk '{print $1}')" \ - = "${_mrc_complete_hash}" ] && \ - return 1 - printf "hashes did not match, starting over\n" 1>&2 + fetch "mrc" "${_url}" "${_url2}" "${_sha512sum}" \ + "mrc/haswell/${_file}.zip" "err" } build_dependencies() @@ -67,18 +58,15 @@ build_dependencies() err "build_dependencies: cannot build cbutils/default" } -fetch_mrc() +extract_mrc() { - mkdir -p mrc/haswell/ || err "fetch_mrc: !mkdir mrc/haswell" + mkdir -p mrc/haswell/ || err "extract_mrc: !mkdir mrc/haswell" ( - cd mrc/haswell/ || err "fetch_mrc: !cd mrc/haswell" + cd mrc/haswell/ || err "extract_mrc: !cd mrc/haswell" - download_image "${_url}" "${_file}" "${_sha512sum}" - [ -f ${_file} ] || \ - download_image "${_url2}" "${_file}" "${_sha512sum}" - [ -f $_file ] || \ - err "fetch_mrc: ${_file} not downloaded / verification failed." + unzip -q "${_file}.zip" || err "download_image: cannot unzip" + rm -f "${_file}.zip" || err "download_image: can't rm zip {1}" extract_partition ROOT-A "${_file}" root-a.ext2 extract_shellball root-a.ext2 chromeos-firmwareupdate-${_board} @@ -86,33 +74,14 @@ fetch_mrc() extract_coreboot chromeos-firmwareupdate-${_board} ../../"${cbfstool}" coreboot-*.bin extract -f mrc.bin -n mrc.bin \ - -r RO_SECTION || err "fetch_mrc: could not fetch mrc.bin" + -r RO_SECTION || err "extract_mrc: could not fetch mrc.bin" rm -f "chromeos-firmwareupdate-${_board}" coreboot-*.bin \ - "${_file}" "root-a.ext2" || err "fetch_mrc: cannot remove files" + "${_file}" "root-a.ext2" || err "extract_mrc: cannot remove files" printf "\n\nmrc.bin saved to ${_mrc_complete}\n\n" ) } -download_image() -{ - url=${1} - _file=${2} - _sha512sum=${3} - - printf "Downloading recovery image\n" - curl --retry 3 "$url" > "$_file.zip" || err "download_image: curl failed" - printf "Verifying recovery image checksum\n" - if [ "$(sha512sum "${_file}.zip" | awk '{print $1}')" = "${_sha512sum}" ] - then - unzip -q "${_file}.zip" || err "download_image: cannot unzip" - rm -f "${_file}.zip" || err "download_image: can't rm zip {1}" - return 0 - fi - rm -f "${_file}.zip" || err "download_image: bad hash, and can't rm zip" - err "download_image: Bad checksum. Recovery image deleted" -} - extract_partition() { NAME=${1} |