From d18d1c2cae2c1c43c56d5c10adb469266d1eb08b Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 3 May 2025 04:16:10 +0100 Subject: lbmk: unified execution on find commands We have a lot of places in lbmk where the output of find is used, and then some function is executed on the result. This is messy, and bloats several of these functions. Now this is unified, into a new function: fx_ What fx_ does is execute a given function, for each result found, with the arguments for a find command appended. For example: find -name ".git" If you wanted to do: foo "$arg" Where "arg" is a search result from find, and you wanted to execute "foo" on each one, you would do: fx_ foo -name ".git" The find utility does have an -exec feature, but I've found that it only works for executables, not functions. fx_ does not return errors, so "foo" in this example would have to do its own error handling. Signed-off-by: Leah Rowe --- mk | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) (limited to 'mk') diff --git a/mk b/mk index 6a46f93c..8884d61e 100755 --- a/mk +++ b/mk @@ -278,20 +278,9 @@ check_project_hashes() [ ! -f "$XBMK_CACHE/hash/$project$tree" ] || \ read -r old_pjhash < "$XBMK_CACHE/hash/$project$tree" - x_ rm -f "$xbmktmp/project.list" "$xbmktmp/project.hash" \ - "$xbmktmp/project.tmp" - x_ touch "$xbmktmp/project.tmp" "$xbmktmp/project.hash" - - for rmchk in "$datadir" "$configdir/$tree" "$mdir"; do - [ ! -d "$rmchk" ] || find "$rmchk" -type f -not -path \ - "*/.git*/*" >> "$xbmktmp/project.tmp" || $err "!fh $rmchk" - done - sort "$xbmktmp/project.tmp" > "$xbmktmp/project.list" || $err "!pj srt" - - while read -r rmchk; do - [ ! -f "$rmchk" ] || x_ sha512sum "$rmchk" | awk \ - '{print $1}' >> "$xbmktmp/project.hash" || $err "!h $rmchk" - done < "$xbmktmp/project.list" + x_ rm -f "$xbmktmp/project.hash" + fx_ create_project_hash "$datadir" "$configdir/$tree" "$mdir" \ + -type f -not -path "*/.git*/*" pjhash="$(sha512sum "$xbmktmp/project.hash" | awk '{print $1}')" || : [ "$pjhash" != "$old_pjhash" ] && badhash="y" @@ -304,6 +293,12 @@ check_project_hashes() "elf/$project/$tree" "elf/$project/$target"; : } +create_project_hash() +{ + [ ! -f "$1" ] || x_ sha512sum "$1" | awk \ + '{print $1}' >> "$xbmktmp/project.hash" || $err "!h $1"; : +} + check_cross_compiler() { xgccargs="UPDATED_SUBMODULES=1 CPUS=$XBMK_THREADS" -- cgit v1.2.1