diff --git a/include/common.sh b/include/common.sh deleted file mode 100644 index 9861fc16..00000000 --- a/include/common.sh +++ /dev/null @@ -1,21 +0,0 @@ -# SPDX-License-Identifier: GPL-3.0-or-later - -. "include/lib.sh" -. "include/env/init.sh" -. "include/env/get.sh" - -. "include/fw/vendor.sh" -. "include/fw/mrc.sh" -. "include/fw/inject.sh" -. "include/fw/rom.sh" - -. "include/mk/release.sh" - -# tree.sh is included from the main mk script - -xbcommands=" \ -version \ -release \ -download \ -inject \ -" diff --git a/include/lib.sh b/include/lib.sh index 84e23586..fd1b0444 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -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 diff --git a/mk b/mk index 099e7d84..d8265d17 100755 --- a/mk +++ b/mk @@ -23,18 +23,26 @@ 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/release.sh" + +_f="${1-}" +shift 1 2>/dev/null || : + +eval "$(printf "version release download inject\n" | awk '{ for (i=1; i<=NF; \ + i++) $i = "[ \""$i"\" = \"$_f\" ] && x_ "$i" \"$@\" && exit 0;"; print }')" . "include/mk/tree.sh" -trees "$@" || exit 0 +trees "$_f" "$@" || exit 0 x_ touch "$mkhelpercfg"