diff options
| author | Leah Rowe <leah@libreboot.org> | 2023-08-21 19:41:49 +0100 | 
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2023-08-21 22:38:00 +0100 | 
| commit | 62f23123cb2a5ef594f405053d0b111c6e01de87 (patch) | |
| tree | 74d57d43b7e3cf107c183d273d10dcd5278ab138 /resources/scripts/build/boot/roms | |
| parent | 7be4706552845824888b58054120dfac99bfdf63 (diff) | |
general code cleanup on lbmk shell scripts
in update/blobs/download, i saw instances where
appdir was being deleted with rm -r, but the more
appropriate command would rm -Rf. this is now fixed.
other than that, i've mostly just simplified a bunch
of if statements and consolidated some duplicated
logic (e.g. if/else block for dependencies in
build_dependencies() of update/blobs/download
one or two functions and/or variables have been
renamed, for greater clarity in the code, also
removed a few messages that were redundant
used printf instead of echo, in a few places, also
fixed up the indentation in a few places
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'resources/scripts/build/boot/roms')
| -rwxr-xr-x | resources/scripts/build/boot/roms | 47 | 
1 files changed, 13 insertions, 34 deletions
| diff --git a/resources/scripts/build/boot/roms b/resources/scripts/build/boot/roms index 70054fd4..44b7cb8e 100755 --- a/resources/scripts/build/boot/roms +++ b/resources/scripts/build/boot/roms @@ -36,20 +36,11 @@ firstoption=""  main()  { -	if [ $# -lt 1 ]; then -		usage -		exit 1 -	fi -	firstoption="${1}" +	[ $# -lt 1 ] && usage && exit 1 -	if [ "${firstoption}" = "help" ]; then -		usage -		exit 0 -	fi -	if [ "${firstoption}" = "list" ]; then -		listboards -		exit 0 -	fi +	firstoption="${1}" +	[ "${firstoption}" = "help" ] && usage && exit 0 +	[ "${firstoption}" = "list" ] && listboards && exit 0  	while [ $# -gt 0 ]; do  		case ${1} in @@ -68,21 +59,16 @@ main()  		shift  	done -	if [ -z ${opts+x} ]; then -		opts="" -	fi - +	[ -z ${opts+x} ] && opts=""  	printf "Building %s ROM images\n" "${projectname}"  	if [ "${firstoption}" = "all" ]; then  		for boardname in $(listboards); do -			buildrom "${boardname}" \ -					|| die "build/roms: error" +			buildrom "${boardname}" || err "build/roms: error"  		done  	else  		for board in ${boards}; do -			buildrom "${board}" \ -					|| die "build/roms: error" +			buildrom "${board}" || err "build/roms: error"  		done  	fi @@ -116,9 +102,7 @@ usage()  listboards()  {  	for boarddir in resources/coreboot/*; do -		if [ ! -d "${boarddir}" ]; then -			continue -		fi +		[ ! -d "${boarddir}" ] && continue  		board="${boarddir##resources/coreboot/}"  		board="${board%/}"  		printf '%s\n' "${board##*/}" @@ -127,18 +111,13 @@ listboards()  # Build ROM images for supported boards  buildrom() { -	board="$1" - -	if [ -d "resources/coreboot/${board}/" ]; then -		./build boot roms_helper ${board}${opts} -	else -		printf "\nbuild/roms: target not defined: %s\n" ${board} -		die "Run: ./build boot roms list" -	fi +	[ -d "resources/coreboot/${1}/" ] || \ +		err "build/roms: target not defined: ${1}" +	./build boot roms_helper ${1}${opts}  } -die() { -	printf 'Error: %s\n' "${@}" 1>&2 +err() { +	printf '%s\n' "${1}" 1>&2  	exit 1  } | 
