summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-05-15 00:10:19 +0100
committerLeah Rowe <leah@libreboot.org>2023-05-15 00:10:37 +0100
commitb24fbc74c36bfd5089d44e0ec3983a3fe9ef50fa (patch)
tree4f73be14bf932683f3aa103ceb1212904337c022
parent2871db159d5619e87054eaff019e1ecea25bb239 (diff)
download/coreboot: move initial logic to main()
-rwxr-xr-xresources/scripts/download/coreboot93
1 files changed, 49 insertions, 44 deletions
diff --git a/resources/scripts/download/coreboot b/resources/scripts/download/coreboot
index b5825892..1a596fd0 100755
--- a/resources/scripts/download/coreboot
+++ b/resources/scripts/download/coreboot
@@ -26,6 +26,54 @@
[ "x${DEBUG+set}" = 'xset' ] && set -v
set -u -e
+main()
+{
+ # In this script, set -u is used to check for undefined variables, and
+ # the test command doesn't do any lazy evaluation, so we can't use
+ # a syntax like that: [ $# -eq 1 -a "$1" = "--help" ].
+
+ if [ $# -eq 1 ] && [ "$1" = "--help" ] ; then
+ usage
+ exit 0
+ elif [ $# -eq 1 ] && [ "$1" = "--list-boards" ] ; then
+ list_supported_boards
+ exit 0
+ fi
+
+ [ -f build_error ] && rm -f build_error
+
+ rm -f resources/coreboot/*/seen
+
+ printf "Downloading coreboot and (if available) applying patches\n"
+
+ if [ $# -gt 0 ]; then
+ for board in "${@}"; do
+ rm -f resources/coreboot/*/seen
+ downloadfor "${board}"
+ if [ -f build_error ]; then
+ break
+ fi
+ done
+ else
+ for board in resources/coreboot/*; do
+ rm -f resources/coreboot/*/seen
+ if [ ! -d "${board}/" ]; then
+ continue
+ fi
+ downloadfor "${board##*/}"
+ if [ -f build_error ]; then
+ break
+ fi
+ done
+ fi
+
+ rm -f resources/coreboot/*/seen
+
+ rm -f "build_error"
+ printf "\n\n"
+ exit 0
+}
+
list_supported_boards()
{
for board in resources/coreboot/*; do
@@ -45,22 +93,6 @@ usage()
printf "\t%s --help\t\t# Prints this help\n" ${progname}
}
-# In this script, set -u is used to check for undefined variables, and
-# the test command doesn't do any lazy evaluation, so we can't use
-# a syntax like that: [ $# -eq 1 -a "$1" = "--help" ].
-
-if [ $# -eq 1 ] && [ "$1" = "--help" ] ; then
- usage
- exit 0
-elif [ $# -eq 1 ] && [ "$1" = "--list-boards" ] ; then
- list_supported_boards
- exit 0
-fi
-
-[ -f build_error ] && rm -f build_error
-
-rm -f resources/coreboot/*/seen
-
downloadfor() {
board="${1}"
@@ -235,31 +267,4 @@ downloadfor() {
fi
}
-printf "Downloading coreboot and (if exist in build system) applying patches\n"
-
-if [ $# -gt 0 ]; then
- for board in "${@}"; do
- rm -f resources/coreboot/*/seen
- downloadfor "${board}"
- if [ -f build_error ]; then
- break
- fi
- done
-else
- for board in resources/coreboot/*; do
- rm -f resources/coreboot/*/seen
- if [ ! -d "${board}/" ]; then
- continue
- fi
- downloadfor "${board##*/}"
- if [ -f build_error ]; then
- break
- fi
- done
-fi
-
-rm -f resources/coreboot/*/seen
-
-rm -f "build_error"
-printf "\n\n"
-exit 0
+main $@