summaryrefslogtreecommitdiff
path: root/include/git.sh
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2024-05-20 00:10:27 +0100
committerLeah Rowe <leah@libreboot.org>2024-05-20 00:10:27 +0100
commit1e54db29897786ff49b8ff228ed0b2fbdd8b70dc (patch)
treec49fb5b64e51703b2b23e7e91fa31e2692ab0425 /include/git.sh
parent00e00a18d0a04a024fe909dbf452f25e5d272776 (diff)
git.sh: allow patching submodules
for single-tree project (e.g. flashprog): config/submodule/PROJECT/MODNAME/patches for multi-tree project (e.g. coreboot): config/submodule/PROJECT/TREE/MODNAME/patches MODNAME is e.g.: 3rdparty/vboot directory in coreboot: would become vboot (the submodule codepath is filtered to up to the final slash) another example: submodire src dir 3rdparty/foo/bar MODNAME would be "bar" Add whatever patches you like to a given submodule. An example patch is included in this commit. Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'include/git.sh')
-rwxr-xr-xinclude/git.sh21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/git.sh b/include/git.sh
index d737fd1c..91ccf179 100755
--- a/include/git.sh
+++ b/include/git.sh
@@ -93,6 +93,9 @@ git_prep()
if [ "$project" != "coreboot" ] || [ $# -gt 2 ]; then
[ ! -f "$tmpgit/.gitmodules" ] || git -C "$tmpgit" submodule \
update --init --checkout || $err "git_prep $_loc: !submod"
+
+ patch_submodules
+
if [ "$project" = "coreboot" ] && [ -n "$xtree" ] && \
[ "$xtree" != "$tree" ]; then
(
@@ -114,6 +117,24 @@ git_prep()
x_ ./update project trees -f coreboot "$xtree"; return 0
}
+patch_submodules()
+{
+ moddir="${PWD}/config/submodule/$project"
+ [ -n "$tree" ] && moddir="$moddir/$tree"
+ [ -d "$moddir" ] || return 0
+
+ git -C "$tmpgit" submodule status | awk '{print $2}' > \
+ "$tmpdir/modules" || $err "$moddir: cannot list submodules"
+
+ while read -r modsrcdir; do
+ modname="${modsrcdir##*/}"
+ modpatchdir="$moddir/$modname/patches"
+ [ -d "$modpatchdir" ] || continue
+
+ git_am_patches "$tmpgit/$modsrcdir" "$modpatchdir"
+ done < "$tmpdir/modules"
+}
+
git_am_patches()
{
for _patch in "$2/"*; do