put cachedir in environmental variable

XBMK_CACHE is now used, instead of hardcoding cache/

this is exported initialised to cache/, if unset.
this means you can set your own directory, and it means
./update release will use the same directory.

this means bandwidth wastage is further avoided.

Signed-off-by: Leah Rowe <leah@libreboot.org>
This commit is contained in:
Leah Rowe
2024-07-19 00:31:57 +01:00
parent 0e0b12a630
commit 2b50b3ea9a
5 changed files with 30 additions and 18 deletions
+6 -5
View File
@@ -37,7 +37,7 @@ fetch_project()
clone_project()
{
loc="cache/repo/$project" && singletree "$project" && \
loc="$XBMK_CACHE/repo/$project" && singletree "$project" && \
loc="src/$project"
printf "Downloading project '%s' to '%s'\n" "$project" "$loc"
@@ -62,8 +62,9 @@ git_prep()
[ "$project" = "coreboot" ] && [ -n "$xtree" ] && [ $# -gt 2 ] && \
[ "$xtree" != "$tree" ] && link_crossgcc "$_loc"
[ "$XBMK_RELEASE" = "y" ] && [ "$_loc" != "cache/repo/$project" ] \
&& rmgit "$tmpgit"
[ "$XBMK_RELEASE" = "y" ] && \
[ "$_loc" != "$XBMK_CACHE/repo/$project" ] && \
rmgit "$tmpgit"
move_repo "$_loc"
}
@@ -106,8 +107,8 @@ tmpclone()
repofail="n"
[ $# -lt 6 ] || rm -Rf "$3" || $err "git retry: !rm $3 ($1)"
repodir="cache/repo/${1##*/}" && [ $# -gt 5 ] && repodir="$3"
x_ mkdir -p "cache/repo"
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 || :