git.sh: general code cleanup in fetch_submodule()

Signed-off-by: Leah Rowe <leah@libreboot.org>
audit2
Leah Rowe 2024-06-20 00:57:10 +01:00 committed by Leah Rowe
parent 3ba876932d
commit 295471644a
1 changed files with 5 additions and 8 deletions

View File

@ -115,22 +115,19 @@ prep_submodules()
fetch_submodule() fetch_submodule()
{ {
mcfgdir="$mdir/${1##*/}" mcfgdir="$mdir/${1##*/}"
eval "$(setvars "" subhash subrepo subrepo_bkup subfile subfile_bkup)" eval $(setvars "" subhash subrepo subrepo_bkup subfile subfile_bkup st)
[ ! -f "$mcfgdir/module.cfg" ] || . "$mcfgdir/module.cfg" || \ [ ! -f "$mcfgdir/module.cfg" ] || . "$mcfgdir/module.cfg" || \
$err "! . $mcfgdir/module.cfg" $err "! . $mcfgdir/module.cfg"
st="" for xt in repo file; do
for _st in repo file; do eval "[ -n \"\$sub$xt\$sub${xt}_bkup\" ] && st=\"\$st \$xt\""
eval "[ -n \"\$sub$_st\$sub${_st}_bkup\" ] && st=\"\$st \$_st\""
done done
st="${st# }" st="${st# }" && [ "$st" = "repo file" ] && $err "$mdir: repo+file"
[ "$st" = "repo file" ] && $err "$mdir: repo/file both defined"
[ -z "$st" ] && return 0 # subrepo/subfile not defined [ -z "$st" ] && return 0 # subrepo/subfile not defined
chkvars "sub${st}" "sub${st}_bkup" "subhash" chkvars "sub${st}" "sub${st}_bkup" "subhash"
[ "$st" != "repo" ] && download "$subfile" "$subfile_bkup" \ [ "$st" = "file" ] && download "$subfile" "$subfile_bkup" \
"$tmpgit/$1" "$subhash" && return 0 "$tmpgit/$1" "$subhash" && return 0
rm -Rf "$tmpgit/$1" || $err "!rm '$mdir' '$1'" rm -Rf "$tmpgit/$1" || $err "!rm '$mdir' '$1'"
tmpclone "$subrepo" "$subrepo_bkup" "$tmpgit/$1" "$subhash" \ tmpclone "$subrepo" "$subrepo_bkup" "$tmpgit/$1" "$subhash" \