Compare commits

...

9 Commits

Author SHA1 Message Date
Leah Rowe a82328904e mk: clean up printf command
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 00:36:10 +01:00
Leah Rowe 823a1fd011 mk: put all includes in one place
the previous design flaw was fixed by recent
refactors, such that i can now . include all
of lbmk at once, and have control logic right
after that.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 00:14:55 +01:00
Leah Rowe 5fb0d1098f mk: simplified command handling
just do includes in mk again. common.sh was stupidly
small, just pointless.

replace the entire command dispatcher with eval, printf
and awk, because i can, and it further reduces sloccount.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-14 00:05:48 +01:00
Leah Rowe dcaa15ab01 common.h: re-order includes
the new order more reliably indicates which order
everything is executed in, by virtue of the functions
provided in each file.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-13 22:25:15 +01:00
Leah Rowe f5f6464c60 79 lines
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-13 20:55:30 +01:00
Leah Rowe 74c374a3a2 use awk instead
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-13 20:38:54 +01:00
Leah Rowe de09b71e0a init.sh: tidy up main loop
the new loop is incredibly novel in nature, and will
break if anyone but me ever touches it. it also
reduces sloccount by two lines.

i did it because i can, and it's perfectly safe.

Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-13 20:12:03 +01:00
Leah Rowe eb23cd3de8 split up include/
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-13 15:33:21 +01:00
Leah Rowe 07ed4e940b more build system cleanup
Signed-off-by: Leah Rowe <leah@libreboot.org>
2026-09-13 15:28:15 +01:00
11 changed files with 52 additions and 106 deletions
-17
View File
@@ -1,17 +0,0 @@
# SPDX-License-Identifier: GPL-3.0-or-later
. "include/lib.sh"
. "include/init.sh"
. "include/vendor.sh"
. "include/mrc.sh"
. "include/inject.sh"
. "include/rom.sh"
. "include/release.sh"
. "include/get.sh"
xbcommands=" \
version \
release \
download \
inject \
"
View File
+18 -21
View File
@@ -35,10 +35,8 @@ xbmk_init()
export PWD="$xbmkpwd"
x_ mkdir -p "$basetmp" "cache"
for init_cmd in get_version set_env set_threads git_init child_exec; do
xbmk_$init_cmd "$@" || \
break; :
done
eval "$(printf "get_ver set_env set_threads git_init xchild\n" | awk \
'{ for (i=1; i<=NF; i++) $i = $i " \"$@\" || return 0;"; print }')"
}
xbmkpkg()
@@ -75,19 +73,19 @@ xbmkpkg()
printf "You need AUR packages: %s\n" "$aur_notice" 1>&2; :
}
xbmk_get_version()
get_ver()
{
[ ! -f ".version" ] || \
read -r version < ".version" || \
err "can't read version file" "xbmk_get_version" "$@"
err "can't read version file" "get_ver" "$@"
[ ! -f ".versiondate" ] || \
read -r versiondate < ".versiondate" || \
err "can't read versiondate" xbmk_get_version "$@"
err "can't read versiondate" get_ver "$@"
[ -f ".version" ] && [ -z "$version" ] && \
err "version not set" "xbmk_get_version" "$@"
err "version not set" "get_ver" "$@"
[ -f ".versiondate" ] && [ -z "$versiondate" ] && \
err "versiondate not set" "xbmk_get_version" "$@"
err "versiondate not set" "get_ver" "$@"
[ ! -e ".git" ] && [ ! -f ".version" ] && \
version="unknown"
@@ -103,7 +101,7 @@ xbmk_get_version()
# a parent instance will cause this function to return 0.
# a child instance will return 1, skipping further initialisation
# after this function is called.
xbmk_set_env()
set_env()
{
is_child="n"
xbmkpath="$PATH"
@@ -130,9 +128,9 @@ xbmk_child_set_env()
xbmk_child_set_tmp
[ -z "${XBMK_CACHE+x}" ] && \
err "XBMK_CACHE unset on child" "xbmk_set_env" "$@"
err "XBMK_CACHE unset on child" "set_env" "$@"
[ -z "${XBMK_THREADS+x}" ] && \
xbmk_set_threads
set_threads
[ -z "${XBMK_CACHE_MIRROR+x}" ] && \
xbmk_set_mirror; :
}
@@ -162,7 +160,7 @@ xbmk_parent_set_env()
xbmk_parent_check_tmp
printf "%s\n" "$xbtmp" > "$xbmklock" || \
err "cannot create '$xbmklock'" xbmk_set_env "$@"; :
err "cannot create '$xbmklock'" set_env "$@"; :
# not really critical for security, but it's a barrier
# against the user to make them think twice before deleting it
@@ -190,11 +188,10 @@ xbmk_parent_check_tmp()
x_ touch "$xbmklist"
for xtmpdir in "$basetmp"/xbmk_*; do
if [ -e "$xtmpdir" ]; then
[ ! -e "$xtmpdir" ] || \
printf "%s\n" "$xtmpdir" >> "$xbmklist" || \
err "can't write '$xtmpdir' to '$xbmklist'" \
"xbmk_parent_check_tmp" "$@"; :
fi
done
# set up a unified temporary directory, for common deletion later:
@@ -233,7 +230,7 @@ xbmk_parent_set_export()
export XBMK_RELEASE="n"; :
}
xbmk_set_threads()
set_threads()
{
[ -z "${XBMK_THREADS+x}" ] && \
export XBMK_THREADS=1
@@ -352,18 +349,18 @@ xbmk_set_mirror()
export XBMK_CACHE_MIRROR="n"; :
}
xbmk_git_init()
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
git config --includes $gitarg 1>/dev/null 2>/dev/null || \
err "Run this first: $gitcmd \"your ${gitcmd##*.}\"" \
"xbmk_git_init" "$@"; :
"git_init" "$@"; :
done
[ -L ".git" ] && \
err "'$xbmkpwd/.git' is a symlink" "xbmk_git_init" "$@"
err "'$xbmkpwd/.git' is a symlink" "git_init" "$@"
[ -e ".git" ] && \
return 0
@@ -380,10 +377,10 @@ xbmk_git_init()
tag -a "$version" -m "$projectname $version" \
1>/dev/null 2>/dev/null; :
) || err "Can't initialise workdir" xbmk_git_init "$@"; :
) || err "Can't initialise workdir" git_init "$@"; :
}
xbmk_child_exec()
xchild()
{
xbmk_rval=0
+17 -33
View File
@@ -57,9 +57,8 @@ download()
export PATH="$PATH:/sbin"
board="$1"
if check_target; then
readkconfig download
fi
check_target || return 0
readkconfig download
}
getfiles()
@@ -251,22 +250,19 @@ find_me()
_7ztest="${_7ztest}a"
_keep="" # -k: keep fptr modules even if they can be removed
_pass="" # -p: skip fptr check
_r="-r" # re-locate modules
_trunc="-t" # -t: truncate the ME size
eval "`newvar _keep _pass`" # -k (keep fptr modules), -p (skip checks)
[ "$ME11bootguard" = "y" ] && \
mfs="--whitelist MFS"
if [ "$MEclean" = "n" ]; then
MEshrink="n"
_keep="-k" # keep ME modules, don't delete anything
mfs="" # no MFS whitelist needed, due to -r:
fi
if [ "$MEclean" = "n" ] || [ "$MEshrink" != "y" ]; then
_r="" # don't re-locate ME modules
_trunc="" # don't shrink the me.bin file size
eval "`newvar _r _trunc`"
fi
[ "$MEcheck" = "n" ] && \
_pass="-p" # skip fptr check
@@ -304,19 +300,12 @@ apply_deguard_hack()
extract_archive()
{
if innoextract "$1" -d "$2"; then
:
elif python "$pfs_extract" "$1" -e; then
:
elif 7z x "$1" -o"$2"; then
:
elif "$bsdtar" -C "$2" -xf "$1"; then
:
elif "$bsdunzip" "$1" -d "$2"; then
:
else
innoextract "$1" -d "$2" || \
python "$pfs_extract" "$1" -e || \
7z x "$1" -o"$2" || \
"$bsdtar" -C "$2" -xf "$1" || \
"$bsdunzip" "$1" -d "$2" || \
return 1
fi
[ -d "${_dl}_extracted" ] && \
x_ cp -R "${_dl}_extracted" "$2"; :
@@ -338,24 +327,17 @@ extract_kbc1126ec_dump()
{
x_ cd "$appdir/"
if mv Rompaq/68*.BIN ec.bin; then
:
elif unar -D ROM.CAB Rom.bin; then
:
elif unar -D Rom.CAB Rom.bin; then
:
elif unar -D 68*.CAB Rom.bin; then
:
else
mv Rompaq/68*.BIN ec.bin || \
unar -D ROM.CAB Rom.bin || \
unar -D Rom.CAB Rom.bin || \
unar -D 68*.CAB Rom.bin || \
err "!kbc1126 unar" "extract_kbc1126ec" "$@"
fi
[ ! -f "ec.bin" ] && \
x_ mv Rom.bin ec.bin
if x_ e ec.bin f; then
x_ "$kbc1126_ec_dump" ec.bin
fi
x_ e ec.bin f
x_ "$kbc1126_ec_dump" ec.bin
}
extract_e6400vga()
@@ -376,6 +358,8 @@ extract_e6400vga()
) || err "can't extract e6400 vga rom" "extract_e6400vga" "$@"
x_ cp "$appdir/$E6400_VGA_romname" "$_pre_dest"
set -u -e
}
extract_sch5545ec()
-24
View File
@@ -191,30 +191,6 @@ x_()
"$@" || err "Unhandled error" "x_" "$@"
}
xeq()
{
[ $# -lt 2 ] && \
err "no args" xeq
xbcmd="$1"
chk="$2"
shift 2
case "$chk" in
-*)
return 1
;;
*)
for eq in "$@"; do
[ "$chk" = "$eq" ] && \
return 0; :
done
;;
esac
err "bad command" xeq "$xbcmd" "$chk" "$@"
}
xchk()
{
if [ $# -lt 3 ]; then
+17 -11
View File
@@ -7,9 +7,9 @@
set -u -e
eval "`printf "%s\n" "LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE \
eval "`printf "LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE \
LC_MONETARY LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE \
LC_MEASUREMENT LC_IDENTIFICATION LC_ALL" | \
LC_MEASUREMENT LC_IDENTIFICATION LC_ALL\n" | \
awk '{ for (i=1; i<=NF; i++) $i = "export " $i "=C.UTF-8;"; print }'`"
(
@@ -23,21 +23,27 @@ commandv="`readlink -f "$xbarg0" 2>/dev/null`"
cd "${commandv%/*}" || exit 1
. "include/common.sh"
. "include/lib.sh"
. "include/env/init.sh"
. "include/env/get.sh"
if xeq main "${1-}" \
$xbcommands; then
. "include/fw/vendor.sh"
. "include/fw/mrc.sh"
. "include/fw/inject.sh"
. "include/fw/rom.sh"
"$@" || exit 1
exit 0
fi
. "include/mk/tree.sh"
. "include/mk/release.sh"
. "include/tree.sh"
_f="${1-}"
shift 1 2>/dev/null || :
trees "$@" || exit 0
eval "$(printf "version release download inject\n" | awk '{ for (i=1; i<=NF; \
i++) $i = "[ \""$i"\" = \"$_f\" ] && x_ "$i" \"$@\" && exit 0;"; print }')"
trees "$_f" "$@" || exit 0
x_ touch "$mkhelpercfg"
. "$mkhelpercfg"
$cmd
) || exit 1; :