blobutil/extract: top-down logic

fsdg20230625
Leah Rowe 2023-05-14 09:19:44 +01:00
parent 423e203399
commit 1ffb32b78f
1 changed files with 44 additions and 29 deletions

View File

@ -5,18 +5,40 @@
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org> # SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
# SPDX-License-Identifier: GPL-3.0-only # SPDX-License-Identifier: GPL-3.0-only
board="${1}" sname=""
vendor_rom="${2}" board=""
vendor_rom=""
Print_help(){ main()
printf "Usage: ./blobutil extract {boardname} {path/to/vendor_rom}\n" {
printf "Example: ./blobutil extract x230 12mb_flash.bin\n" sname=${0}
printf "\nYou need to specify exactly 2 arguments\n" if [ $# -lt 2 ]; then
} Fail "Missing arguments (less than two)."
fi
Fail(){ board="${1}"
printf "\nERROR: $@\n" vendor_rom="${2}"
exit 1
if [ ! -f "${vendor_rom}" ] ; then
Print_help
exit 1
fi
if [ ! -d "resources/coreboot/${board}" ]; then
Print_help
printf "build/roms %s: target not defined.\n" \
"${projectname}" ${board}
exit 1
fi
if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then
Print_help
printf "build/roms %s: missing board.cfg.\n" ${board}
exit 1
fi
Build_deps
Extract_blobs
} }
Build_deps(){ Build_deps(){
@ -44,8 +66,9 @@ Build_deps(){
fi fi
} }
Extract_blobs(){ Extract_blobs(){
printf "extracting blobs for %s from %s\n" ${board} ${vendor_rom}
# TODO: find a better way to know which coreboot config to source # TODO: find a better way to know which coreboot config to source
set -- "resources/coreboot/${board}/config/"* set -- "resources/coreboot/${board}/config/"*
. ${1} 2>/dev/null . ${1} 2>/dev/null
@ -83,24 +106,16 @@ Extract_blobs(){
fi fi
} }
if [ ! -f "${vendor_rom}" ] ; then Print_help(){
printf "Usage: ./blobutil extract {boardname} {path/to/vendor_rom}\n"
printf "Example: ./blobutil extract x230 12mb_flash.bin\n"
printf "\nYou need to specify exactly 2 arguments\n"
}
Fail(){
Print_help Print_help
printf "\n%s: ERROR: %s\n" ${sname} $@
exit 1 exit 1
fi }
if [ ! -d "resources/coreboot/${board}" ]; then main $@
Print_help
printf "build/roms %s: target not defined. Skipping extraction.\n" \
"${projectname}" ${board}
exit 1
fi
if [ ! -f "resources/coreboot/${board}/board.cfg" ]; then
Print_help
printf "build/roms %s: missing board.cfg. Skipping build.\n" ${board}
exit 1
fi
printf "extracting blobs for ${board} from ${vendor_rom}\n"
Build_deps
Extract_blobs