mirror of
https://codeberg.org/libreboot/lbmk.git
synced 2026-09-20 05:30:25 +02:00
mk: generalised dispatch loop
with this new function, i can turn commands on and off by virtue of config. for now, behaviour is unchanged, but this new design means i will be able to disable certain commands in child processes Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
@@ -27,6 +27,11 @@ update_xbmkver()
|
|||||||
err "can't write '$versiondate'" "update_xbmkver" "$@"; :
|
err "can't write '$versiondate'" "update_xbmkver" "$@"; :
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version()
|
||||||
|
{
|
||||||
|
printf "%s\nWebsite: %s\n" "$relname" "$projectsite"
|
||||||
|
}
|
||||||
|
|
||||||
xbmk_sanitize_version()
|
xbmk_sanitize_version()
|
||||||
{
|
{
|
||||||
if [ -z "$version" ]; then
|
if [ -z "$version" ]; then
|
||||||
@@ -222,6 +227,31 @@ x_()
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
xeq()
|
||||||
|
{
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
|
err "no args" xeq
|
||||||
|
fi
|
||||||
|
xbcmd="$1"
|
||||||
|
chk="$2"
|
||||||
|
shift 2
|
||||||
|
|
||||||
|
case "$chk" in
|
||||||
|
-*)
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
for eq in "$@"; do
|
||||||
|
if [ "$chk" = "$eq" ]; then
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
err "bad command" xeq "$xbcmd" "$chk" "$@"
|
||||||
|
}
|
||||||
|
|
||||||
xchk()
|
xchk()
|
||||||
{
|
{
|
||||||
if [ $# -lt 3 ]; then
|
if [ $# -lt 3 ]; then
|
||||||
|
|||||||
@@ -35,26 +35,15 @@ main()
|
|||||||
cmd=""
|
cmd=""
|
||||||
if [ $# -gt 0 ]; then
|
if [ $# -gt 0 ]; then
|
||||||
cmd="$1"
|
cmd="$1"
|
||||||
|
|
||||||
shift 1
|
shift 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case "$cmd" in
|
if ! xeq main "$cmd" \
|
||||||
version)
|
version release download inject prep_mr_import; then
|
||||||
printf "%s\nWebsite: %s\n" "$relname" "$projectsite"
|
|
||||||
;;
|
|
||||||
release|download|inject|prep_mr_import)
|
|
||||||
$cmd "$@"
|
|
||||||
;;
|
|
||||||
-*)
|
|
||||||
return 0
|
return 0
|
||||||
;;
|
fi
|
||||||
*)
|
|
||||||
err "bad command" main "$@"
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# some commands disable them. turn them back on!
|
$cmd "$@"
|
||||||
set -u -e
|
set -u -e
|
||||||
|
|
||||||
return 1
|
return 1
|
||||||
|
|||||||
Reference in New Issue
Block a user