From 1c2f9b54c65555fcfbc690fc2022b2987ed4bd56 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 1 Apr 2023 11:20:12 +0100 Subject: blobutil/download: move main logic to the top Top-down order is easier to read, for greater understanding. What's moved is initialisation. The glue that calls Build_deps and Download_needed still need to be at the bottom. --- resources/scripts/blobs/download | 98 ++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 49 deletions(-) (limited to 'resources/scripts/blobs') diff --git a/resources/scripts/blobs/download b/resources/scripts/blobs/download index a1defc14..6f9c0cf6 100755 --- a/resources/scripts/blobs/download +++ b/resources/scripts/blobs/download @@ -8,6 +8,55 @@ board="${1}" # A shorthand for each board, to avoid duplicating configs per flash size board_short=${board%%_*mb} +set -- "resources/coreboot/${board}/config/*" +. ${1} 2>/dev/null +. "resources/coreboot/${board}/board.cfg" + +if [ "${CONFIG_HAVE_MRC}" = "y" ]; then + printf 'haswell board detected, downloading mrc\n' + needs="${needs} MRC" +fi + +if [ "${CONFIG_HAVE_IFD_BIN}" = "y" ]; then + printf 'board needs intel firmware descriptor\n' + needs="${needs} IFD" +fi + +if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then + printf 'board needs intel management engine\n' + needs="${needs} ME" +fi + +if [ "${CONFIG_HAVE_GBE_BIN}" = "y" ]; then + printf 'board needs gigabit ethernet firmware\n' + needs="${needs} GBE" +fi + +# Quickly exit without wasting more time if there are no blobs needed (GM45) +if [ -z ${needs+x} ]; then + printf 'No binary blobs needed for this board\n' + exit 0 +fi + +while read -r line ; do + case ${line} in + DL_hash*) + set ${line} + dl_hash=${2} + ;; + DL_url*) + set ${line} + dl_url=${2} + ;; + DL_url_bkup*) + set ${line} + dl_url_bkup=${2} + ;; + esac +done << EOF +$(eval "awk ' /\{.*${board_short}.*}{/ {flag=1;next} /\}/{flag=0} flag { print }' resources/blobs/sources") +EOF + Fail(){ printf "\nERROR: $@\n" exit 1 @@ -91,54 +140,5 @@ Extract_me(){ printf "Truncated and cleaned me output to ${_me_destination}\n" } -set -- "resources/coreboot/${board}/config/*" -. ${1} 2>/dev/null -. "resources/coreboot/${board}/board.cfg" - -if [ "${CONFIG_HAVE_MRC}" = "y" ]; then - printf 'haswell board detected, downloading mrc\n' - needs="${needs} MRC" -fi - -if [ "${CONFIG_HAVE_IFD_BIN}" = "y" ]; then - printf 'board needs intel firmware descriptor\n' - needs="${needs} IFD" -fi - -if [ "${CONFIG_HAVE_ME_BIN}" = "y" ]; then - printf 'board needs intel management engine\n' - needs="${needs} ME" -fi - -if [ "${CONFIG_HAVE_GBE_BIN}" = "y" ]; then - printf 'board needs gigabit ethernet firmware\n' - needs="${needs} GBE" -fi - -# Quickly exit without wasting more time if there are no blobs needed (GM45) -if [ -z ${needs+x} ]; then - printf 'No binary blobs needed for this board\n' - exit 0 -fi - Build_deps - -while read -r line ; do - case ${line} in - DL_hash*) - set ${line} - dl_hash=${2} - ;; - DL_url*) - set ${line} - dl_url=${2} - ;; - DL_url_bkup*) - set ${line} - dl_url_bkup=${2} - ;; - esac -done << EOF -$(eval "awk ' /\{.*${board_short}.*}{/ {flag=1;next} /\}/{flag=0} flag { print }' resources/blobs/sources") -EOF Download_needed -- cgit v1.2.1