summaryrefslogtreecommitdiff
path: root/include/lib.sh
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-09-10 12:29:39 +0100
committerLeah Rowe <leah@libreboot.org>2026-09-10 12:34:35 +0100
commitafdf8c7733f81ca196c70a40566ec75111c31c33 (patch)
treea4671c68d72cbf9ecc58b3f08d89aa8c8f2c7d21 /include/lib.sh
parent123639e3db0757fb3370516f7eaf50cbfae4d026 (diff)
Revert "xbmk: general code cleanup"
This reverts commit 1b65e8914c4ad1e140b573fa6bc8feead14542ad. 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>
Diffstat (limited to 'include/lib.sh')
-rw-r--r--include/lib.sh59
1 files changed, 6 insertions, 53 deletions
diff --git a/include/lib.sh b/include/lib.sh
index 0c7d9ba2..812341f4 100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -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
}