diff options
Diffstat (limited to 'include/lib.sh')
-rw-r--r-- | include/lib.sh | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/include/lib.sh b/include/lib.sh index 2ff410eb..3d205fa9 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -91,36 +91,21 @@ setvars() _setvars="" if [ $# -lt 2 ]; then - printf "err \"setvars: too few args\\n\"" + return 0 else val="$1" + shift 1 + while [ $# -gt 0 ]; do printf "%s=\"%s\"\n" "$1" "$val" + shift 1 done fi } -setcfg() -{ - if [ $# -gt 1 ]; then - printf "e \"%s\" f missing && return %s;\n" "$1" "$2" - else - printf "e \"%s\" f not && err \"Missing config '$1'\";\n" "$1" - fi - printf ". \"%s\" || err \"Could not read config '$1'\";\n" "$1" -} - -chkvars() -{ - while [ $# -gt 0 ]; do - eval "[ -n \"\${$1+x}\" ] || err \"$1 unset\"" - eval "[ -n \"\$$1\" ] || err \"$1 unset\"; shift 1; :" - done; : -} - # return 0 if project is single-tree, otherwise 1 # e.g. coreboot is multi-tree, so 1 singletree() @@ -145,6 +130,7 @@ findpath() fi printf "%s\n" "$found" + shift 1 done } @@ -176,6 +162,13 @@ unpad_one_byte() x_ mv "$unpaddedfile" "$1" } +build_sbase() +{ + if [ ! -f "$sha512sum" ]; then + x_ make -C "$xbmkpwd/util/sbase" + fi +} + fx_() { xchk fx_ "$@" @@ -184,7 +177,9 @@ fx_() xfile="`mktemp || err "can't create tmpfile"`" || \ err "can't make tmpfile" "fx_" "$@" - x_ rm -f "$xfile" && x_ touch "$xfile" + x_ rm -f "$xfile" + x_ touch "$xfile" + shift 1 "$@" 2>/dev/null | sort 1>"$xfile" 2>/dev/null || \ @@ -197,7 +192,12 @@ fx_() dx_() { xchk dx_ "$@" - [ ! -f "$2" ] || while read -r fx; do + + if [ ! -f "$2" ]; then + return 0 + fi + + while read -r fx; do $1 "$fx" || return 1; : done < "$2" || err "cannot read '$2'" "dx_" "$@"; : } @@ -227,13 +227,13 @@ err() if [ $# -eq 1 ]; then printf "ERROR %s: %s\n" "$0" "$1" 1>&2 || : elif [ $# -gt 1 ]; then - printf "ERROR %s: %s: in command/function with arguments: " \ - "$0" "$1" 1>&2 + 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 + exit 1 } @@ -242,8 +242,11 @@ xprintf() xprintfargs=0 while [ $# -gt 0 ]; do printf "\"%s\"" "$1" + if [ $# -gt 1 ]; then + printf " " + fi + xprintfargs=1 - [ $# -gt 1 ] && printf " "; : shift 1 done if [ $xprintfargs -gt 0 ]; then |