From 208dfc89bd583f4d8b757ca34e6f6a85538d5e48 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 15 May 2025 01:03:14 +0100 Subject: get.sh: simplify nuke() more specifically, re-write it so that it can be called with fx_ this means that the single-tree check for nuke.list can be made much simpler Signed-off-by: Leah Rowe --- include/get.sh | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/include/get.sh b/include/get.sh index 7d728796..156d2b87 100644 --- a/include/get.sh +++ b/include/get.sh @@ -15,7 +15,7 @@ fetch_targets() printf "Creating %s tree %s\n" "$project" "$tree" git_prep "$url" "$bkup_url" "$xbmkpwd/$configdir/$tree/patches" \ "src/$project/$tree" with_submodules - nuke "$project/$tree" "$project/$tree" + ( fx_ nuke find "$xbmkpwd/config" -type f -name "nuke.list" ) || exit 1 } fetch_project() @@ -31,10 +31,7 @@ fetch_project() x_ ./mk -f $d done clone_project - - for x in config/git/*; do - [ -d "$x" ] && nuke "${x##*/}" "src/${x##*/}" 2>/dev/null; : - done; : + ( fx_ nuke find "$xbmkpwd/config" -type f -name "nuke.list" ) || exit 1 } clone_project() @@ -166,8 +163,7 @@ tmpclone() nuke() { - e "config/${1%/}/nuke.list" f missing || while read -r nukefile; do - rmf="src/${2%/}/$nukefile" && [ -L "$rmf" ] && continue - e "$rmf" e missing || x_ rm -Rf "$rmf" - done < "config/${1%/}/nuke.list"; : + rdir="${1#"$xbmkpwd/config/"}" && [ -d "$xbmkpwd/src/${rdir%/*}" ] && \ + x_ cd "$xbmkpwd/src/${rdir%/*}" && \ + dx_ "[ -L \"\$fx\" ] || x_ rm -Rf" "$1"; : } -- cgit v1.2.1 From c8813c9a144b14a78f7328ce7b886270e1b676f3 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 15 May 2025 02:20:55 +0100 Subject: properly exit 1 when calling fx_ in a few places, we use the presence of a file found by fx_ to cause an exit, but the command that runs looks something like: exit 1 "string" this yields an error, and a non-zero exit, because of too many arguments to "exit", but we wanted a non-zero exit anyway. nevertheless, this is incorrect. to fix it, eval is used instead. if the never-going-to-exist condition one day exists where exit 1 actually returns, not, you know, exits, we will use err instead, with the string as argument. this should be fine. it's a bit hacky, but so is fx_, and it works. fx_ is used in several places to keep the sloccount down, providing a common way to perform while loops on the output of a command; that is its only purpose.. Signed-off-by: Leah Rowe --- include/lib.sh | 4 ++-- include/tree.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/lib.sh b/include/lib.sh index cf4305a1..75de7512 100644 --- a/include/lib.sh +++ b/include/lib.sh @@ -75,8 +75,8 @@ chkvars() # e.g. coreboot is multi-tree, so 1 singletree() { - ( fx_ "exit 1" find "config/$1/"*/ -type f -name "target.cfg" ) || \ - return 1 + ( fx_ "eval exit 1 && err" find "config/$1/"*/ -type f \ + -name "target.cfg" ) || return 1; : } findpath() diff --git a/include/tree.sh b/include/tree.sh index f44b39cc..25d4732c 100644 --- a/include/tree.sh +++ b/include/tree.sh @@ -270,7 +270,7 @@ check_defconfig() elfcheck() { # TODO: *STILL* very hacky check. do it properly (based on build.list) - ( fx_ "exit 1" find "$dest_dir" -type f ) || return 1; : + ( fx_ "eval exit 1 && err" find "$dest_dir" -type f ) || return 1; : } handle_makefile() -- cgit v1.2.1 From a191d22bd6dad8b5d9cb37e952904ff1a0030259 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Thu, 15 May 2025 02:38:54 +0100 Subject: get.sh: add missing eval to dx_ in nuke() Signed-off-by: Leah Rowe --- include/get.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/get.sh b/include/get.sh index 156d2b87..74adb6be 100644 --- a/include/get.sh +++ b/include/get.sh @@ -165,5 +165,5 @@ nuke() { rdir="${1#"$xbmkpwd/config/"}" && [ -d "$xbmkpwd/src/${rdir%/*}" ] && \ x_ cd "$xbmkpwd/src/${rdir%/*}" && \ - dx_ "[ -L \"\$fx\" ] || x_ rm -Rf" "$1"; : + dx_ "eval [ -L \"\$fx\" ] || x_ rm -Rf" "$1"; : } -- cgit v1.2.1