summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2026-09-12 14:27:14 +0100
committerLeah Rowe <leah@libreboot.org>2026-09-12 14:29:11 +0100
commita32374f6cc670789732628dfa003baf51374c7a2 (patch)
tree5f25daa59547696ebcbfde6768328a6d6835bb8a /include
parent897c2667af32342a39093733315a25cc2e0296e8 (diff)
more cleanup
this will be the last time, i promise Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include')
-rw-r--r--include/get.sh11
-rw-r--r--include/init.sh45
-rw-r--r--include/inject.sh25
-rw-r--r--include/tree.sh72
-rw-r--r--include/vendor.sh13
5 files changed, 65 insertions, 101 deletions
diff --git a/include/get.sh b/include/get.sh
index ea03b07f..f10c8597 100644
--- a/include/get.sh
+++ b/include/get.sh
@@ -140,11 +140,10 @@ try_fetch_git()
x_ xbmkdir "${5%/*}" "${cached%/*}"
- if ! try_$2 "$cached" "$@"; then
+ try_$2 "$cached" "$@" || \
return 1
- elif [ ! -d "$cached" ]; then
+ [ ! -d "$cached" ] && \
return 1
- fi
if [ ! -d "$5" ]; then
tmpclone "$cached" "$5" "$6" "$7" || \
@@ -166,10 +165,9 @@ try_fetch_curl()
x_ rm -f "$cached"
fi
- [ ! -f "$cached" ] && \
- if ! try_$2 "$cached" "$@"; then
+ [ -f "$cached" ] || \
+ try_$2 "$cached" "$@" || \
return 1
- fi
[ -f "$5" ] && \
if bad_checksum "$6" "$5" 2>/dev/null; then
@@ -180,7 +178,6 @@ try_fetch_curl()
return 1
elif bad_checksum "$6" "$cached"; then
x_ rm -f "$cached"
-
return 1
fi
diff --git a/include/init.sh b/include/init.sh
index 468842e0..cdefde21 100644
--- a/include/init.sh
+++ b/include/init.sh
@@ -39,9 +39,8 @@ xbmk_init()
x_ xbmkdir "cache"
for init_cmd in get_version set_env set_threads git_init child_exec; do
- if ! xbmk_$init_cmd "$@"; then
- break
- fi
+ xbmk_$init_cmd "$@" || \
+ break; :
done
}
@@ -147,9 +146,7 @@ xbmk_child_set_env()
xbmk_child_set_tmp()
{
- badtmp=""
- locktmp=""
- xbtmpchk=""
+ eval "`newvar badtmp locktmp xbtmpchk`"
xbtmpchk="`findpath "$TMPDIR" || err "!findpath $TMPDIR"`" || \
err "!findpath '$TMPDIR'" "xbmk_child_set_tmp" "$@"
@@ -281,14 +278,13 @@ xbmk_set_pyver()
pyver="2"
pyv="import sys; print(sys.version_info[:])"
- if ! pybin python3 1>/dev/null; then
+ pybin python3 1>/dev/null || \
python="python"
- fi
[ "$python" = "python3" ] && \
pyver="3"
- if ! pybin "$python" 1>/dev/null; then
+ pybin "$python" 1>/dev/null || \
pyver=""
- fi
+
[ -z "$pyver" ] || \
"`x_ pybin "$python"`" -c "$pyv" 1>/dev/null \
2>/dev/null || \
@@ -321,44 +317,37 @@ pybin()
py="import sys; quit(1) if sys.prefix == sys.base_prefix else quit(0)"
venv=1
- if ! command -v "$1" 1>/dev/null 2>/dev/null; then
+ command -v "$1" 1>/dev/null 2>/dev/null || \
venv=0
- fi
- [ $venv -gt 0 ] && \
- if ! "$1" -c "$py" 1>/dev/null 2>/dev/null; then
- venv=0
- fi
- # ideally, don't rely on PATH or hardcoded paths if python venv.
- # use the *real*, direct executable linked to by the venv symlink:
+ [ $venv -lt 1 ] || \
+ "$1" -c "$py" 1>/dev/null 2>/dev/null || \
+ venv=0
+ # try the direct path from PATH first. the binary specified by venv
+ # can be called directly, which then removes use of the venv
if [ $venv -gt 0 ] && [ -L "`command -v "$1" 2>/dev/null`" ]; then
pypath="$(findpath \
"$(command -v "$1" 2>/dev/null)" 2>/dev/null || :)"
-
if [ -e "$pypath" ] && [ ! -d "$pypath" ] && \
[ -x "$pypath" ]; then
-
printf "%s\n" "$pypath"
return 0
fi
fi
# if python venv: fall back to common PATH directories for checking:
-
[ $venv -gt 0 ] && for pypath in "/usr/local/bin" "/usr/bin"; do
if [ -e "$pypath/$1" ] && [ ! -d "$pypath/$1" ] && \
[ -x "$pypath/$1" ]; then
-
printf "%s/%s\n" "$pypath" "$1"
return 0
fi
done && return 1
# Defer to normal command -v if not a venv
- if ! command -v "$1" 2>/dev/null; then
- return 1
- fi
+ command -v "$1" 2>/dev/null || \
+ return 1; :
}
xbmk_set_mirror()
@@ -382,11 +371,9 @@ xbmk_git_init()
# the git identity check is only needed for: ./mk -b coreboot [args]
[ "${2-}" = "-b" ] && [ "${3-}" = "coreboot" ] && \
for gitarg in "user.name" "user.email"; do
- gitcmd="git config --includes $gitarg"
- if ! $gitcmd 1>/dev/null 2>/dev/null; then
+ git config --includes $gitarg 1>/dev/null 2>/dev/null || \
err "Run this first: $gitcmd \"your ${gitcmd##*.}\"" \
- "xbmk_git_init" "$@"
- fi
+ "xbmk_git_init" "$@"; :
done
[ -L ".git" ] && \
diff --git a/include/inject.sh b/include/inject.sh
index eb764a98..0760c1d8 100644
--- a/include/inject.sh
+++ b/include/inject.sh
@@ -48,9 +48,8 @@ inject()
check_release
if check_target; then
- if ! patch_release; then
- return 0
- fi
+ patch_release || \
+ return 0; :
fi
[ "$xchanged" = "y" ] && \
remktar
@@ -135,17 +134,16 @@ patch_release()
fi
done
- if ! readkconfig; then
+ readkconfig || \
return 1
- elif [ -n "$new_mac" ] && [ -n "$CONFIG_GBE_BIN_PATH" ]; then
- modify_mac
- fi
+
+ [ -n "$new_mac" ] && [ -n "$CONFIG_GBE_BIN_PATH" ] && \
+ modify_mac; :
}
readkconfig()
{
x_ rm -f "$xbtmp/cbcfg"
-
fx_ scankconfig x_ find "$boarddir/config" -type f
if e "$xbtmp/cbcfg" f missing; then
@@ -155,9 +153,8 @@ readkconfig()
. "$xbtmp/cbcfg" || \
err "Can't read '$xbtmp/cbcfg'" "readkconfig" "$@"
- if ! setvfile "$@"; then
- return 1
- fi
+ setvfile "$@" || \
+ return 1; :
}
scankconfig()
@@ -195,10 +192,10 @@ newmac()
remktar()
{
(
- x_ cd "${tmpromdir%"/bin/$board"}"
+ x_ cd "${tmpromdir%"/bin/$board"}"
- printf "Re-building tar archive (please wait)\n"
- mkrom_tarball "bin/$board" 1>/dev/null
+ printf "Re-building tar archive (please wait)\n"
+ mkrom_tarball "bin/$board" 1>/dev/null
) || err "Cannot re-generate '$archive'" "remktar" "$@"
diff --git a/include/tree.sh b/include/tree.sh
index 9ac0ca6d..f373af97 100644
--- a/include/tree.sh
+++ b/include/tree.sh
@@ -111,20 +111,18 @@ trees()
build_project()
{
- if ! configure_project "$configdir"; then
+ configure_project "$configdir" || \
return 0
- elif [ -f "$listfile" ]; then
- if ! $if_not_dry_build elfcheck; then
+
+ [ ! -f "$listfile" ] || \
+ $if_not_dry_build elfcheck || \
return 0
- fi
- fi
[ "$mode" = "distclean" ] && \
mode="clean"
- if ! run_make_command; then
+ run_make_command || \
return 0
- fi
[ -z "$mode" ] && \
$if_not_dry_build \
@@ -168,9 +166,9 @@ handle_defconfig()
[ ! -f "CHANGELOG" ] && \
fetch_project "$project"
- if ! configure_project "$target_dir"; then
+
+ configure_project "$target_dir" || \
return 0
- fi
[ -z "$tree" ] && \
err "$configdir: 'tree' not set" "handle_defconfig" "$@"
@@ -304,10 +302,9 @@ build_dependencies()
delete_old_project_files()
{
# delete an entire source tree along with its builds:
- if ! project_up_to_date hash "$tree" badhash "$datadir" \
- "$configdir/$tree" "$mdir"; then
+ project_up_to_date hash "$tree" badhash "$datadir" \
+ "$configdir/$tree" "$mdir" || \
x_ rm -Rf "src/$project/$tree" "elf/$project/$tree"
- fi
x_ cp "$xbtmp/new.hash" "$XBMK_CACHE/hash/$project$tree"
@@ -320,10 +317,8 @@ delete_old_project_files()
# this is useful when only the target config changes, for
# example x200_8mb coreboot configs change, but not coreboot:
- if ! project_up_to_date tghash "$target" badtghash "$configdir/$target"
- then
+ project_up_to_date tghash "$target" badtghash "$configdir/$target" || \
x_ rm -Rf "elf/$project/$tree/$target"
- fi
x_ cp "$xbtmp/new.hash" "$XBMK_CACHE/tghash/$project$target"
}
@@ -414,9 +409,8 @@ check_cross_compiler()
check_gnu_path()
{
- if ! command -v "$1" 1>/dev/null; then
+ command -v "$1" 1>/dev/null || \
err "Host '$1' unavailable" "check_gnu_path" "$@"
- fi
eval "`newvar gccdir gccfull gccver gnatdir gnatfull gnatver`"
@@ -431,9 +425,8 @@ check_gnu_path()
host_gcc_gnat_match()
{
- if ! gnu_setver "$1" "$1"; then
+ gnu_setver "$1" "$1" || \
err "Command '$1' unavailable." "check_gnu_path" "$@"
- fi
gnu_setver "$2" "$2" || :
eval "[ -z \"\$$1ver\" ] && err \"Cannot detect host '$1' version\""
@@ -458,11 +451,10 @@ match_gcc_gnat_versions()
fi
done
- if ! gnu_setver "$2" "$_gnudir/$2-$_gnuver"; then
+ gnu_setver "$2" "$_gnudir/$2-$_gnuver" || \
return 1
- elif [ "$gnatfull" != "$gccfull" ]; then
+ [ "$gnatfull" != "$gccfull" ] && \
return 1
- fi
( link_gcc_gnat_versions "$@" "$_gnudir" "$_gnuver" ) || \
err "Can't link '$2-$_gnuver' '$_gnudir'" "check_gnu_path" "$@"; :
@@ -555,14 +547,13 @@ run_make_command()
[ -z "$mode" ] && \
x_ $premake
- if $if_not_dry_build check_cmake "$srcdir"; then
+ $if_not_dry_build check_cmake "$srcdir" && \
[ -z "$mode" ] && \
$if_not_dry_build \
- check_autoconf "$srcdir"; :
- fi
- if ! $if_not_dry_build check_makefile "$srcdir"; then
+ check_autoconf "$srcdir"
+
+ $if_not_dry_build check_makefile "$srcdir" || \
return 1
- fi
$if_not_dry_build \
x_ make -C "$srcdir" $mode -j$XBMK_THREADS $makeargs
@@ -570,30 +561,29 @@ run_make_command()
[ -z "$mode" ] && \
x_ $mkhelper
- if ! check_makefile "$srcdir"; then
+ check_makefile "$srcdir" || \
return 0
- fi
- if [ "$mode" = "clean" ]; then
- $if_dry_build \
- return 0
- if ! make -C "$srcdir" $cleanargs distclean; then
- x_ make -C "$srcdir" $cleanargs clean
- fi
- fi
+ [ "$mode" = "clean" ] || \
+ return 0
+ $if_dry_build \
+ return 0
+
+ make -C "$srcdir" $cleanargs distclean || \
+ x_ make -C "$srcdir" $cleanargs clean; :
}
check_cmake()
{
$if_dry_build \
return 0
- if [ ! -n "$cmakedir" ]; then
+ [ ! -n "$cmakedir" ] && \
return 0
- elif ! check_makefile "$1"; then
- if ! cmake -B "$1" "$1/$cmakedir"; then
+
+ check_makefile "$1" || \
+ cmake -B "$1" "$1/$cmakedir" || \
x_ check_makefile "$1"
- fi
- fi
+
x_ check_makefile "$1"; :
}
diff --git a/include/vendor.sh b/include/vendor.sh
index 07411ed8..e4e6e3a1 100644
--- a/include/vendor.sh
+++ b/include/vendor.sh
@@ -168,10 +168,9 @@ fetch()
# the given hashsum. So, search for a matching file via bruteforce:
( fx_ "mkdst $binsum" x_ find "${_pre_dest%/*}" -type f ) || :
- if ! bad_checksum "$binsum" "$_dest"; then
- [ -f "$_dest" ] && \
+ bad_checksum "$binsum" "$_dest" || \
+ [ ! -f "$_dest" ] || \
return 0; :
- fi
[ -z "$binsum" ] && \
printf "'%s': checksum undefined\n" "$_dest" 1>&2
@@ -266,11 +265,6 @@ find_me()
mfs="" # no MFS whitelist needed, due to -r:
fi
if [ "$MEclean" = "n" ] || [ "$MEshrink" != "y" ]; then
- # MEclean can still be y, this just means don't shrink,
- # so deleted modules would become padded space. this
- # could also be used alongside --whitelist, if
- # MEclean is otherwise enabled.
-
_r="" # don't re-locate ME modules
_trunc="" # don't shrink the me.bin file size
fi
@@ -523,9 +517,8 @@ prep()
( mksha512 "$_xrom" "vendorhashes" ) || err; :
fi
- if ! add_vfiles "$_xrom"; then
+ add_vfiles "$_xrom" || \
return 1 # no need to insert files
- fi
if [ "$nuke" = "nuke" ]; then
pad_one_byte "$_xrom"