diff options
| author | Leah Rowe <leah@libreboot.org> | 2023-08-24 00:30:07 +0100 | 
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2023-08-24 00:31:19 +0100 | 
| commit | 8f4f0e00ec3c307599f7f27777e3e92c1f9f6e4e (patch) | |
| tree | 39ec749c16892b69cda00b6241714f475a1989b6 /resources/scripts/build/clean | |
| parent | 4c6c7d1088eb9dc0c9b2eeeb64febeeb78038583 (diff) | |
use the new coding style in scripts
there were stragglers left over from the last audit,
and these stragglers still exist even after all the
major re-factoring as of late
the new style is: bsd-like coding style and error
handling. verbose yet simple error handling. we use
an "err" function in a way reminiscent of most C
programs that you see in openbsd base (err.h)
this style is very clean, resulting in readable code
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'resources/scripts/build/clean')
| -rwxr-xr-x | resources/scripts/build/clean/cbutils | 52 | ||||
| -rwxr-xr-x | resources/scripts/build/clean/crossgcc | 7 | ||||
| -rwxr-xr-x | resources/scripts/build/clean/seabios | 27 | ||||
| -rwxr-xr-x | resources/scripts/build/clean/u-boot | 33 | 
4 files changed, 77 insertions, 42 deletions
| diff --git a/resources/scripts/build/clean/cbutils b/resources/scripts/build/clean/cbutils index dec8d944..067c2cb2 100755 --- a/resources/scripts/build/clean/cbutils +++ b/resources/scripts/build/clean/cbutils @@ -24,26 +24,36 @@  [ "x${DEBUG+set}" = 'xset' ] && set -v  set -u -e -# clean coreboot utilities (dependencies for 'build'): - -printf "Cleaning the previous build of coreboot and its utilities\n" - -rm -Rf cbutils - -[ ! -d "coreboot/" ] && exit 0 - -for tree in coreboot/*; do -	[ "${tree##*/}" = "coreboot" ] && continue -	[ -d "${tree}" ] || continue - -	# Clean coreboot, of course -	make -C "${tree}/" distclean - -	# Clean its utilities as well -	for util in cbfstool ifdtool nvramtool cbmem; do -		make distclean -C "${tree}/util/${util}/" +. "include/err.sh" + +main() +{ +	printf "Cleaning the previous build of coreboot and its utilities\n" + +	rm -Rf cbutils || err "cannot remove cbutils/" +	[ ! -d "coreboot/" ] && exit 0 + +	clean_cbutils +} + +clean_cbutils() +{ +	for tree in coreboot/*; do +		[ "${tree##*/}" = "coreboot" ] && continue +		[ -d "${tree}" ] || continue + +		# Clean coreboot, of course +		make -C "${tree}/" distclean || \ +		    err "cannot distclean coreboot tree, ${tree}" + +		# Clean its utilities as well +		for util in cbfstool ifdtool nvramtool cbmem; do +			make distclean -C "${tree}/util/${util}/" || \ +			    err "cannot clean util, ${util}, at ${tree}" +		done +		make distclean -C "${tree}/payloads/libpayload/" || \ +		    err "cannot distclean libpayload, at ${tree}"  	done -	make distclean -C "${tree}/payloads/libpayload/" -done +} -printf "\n\n" +main $@ diff --git a/resources/scripts/build/clean/crossgcc b/resources/scripts/build/clean/crossgcc index 76de1e19..7b1765f8 100755 --- a/resources/scripts/build/clean/crossgcc +++ b/resources/scripts/build/clean/crossgcc @@ -29,9 +29,14 @@ main()  	printf "Cleaning crossgcc builds in all coreboot archives\n"  	[ ! -d "coreboot/" ] && exit 0 +	clean_crossgcc +} + +clean_crossgcc() +{  	for board in coreboot/*; do +		[ -d "${board}" ] || continue  		[ "${board##*/}" = "coreboot" ] && continue -		[ ! -d "${board}" ] && continue  		make -C "${board}/" crossgcc-clean || err "make-clean"  	done  } diff --git a/resources/scripts/build/clean/seabios b/resources/scripts/build/clean/seabios index e9b11e5b..c6759e83 100755 --- a/resources/scripts/build/clean/seabios +++ b/resources/scripts/build/clean/seabios @@ -2,7 +2,7 @@  #  helper script: clean the dependencies that were built in seabios  # -#	Copyright (C) 2015, 2020, 2021 Leah Rowe <info@minifree.org> +#	Copyright (C) 2015,2020,2021,2023 Leah Rowe <info@minifree.org>  #  #    This program is free software: you can redistribute it and/or modify  #    it under the terms of the GNU General Public License as published by @@ -26,13 +26,22 @@ set -u -e  # clean bucts  # -------------------------------------------------------- -printf "Cleaning the previous builds of seabios\n" +main() +{ +	[ ! -d "elf/seabios" ] || rm -Rf elf/seabios || \ +	    err "cannot remove elf/seabios" +	[ ! -d "seabios/" ] && exit 0 -[ ! -d "elf/seabios" ] || rm -Rf elf/seabios || err "cannot remove elf/seabios" -[ ! -d "seabios/" ] && exit 0 +	clean_seabios +} -for x in seabios/*; do -	[ "${x}" = "seabios/seabios" ] && continue -	[ ! -d "${x}" ] && continue -	make -C "${x}" distclean || err "cannot distclean tree, ${x}" -done +clean_seabios() +{ +	for x in seabios/*; do +		[ ! -d "${x}" ] && continue +		[ "${x}" = "seabios/seabios" ] && continue +		make -C "${x}" distclean || err "cannot distclean tree, ${x}" +	done +} + +main $@ diff --git a/resources/scripts/build/clean/u-boot b/resources/scripts/build/clean/u-boot index 6a59a5c1..7ba3a4a9 100755 --- a/resources/scripts/build/clean/u-boot +++ b/resources/scripts/build/clean/u-boot @@ -2,7 +2,7 @@  #  helper script: clean the u-boot builds  # -#	   Copyright (C) 2014, 2015, 2016, 2020 Leah Rowe <info@minifree.org> +#	   Copyright (C) 2014-2016, 2020, 2023 Leah Rowe <info@minifree.org>  #	   Copyright (C) 2015 Klemens Nanni <contact@autoboot.org>  #	   Copyright (C) 2022 Alper Nebi Yasak <alpernebiyasak@gmail.com>  # @@ -23,17 +23,28 @@  [ "x${DEBUG+set}" = 'xset' ] && set -v  set -u -e -printf "Cleaning u-boot builds for all boards\n" +. "include/err.sh" -for board in u-boot/*; do -	if [ "${board##*/}" = "u-boot" ] || [ ! -d "${board}" ]; then -		continue -	fi +main() +{ +	printf "Cleaning u-boot builds for all boards\n" +	clean_uboot +} -	make -C "${board}/" distclean +clean_uboot() +{ +	for board in u-boot/*; do +		if [ "${board##*/}" = "u-boot" ] || [ ! -d "${board}" ]; then +			continue +		fi -	[ -e "${board}/.git" ] && \ -		git -C "${board}" clean -fdx -done +		make -C "${board}/" distclean || \ +		    err "cannot distclean u-boot dir, ${board}" -printf "\n\n" +		[ ! -e "${board}/.git" ] || \ +			git -C "${board}" clean -fdx || \ +			    err "cannot clean u-boot git repo, ${board}" +	done +} + +main $@ | 
