From a5e724e51ea8e40da72493cec36506527123e842 Mon Sep 17 00:00:00 2001 From: Leah Rowe Date: Sat, 29 Jun 2024 23:13:55 +0100 Subject: trees: unified multi-tree configuration handling the same function that loads configurations for single-tree projects has been merged with the function for multi-tree configs in git.sh, and that functionality has been removed from git.sh; now it is all unified in the trees script. as the saying goes: write one program to do one thing well. the purpose of git.sh is to download source code, but not to handle configuration files; the latter is meant to be handled by the trees script, which then calls into git.sh before running the build logic for that given project. additionally: the "seen" files are no longer handled, at all. the logic there was added ages ago, because at the time, i was considering whether to separate configuration into a new repository, so that users could more easily make their own configuration, so it was a guard against misconfiguration. however, that decision was canceled and we're always very careful not to introduce a loop; if a loop does occur, the worst that can possibly happen is you waste some CPU cycles. Instead, print (on standard output) what config file is being used, so the operator can see when an infinite loop occurs. ALSO: remove _setcfgarg in load_project_config() it was used to skip when a target.cfg file didn't exist, specifically on single-tree projects, but this is now handled using -f instead, on the while loop inside that function, so _setcfgarg is now a redundant variable. Signed-off-by: Leah Rowe --- include/git.sh | 31 +++++-------------------------- 1 file changed, 5 insertions(+), 26 deletions(-) (limited to 'include') diff --git a/include/git.sh b/include/git.sh index f65fe85e..e73f1ad7 100755 --- a/include/git.sh +++ b/include/git.sh @@ -2,42 +2,21 @@ # Copyright (c) 2020-2021,2023-2024 Leah Rowe # Copyright (c) 2022 Caleb La Grange -eval `setvars "" _target rev loc url bkup_url depend tree_depend xtree mdir \ - subhash subrepo subrepo_bkup subfile subfile_bkup` +eval `setvars "" rev loc url bkup_url depend tree_depend xtree mdir subhash \ + subrepo subrepo_bkup subfile subfile_bkup` fetch_targets() { - _target="$target" [ ! -d "src/$project/$project" ] && x_ mkdir -p "src/$project" \ && fetch_project "$project" - fetch_config - e "src/$project/$tree" d || prepare_new_tree; return 0 -} - -fetch_config() -{ - rm -f "$cfgsdir/"*/seen || $err "fetch_config $cfgsdir: !rm seen" - eval `setvars "" xtree tree_depend` - while true; do - eval `setvars "" rev tree` - load_target_config "$_target" - [ "$_target" = "$tree" ] && break - _target="$tree" - done [ -n "$tree_depend" ] && [ "$tree_depend" != "$tree" ] && \ - x_ ./update trees -f "$project" "$tree_depend"; return 0 -} - -load_target_config() -{ - [ -f "$cfgsdir/$1/seen" ] && $err "$project/$_target: tree loop" - eval `setcfg "$cfgsdir/$1/target.cfg"` - touch "$cfgsdir/$1/seen" || $err "load_config $cfgsdir/$1: !mk seen" + x_ ./update trees -f "$project" "$tree_depend" + e "src/$project/$tree" d || prepare_new_tree; return 0 } prepare_new_tree() { - printf "Creating %s tree %s (%s)\n" "$project" "$tree" "$_target" + printf "Creating %s tree %s\n" "$project" "$tree" git_prep "src/$project/$project" "src/$project/$project" \ "$PWD/$cfgsdir/$tree/patches" "src/$project/$tree" "update" -- cgit v1.2.1