diff options
Diffstat (limited to 'include/git.sh')
-rwxr-xr-x | include/git.sh | 38 |
1 files changed, 27 insertions, 11 deletions
diff --git a/include/git.sh b/include/git.sh index bc818b19..934976eb 100755 --- a/include/git.sh +++ b/include/git.sh @@ -7,7 +7,8 @@ eval "$(setvars "" _target rev _xm loc url bkup_url depend tree_depend xtree)" fetch_project_trees() { _target="${target}" - [ -d "src/${project}/${project}" ] || fetch_from_upstream + [ ! -d "src/${project}/${project}" ] && x_ mkdir -p "src/${project}" \ + && fetch_project_repo "${project}" fetch_config if [ -d "src/${project}/${tree}" ]; then printf "download/%s %s (%s): exists\n" \ @@ -17,14 +18,6 @@ fetch_project_trees() prepare_new_tree } -fetch_from_upstream() -{ - [ -d "src/${project}/${project}" ] && return 0 - - x_ mkdir -p "src/${project}" - fetch_project_repo "${project}" -} - fetch_config() { rm -f "${cfgsdir}/"*/seen || $err "fetch_config ${cfgsdir}: !rm seen" @@ -100,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 ( @@ -111,12 +107,32 @@ git_prep() fi fi - [ "$xbmk_release" = "y" ] && rmgit "$tmpgit" + [ "$xbmk_release" = "y" ] && [ "$_loc" != "src/$project/$project" ] \ + && rmgit "$tmpgit" + [ "$_loc" = "${_loc%/*}" ] || x_ mkdir -p "${_loc%/*}" mv "$tmpgit" "$_loc" || $err "git_prep: !mv $tmpgit $_loc" [ -n "$xtree" ] && [ ! -d "src/coreboot/$xtree" ] && \ - x_ ./update project trees -f coreboot "$xtree"; return 0 + x_ ./update 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() |