Revert "xbmk: general code cleanup"

This reverts commit 1b65e8914c.

NOTE: cleanup of xbmk_git_init was retained

this "cleanup" actually made the code harder to read.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2026-09-10 12:29:39 +01:00
parent 123639e3db
commit afdf8c7733
11 changed files with 130 additions and 938 deletions
+6 -53
View File
@@ -11,7 +11,6 @@ rmodtool="elf/coreboot/default/rmodtool"
mkrom_tarball()
{
update_xbmkver "$1"
mktarball "$1" "${1%/*}/${relname}_${1##*/}.tar.xz"
x_ rm -Rf "$1"
@@ -31,7 +30,6 @@ update_xbmkver()
xbmk_sanitize_version()
{
if [ -z "$version" ]; then
return 0
fi
@@ -44,7 +42,6 @@ xbmk_sanitize_version()
version="${version#-}"
if [ -z "$version" ]; then
err "'version' empty after sanitization" \
"xbmk_sanitize_version" "$@"
fi
@@ -55,7 +52,6 @@ mktarball()
printf "Creating tar archive '%s' from directory '%s'\n" "$2" "$1"
if [ "${2%/*}" != "$2" ]; then
x_ xbmkdir "${2%/*}"
fi
@@ -68,7 +64,6 @@ e()
es_t="e"
if [ $# -gt 1 ]; then
es_t="$2"
fi
@@ -76,7 +71,6 @@ e()
estr="[ -$es_t \"\$1\" ] || return 1"
if [ $# -gt 2 ]; then
estr="[ -$es_t \"\$1\" ] && return 1"
es2="missing"
fi
@@ -91,18 +85,14 @@ setvars()
_setvars=""
if [ $# -lt 2 ]; then
return 0
fi
val="$1"
shift 1
while [ $# -gt 0 ]; do
printf "%s=\"%s\"\n" "$1" "$val"
shift 1
done
}
@@ -118,16 +108,14 @@ singletree()
findpath()
{
if [ $# -lt 1 ]; then
err "findpath: No arguments provided" "findpath" "$@"
fi
while [ $# -gt 0 ]; do
while [ $# -gt 0 ]
do
found="`readlink -f "$1" 2>/dev/null`" || return 1; :
if [ -z "$found" ]; then
found="`realpath "$1" 2>/dev/null`" || \
return 1
fi
@@ -155,7 +143,6 @@ unpad_one_byte()
err "can't increment file size" "unpad_one_byte" "$@"
if [ $xromsize -lt 524288 ]; then
err "too small, $xromsize: $1" "unpad_one_byte" "$@"
fi
@@ -163,14 +150,12 @@ unpad_one_byte()
err "can't make tmp file" "unpad_one_byte" "$@"
x_ dd if="$1" of="$unpaddedfile" bs=$xromsize count=1
x_ mv "$unpaddedfile" "$1"
}
build_sbase()
{
if [ ! -f "$sha512sum" ]; then
x_ make -C "$xbmkpwd/util/sbase"
fi
}
@@ -178,16 +163,14 @@ build_sbase()
remkdir()
{
x_ rm -Rf "$@"
x_ xbmkdir "$@"
}
xbmkdir()
{
while [ $# -gt 0 ]; do
while [ $# -gt 0 ]
do
if [ ! -d "$1" ]; then
x_ mkdir -p "$1"
fi
@@ -198,14 +181,12 @@ xbmkdir()
fx_()
{
xchk fx_ "$@"
xcmd="$1"
xfile="`mktemp || err "can't create tmpfile"`" || \
err "can't make tmpfile" "fx_" "$@"
x_ rm -f "$xfile"
x_ touch "$xfile"
shift 1
@@ -214,7 +195,6 @@ fx_()
err "can't sort to '$xfile'" "fx_" "$xcmd" "$@"
dx_ "$xcmd" "$xfile" || :
x_ rm -f "$xfile"
}
@@ -223,30 +203,21 @@ dx_()
xchk dx_ "$@"
if [ ! -f "$2" ]; then
return 0
fi
while read -r fx; do
$1 "$fx" || return 1; :
done < "$2" \
|| err "cannot read '$2'" "dx_" "$@"; :
done < "$2" || err "cannot read '$2'" "dx_" "$@"; :
}
x_()
{
if [ $# -lt 1 ]; then
return 0
elif [ -z "$1" ]; then
err "Empty first arg" "x_" "$@"
else
"$@" || err "Unhandled error" "x_" "$@"
fi
}
@@ -254,12 +225,8 @@ x_()
xchk()
{
if [ $# -lt 3 ]; then
err "$1 needs at least two arguments" "xchk" "$@"
elif [ -z "$2" ] || \
[ -z "$3" ]; then
elif [ -z "$2" ] || [ -z "$3" ]; then
err "arguments must not be empty" "xchk" "$@"
fi
}
@@ -267,19 +234,12 @@ xchk()
err()
{
if [ $# -eq 1 ]; then
printf "ERROR %s: %s\n" "$0" "$1" 1>&2 || :
elif [ $# -gt 1 ]; then
printf "ERROR %s: %s: in command with args: " "$0" "$1" 1>&2
shift 1
xprintf "$@" 1>&2
else
printf "ERROR, but no arguments provided to err\n" 1>&2
fi
@@ -289,23 +249,16 @@ err()
xprintf()
{
xprintfargs=0
while [ $# -gt 0 ]; do
printf "\"%s\"" "$1"
if [ $# -gt 1 ]; then
printf " "
fi
xprintfargs=1
shift 1
done
if [ $xprintfargs -gt 0 ]; then
printf "\n"
fi
}