summaryrefslogtreecommitdiff
path: root/include/git.sh
diff options
context:
space:
mode:
Diffstat (limited to 'include/git.sh')
-rw-r--r--[-rwxr-xr-x]include/git.sh40
1 files changed, 29 insertions, 11 deletions
diff --git a/include/git.sh b/include/git.sh
index b0acd7dc..f8441f33 100755..100644
--- a/include/git.sh
+++ b/include/git.sh
@@ -2,8 +2,8 @@
# Copyright (c) 2020-2021,2023-2024 Leah Rowe <leah@libreboot.org>
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
-eval `setvars "" loc url bkup_url subfile mdir subhash subrepo subrepo_bkup \
- depend subfile_bkup`
+eval `setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \
+ depend subfile_bkup repofail`
fetch_targets()
{
@@ -12,8 +12,8 @@ fetch_targets()
e "src/$project/$tree" d && return 0
printf "Creating %s tree %s\n" "$project" "$tree"
- git_prep "$loc" "$loc" "$PWD/$cfgsdir/$tree/patches" \
- "${loc%/*}/$tree" u; nuke "$project/$tree" "$project/$tree"
+ git_prep "$loc" "$loc" "$PWD/$configdir/$tree/patches" \
+ "src/$project/$tree" u; nuke "$project/$tree" "$project/$tree"
}
fetch_project()
@@ -37,7 +37,8 @@ fetch_project()
clone_project()
{
- loc="src/$project/$project" && singletree "$project" && loc="${loc%/*}"
+ loc="$XBMK_CACHE/repo/$project" && singletree "$project" && \
+ loc="src/$project"
printf "Downloading project '%s' to '%s'\n" "$project" "$loc"
e "$loc" d && return 0
@@ -61,17 +62,15 @@ git_prep()
[ "$project" = "coreboot" ] && [ -n "$xtree" ] && [ $# -gt 2 ] && \
[ "$xtree" != "$tree" ] && link_crossgcc "$_loc"
- [ "$XBMK_RELEASE" = "y" ] && [ "$_loc" != "src/$project/$project" ] \
- && rmgit "$tmpgit"
+ [ "$XBMK_RELEASE" = "y" ] && \
+ [ "$_loc" != "$XBMK_CACHE/repo/$project" ] && \
+ rmgit "$tmpgit"
move_repo "$_loc"
}
prep_submodules()
{
- mdir="$PWD/config/submodule/$project"
- [ -n "$tree" ] && mdir="$mdir/$tree"
-
[ -f "$mdir/module.list" ] && while read -r msrcdir; do
fetch_submodule "$msrcdir"
done < "$mdir/module.list"; return 0
@@ -103,9 +102,28 @@ fetch_submodule()
tmpclone()
{
- git clone $1 "$3" || git clone $2 "$3" || $err "!clone $1 $2 $3 $4 $5"
+ [ "$repofail" = "y" ] && \
+ printf "Cached clone failed; trying online.\n" 1>&2
+ repofail="n"
+
+ [ $# -lt 6 ] || rm -Rf "$3" || $err "git retry: !rm $3 ($1)"
+ repodir="$XBMK_CACHE/repo/${1##*/}" && [ $# -gt 5 ] && repodir="$3"
+ mkdir -p "$XBMK_CACHE/repo" || $err "!rmdir $XBMK_CACHE/repo"
+ if [ -d "$repodir" ] && [ $# -lt 6 ]; then
+ git -C "$repodir" pull || sleep 3 || git -C "$repodir" pull \
+ || sleep 3 || git -C "$repodir" pull || :
+ else
+ git clone $1 "$repodir" || git clone $2 "$repodir" || \
+ $err "!clone $1 $2 $repodir $4 $5"
+ fi
+ (
+ [ $# -gt 5 ] || git clone "$repodir" "$3" || $err "!clone $repodir $3"
git -C "$3" reset --hard "$4" || $err "!reset $1 $2 $3 $4 $5"
git_am_patches "$3" "$5"
+ ) || repofail="y"
+
+ [ "$repofail" = "y" ] && [ $# -lt 6 ] && tmpclone $@ retry
+ [ "$repofail" = "y" ] && $err "!clone $1 $2 $3 $4 $5"; :
}
git_am_patches()