diff options
author | Leah Rowe <leah@libreboot.org> | 2024-06-22 02:35:25 +0100 |
---|---|---|
committer | Leah Rowe <leah@libreboot.org> | 2024-06-22 13:44:27 +0100 |
commit | fc7ae3e5903c176584cfefd6d3cf4c1549c4eaaa (patch) | |
tree | d13789beaaa3c1215607dda17fada1b322b5db49 /include/git.sh | |
parent | ad1602569ebf1404c47fb8ea4b39d0f8e844b840 (diff) |
lib.sh: more unified config handling
replace it with logic that simply uses "." to load
files directly. for this, "vcfg" is added as a variable
in coreboot target.cfg files, referring to a directory
in config/vendor/ containing a file named pkg.cfg, and
this file then contains the same variables as the
erstwhile config/vendor/sources
config/git files are now directories, also containing
pkg.cfg files each with the same variables as before,
such as repository link and commit hash
this change results in a noticeable reduction in code
complexity within the build system.
unified reading of config files: new function setcfg()
added to lib.sh
setcfg checks if a config exists. if a 2nd argument is
passed, it is used as a return value for eval, otherwise
a string calling err is passed. setcfg output is passed
through eval, to set strings based on config; eval must
be used, so that the variables are set within the same
scope, otherwise they'd be set within setcfg which could
lead to some whacky results.
there's still a bit more more to do, but this single change
results in a substantial reduction in code complexity.
Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include/git.sh')
-rwxr-xr-x | include/git.sh | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/include/git.sh b/include/git.sh index e2fd2129..a10fb014 100755 --- a/include/git.sh +++ b/include/git.sh @@ -31,10 +31,8 @@ fetch_config() load_target_config() { - [ -f "$cfgsdir/$1/target.cfg" ] || $err "$1: target.cfg missing" [ -f "$cfgsdir/$1/seen" ] && $err "$_xm cfg: infinite loop in trees" - - . "$cfgsdir/$1/target.cfg" || $err "load_target_config !$cfgsdir/$1" + eval `setcfg "$cfgsdir/$1/target.cfg"` touch "$cfgsdir/$1/seen" || $err "load_config $cfgsdir/$1: !mk seen" } @@ -50,9 +48,9 @@ prepare_new_tree() fetch_project_repo() { eval "$(setvars "" xtree tree_depend)" + eval `setcfg "config/git/$project/pkg.cfg"` - scan_config "$project" "config/git" - chkvars loc url + chkvars url [ -n "$xtree" ] && [ ! -d "src/coreboot/$xtree" ] && \ x_ ./update trees -f coreboot "$xtree" @@ -63,14 +61,14 @@ fetch_project_repo() clone_project for x in config/git/*; do - [ -f "$x" ] && nuke "${x##*/}" "src/${x##*/}" 2>/dev/null - done + [ -d "$x" ] && nuke "${x##*/}" "src/${x##*/}" 2>/dev/null + done; return 0 } clone_project() { - loc="${loc#src/}" - loc="src/$loc" + loc="src/$project" + singletree "$project" || loc="src/$project/$project" printf "Downloading project '%s' to '%s'\n" "$project" "$loc" e "$loc" d && return 0 |