summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xbuild2
-rw-r--r--include/git.sh24
-rw-r--r--include/lib.sh16
-rw-r--r--include/vendor.sh7
-rwxr-xr-xscript/trees19
5 files changed, 44 insertions, 24 deletions
diff --git a/build b/build
index 3408b745..ce778e2a 100755
--- a/build
+++ b/build
@@ -100,7 +100,7 @@ build_release()
cd "$srcdir" || $err "$vdir: !cd \"$srcdir\""
./update trees -f
rmgit .
- x_ rm -Rf cache
+ x_ rm -Rf tmp
x_ mv src/docs docs
) || $err "can't create release files"
diff --git a/include/git.sh b/include/git.sh
index 2eea5137..f8441f33 100644
--- a/include/git.sh
+++ b/include/git.sh
@@ -3,7 +3,7 @@
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
eval `setvars "" loc url bkup_url subfile subhash subrepo subrepo_bkup \
- depend subfile_bkup`
+ depend subfile_bkup repofail`
fetch_targets()
{
@@ -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"
}
@@ -101,12 +102,16 @@ fetch_submodule()
tmpclone()
{
+ [ "$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="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 :
+ || sleep 3 || git -C "$repodir" pull || :
else
git clone $1 "$repodir" || git clone $2 "$repodir" || \
$err "!clone $1 $2 $repodir $4 $5"
@@ -115,7 +120,10 @@ tmpclone()
[ $# -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"
- ) || [ $# -gt 5 ] || tmpclone $@ retry; :
+ ) || repofail="y"
+
+ [ "$repofail" = "y" ] && [ $# -lt 6 ] && tmpclone $@ retry
+ [ "$repofail" = "y" ] && $err "!clone $1 $2 $3 $4 $5"; :
}
git_am_patches()
diff --git a/include/lib.sh b/include/lib.sh
index 791ab4e1..2cd8c0d7 100644
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -88,6 +88,14 @@ if [ -z "${TMPDIR+x}" ]; then
xbmk_parent="y"
fi
+# XBMK_CACHE is a directory, for caching downloads and git repositories
+[ -z "${XBMK_CACHE+x}" ] && export XBMK_CACHE="$PWD/cache"
+[ -z "$XBMK_CACHE" ] && export XBMK_CACHE="$PWD/cache"
+[ -L "$XBMK_CACHE" ] && [ "$XBMK_CACHE" = "$PWD/cache" ] && \
+ $err "cachedir is default, $PWD/cache, but it exists and is a symlink"
+[ -L "$XBMK_CACHE" ] && export XBMK_CACHE="$PWD/cache"
+[ -f "$XBMK_CACHE" ] && $err "cachedir '$XBMK_CACHE' exists but it's a file"
+
# if "y": a coreboot target won't be built if target.cfg says release="n"
# (this is used to exclude certain build targets from releases)
[ -z "${XBMK_RELEASE+x}" ] && export XBMK_RELEASE="n"
@@ -180,14 +188,16 @@ singletree()
download()
{
- cached="cache/file/$4"
+ cached="$XBMK_CACHE/file/$4"
dl_fail="n" # 1 url, 2 url backup, 3 destination, 4 checksum
vendor_checksum "$4" "$cached" 2>/dev/null && dl_fail="y"
[ "$dl_fail" = "n" ] && e "$3" f && return 0
- x_ mkdir -p "${3%/*}" cache/file && for url in "$1" "$2"; do
+ mkdir -p "${3%/*}" "$XBMK_CACHE/file" || \
+ $err "!mkdir '$3' '$XBMK_CACHE/file'"
+ for url in "$1" "$2"; do
[ "$dl_fail" = "n" ] && break
[ -z "$url" ] && continue
- x_ rm -f "$cached"
+ rm -f "$cached" || $err "!rm -f '$cached'"
curl --location --retry 3 -A "$_ua" "$url" -o "$cached" || \
wget --tries 3 -U "$_ua" "$url" -O "$cached" || continue
vendor_checksum "$4" "$cached" || dl_fail="n"
diff --git a/include/vendor.sh b/include/vendor.sh
index 426e0f5f..ace3f7ce 100644
--- a/include/vendor.sh
+++ b/include/vendor.sh
@@ -8,7 +8,7 @@ me7updateparser="$PWD/util/me7_update_parser/me7_update_parser.py"
pfs_extract="$PWD/src/biosutilities/Dell_PFS_Extract.py"
uefiextract="$PWD/elf/uefitool/uefiextract"
vendir="vendorfiles"
-appdir="cache/app"
+appdir="$vendir/app"
cbcfgsdir="config/coreboot"
eval `setvars "" EC_url_bkup EC_hash DL_hash DL_url_bkup MRC_refcode_gbe vcfg \
@@ -78,11 +78,12 @@ getfiles()
fetch()
{
dl_type="$1"; dl="$2"; dl_bkup="$3"; dlsum="$4"; _dest="${5##*../}"
- [ "$5" = "/dev/null" ] && return 0; _dl="cache/file/$dlsum"
+ [ "$5" = "/dev/null" ] && return 0; _dl="$XBMK_CACHE/file/$dlsum"
download "$dl" "$dl_bkup" "$_dl" "$dlsum"
- x_ rm -Rf "${_dl}_extracted"
+ rm -Rf "${_dl}_extracted" || \
+ $err "!rm -Rf ${_ul}_extracted"
e "$_dest" f && return 0
mkdir -p "${_dest%/*}" || $err "mkdirs: !mkdir -p ${_dest%/*}"
diff --git a/script/trees b/script/trees
index d3ac03f9..ce6da422 100755
--- a/script/trees
+++ b/script/trees
@@ -165,11 +165,11 @@ build_dependencies()
check_project_hashes()
{
- x_ mkdir -p cache/hash
+ mkdir -p "$XBMK_CACHE/hash" || $err "!mkdir '$XBMK_CACHE/hash'"
old_pjhash=""
- [ ! -f "cache/hash/$project$tree" ] || \
- read -r old_pjhash < "cache/hash/$project$tree"
+ [ ! -f "$XBMK_CACHE/hash/$project$tree" ] || \
+ read -r old_pjhash < "$XBMK_CACHE/hash/$project$tree"
x_ rm -f "$TMPDIR/project.list" "$TMPDIR/project.hash" \
"$TMPDIR/project.tmp"; x_ touch "$TMPDIR/project.tmp"
@@ -192,10 +192,10 @@ check_project_hashes()
pjhash="$(sha512sum "$TMPDIR/project.hash" | awk '{print $1}')" || :
badhash="y" && [ "$pjhash" = "$old_pjhash" ] && badhash="n"
- [ -f "cache/hash/$project$tree" ] || badhash="y"
+ [ -f "$XBMK_CACHE/hash/$project$tree" ] || badhash="y"
- printf "%s\n" "$pjhash" > "cache/hash/$project$tree" || \
- $err "!mk cache/hash/$project$tree"
+ printf "%s\n" "$pjhash" > "$XBMK_CACHE/hash/$project$tree" || \
+ $err "!mk $XBMK_CACHE/hash/$project$tree"
[ "$badhash" = "n" ] || rm -Rf "src/$project/$tree" \
"elf/$project/$tree" "elf/$project/$target" || \
@@ -204,6 +204,7 @@ check_project_hashes()
check_cross_compiler()
{
+ xgccargs="UPDATED_SUBMODULES=1 CPUS=$XBMK_THREADS"
for _xarch in $xarch; do
cbdir="src/coreboot/$tree"
[ "$project" != "coreboot" ] && cbdir="src/coreboot/default"
@@ -216,9 +217,9 @@ check_cross_compiler()
[ -n "$xlang" ] && export BUILD_LANGUAGES="$xlang"
# sometimes buildgcc fails for like no reason. try twice.
- make -C "$cbdir" crossgcc-${_xarch%-*} $makeargs || \
- make -C "$cbdir" crossgcc-${_xarch%-*} $makeargs || \
- $err "!mkxgcc $project/$xtree '${_xarch%-*}' '$makeargs'"
+ make -C "$cbdir" crossgcc-${_xarch%-*} $xgccargs || \
+ make -C "$cbdir" crossgcc-${_xarch%-*} $xgccargs || \
+ $err "!mkxgcc $project/$xtree '${_xarch%-*}' '$xgccargs'"
done; return 0
}