diff options
| author | Leah Rowe <leah@libreboot.org> | 2025-05-04 09:56:21 +0100 | 
|---|---|---|
| committer | Leah Rowe <leah@libreboot.org> | 2025-05-04 10:13:42 +0100 | 
| commit | 54291ebb7209c314bb52f507bc6a1ecf2a28fbc9 (patch) | |
| tree | af71ac248c7570d944d82c6b2428eaacf70c9534 /include/rom.sh | |
| parent | 3f7dc2a55f5b2273e73e17e4cec75faffe65740f (diff) | |
lbmk: MUCH safer err function
Don't directly call a variable. Call a function that
checks the variable instead.
The new err function also checks whether an exit was
actually done, and exits 1 if not.
If an exit was done by the given function, but the exit
was zero, this is also corrected to perform an exit 1.
This fixes a longstanding design flaw of lbmk.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include/rom.sh')
| -rw-r--r-- | include/rom.sh | 18 | 
1 files changed, 9 insertions, 9 deletions
| diff --git a/include/rom.sh b/include/rom.sh index ec464d85..af739d92 100644 --- a/include/rom.sh +++ b/include/rom.sh @@ -11,7 +11,7 @@ mkserprog()  {  	[ "$_f" = "-d" ] && return 0 # dry run  	basename -as .h "$serdir/"*.h > "$xbmktmp/ser" || \ -	    $err "!mk $1 $xbmktmp" +	    err "!mk $1 $xbmktmp"  	while read -r sertarget; do  		[ "$1" = "pico" ] && x_ cmake -DPICO_BOARD="$sertarget" \ @@ -33,8 +33,8 @@ copyps1bios()  	x_ cp src/pcsx-redux/src/mips/openbios/openbios.bin bin/playstation  	printf "MIT License\n\nCopyright (c) 2019-2024 PCSX-Redux authors\n\n" \ -	    > bin/playstation/COPYING.txt || $err "!pcsx-redux copyright" -	cat config/snippet/mit >>bin/playstation/COPYING.txt || $err "!pcsx MIT" +	    > bin/playstation/COPYING.txt || err "!pcsx-redux copyright" +	cat config/snippet/mit >>bin/playstation/COPYING.txt || err "!pcsx MIT"  }  mkpayload_grub() @@ -55,7 +55,7 @@ mkvendorfiles()  	[ -z "$mode" ] && $dry cook_coreboot_config  	check_coreboot_utils "$tree"  	printf "%s\n" "${version%%-*}" > "$srcdir/.coreboot-version" || \ -	    $err "!mk $srcdir .coreboot-version" +	    err "!mk $srcdir .coreboot-version"  	[ -z "$mode" ] && [ "$target" != "$tree" ] && \  	    x_ ./mk download "$target"; :  } @@ -64,8 +64,8 @@ cook_coreboot_config()  {  	[ -f "$srcdir/.config" ] || return 0  	printf "CONFIG_CCACHE=y\n" >> "$srcdir/.config" || \ -	    $err "$srcdir/.config: Could not enable ccache" -	make -C "$srcdir" oldconfig || $err "Could not cook $srcdir/.config"; : +	    err "$srcdir/.config: Could not enable ccache" +	make -C "$srcdir" oldconfig || err "Could not cook $srcdir/.config"; :  }  check_coreboot_utils() @@ -105,7 +105,7 @@ mkcorebootbin()  	[ "$payload_uboot_i386" = "y" ] && \  	    [ "$payload_uboot_amd64" = "y" ] && \ -		$err "'$target' enables 32- and 64-bit x86 U-Boot" +		err "'$target' enables 32- and 64-bit x86 U-Boot"  	if [ "$payload_uboot_i386" = "y" ] || \  	    [ "$payload_uboot_amd64" = "y" ]; then @@ -118,7 +118,7 @@ mkcorebootbin()  	[ "$payload_uboot" = "y" ] || payload_seabios="y"  	[ "$payload_grub" = "y" ] && payload_seabios="y"  	[ "$payload_seabios" = "y" ] && [ "$payload_uboot" = "y" ] && \ -	    $dry $err "$target: U-Boot(arm64) and SeaBIOS/GRUB both enabled." +	    $dry err "$target: U-Boot(arm64) and SeaBIOS/GRUB both enabled."  	[ -z "$grub_scan_disk" ] && grub_scan_disk="nvme ahci ata" @@ -180,7 +180,7 @@ add_grub()  	    _grubname="fallback/payload"  	cbfs "$tmprom" "$grubelf" "$_grubname"  	printf "set grub_scan_disk=\"%s\"\n" "$grub_scan_disk" \ -	    > "$xbmktmp/tmpcfg" || $err "$target: !insert scandisk" +	    > "$xbmktmp/tmpcfg" || err "$target: !insert scandisk"  	cbfs "$tmprom" "$xbmktmp/tmpcfg" scan.cfg raw  	[ "$initmode" != "normal" ] && [ "$displaymode" != "txtmode" ] && \  	    cbfs "$tmprom" "$grubdata/background/background1280x800.png" \ | 
