From d5baaff0ec66a49ad3305a7f3d06ef4280fa00e0 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sun, 23 Jun 2024 12:34:26 +0100 Subject: lib.sh: fix error running ./build dependencies the e() and setvars() functions need to be declared before the dependencies function. also: after calling install_packages, it was doing a return when it should have done an exit. this is all fixed now. i apologise to anyone who previously ran into trouble with this! Signed-off-by: Leah Rowe --- include/lib.sh | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) (limited to 'include/lib.sh') diff --git a/include/lib.sh b/include/lib.sh index c62bf98f..e4e33f0a 100755 --- a/include/lib.sh +++ b/include/lib.sh @@ -48,6 +48,29 @@ eval `setvars "" xbmk_release tmpdir _nogit version board boarddir relname \ read -r projectname < projectname || : read -r projectsite < projectsite || : +setcfg() +{ + if [ $# -gt 1 ]; then + printf "e \"%s\" f missing && return %s;\n" "$1" "$2" + else + printf "e \"%s\" f missing && %s \"Missing config\";\n" "$1" \ + "$err" + fi + printf ". \"%s\" || %s \"Could not read config\";\n" "$1" "$err" +} + +e() +{ + es_t="e" + [ $# -gt 1 ] && es_t="$2" + es2="already exists" + estr="[ -$es_t \"\$1\" ] || return 1" + [ $# -gt 2 ] && estr="[ -$es_t \"\$1\" ] && return 1" && es2="missing" + + eval "$estr" + printf "%s %s\n" "$1" "$es2" 1>&2 +} + install_packages() { [ $# -lt 2 ] && $err "fewer than two arguments" @@ -58,7 +81,7 @@ install_packages() [ -n "$aur_notice" ] && \ printf "You need AUR packages: %s\n" "$aur_notice" 1>&2; return 0 } -[ $# -gt 0 ] && [ "$1" = "dependencies" ] && install_packages $@ && return 0 +[ $# -gt 0 ] && [ "$1" = "dependencies" ] && install_packages $@ && exit 0 id -u 1>/dev/null 2>/dev/null || $err "suid check failed (id -u)" [ "$(id -u)" != "0" ] || $err "this command as root is not permitted" @@ -172,18 +195,6 @@ rmgit() ) || $err "Cannot remove .git/.gitmodules in $1" } -e() -{ - es_t="e" - [ $# -gt 1 ] && es_t="$2" - es2="already exists" - estr="[ -$es_t \"\$1\" ] || return 1" - [ $# -gt 2 ] && estr="[ -$es_t \"\$1\" ] && return 1" && es2="missing" - - eval "$estr" - printf "%s %s\n" "$1" "$es2" 1>&2 -} - # return 0 if project is single-tree, otherwise 1 # e.g. coreboot is multi-tree, so 1 singletree() @@ -223,14 +234,3 @@ cbfs() lzma="-c lzma" && [ $# -gt 3 ] && lzma="-t raw" x_ "$cbfstool" "$1" $ccmd -f "$2" -n "$3" $lzma } - -setcfg() -{ - if [ $# -gt 1 ]; then - printf "e \"%s\" f missing && return %s;\n" "$1" "$2" - else - printf "e \"%s\" f missing && %s \"Missing config\";\n" "$1" \ - "$err" - fi - printf ". \"%s\" || %s \"Could not read config\";\n" "$1" "$err" -} -- cgit v1.2.1