summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rwxr-xr-xinclude/git.sh28
-rwxr-xr-xinclude/lib.sh28
-rwxr-xr-xinclude/vendor.sh27
3 files changed, 50 insertions, 33 deletions
diff --git a/include/git.sh b/include/git.sh
index 63300fe8..5fe41fb3 100755
--- a/include/git.sh
+++ b/include/git.sh
@@ -3,7 +3,7 @@
# Copyright (c) 2022 Caleb La Grange <thonkpeasant@protonmail.com>
eval "$(setvars "" _target rev _xm loc url bkup_url depend tree_depend xtree \
- mdir subrev subrepo subrepo_bkup)"
+ mdir subhash subrepo subrepo_bkup subfile subfile_bkup)"
fetch_project_trees()
{
@@ -114,19 +114,31 @@ prep_submodules()
fetch_submodule()
{
mcfgdir="$mdir/${1##*/}"
- eval "$(setvars "" subrev subrepo subrepo_bkup)"
+ eval "$(setvars "" subhash subrepo subrepo_bkup subfile subfile_bkup)"
[ ! -f "$mcfgdir/module.cfg" ] || . "$mcfgdir/module.cfg" || \
$err "! . $mcfgdir/module.cfg"
- [ -z "$subrepo" ] && [ -z "$subrepo_bkup" ] && return 0
- for mvar in subrepo subrepo_bkup subrev; do
- eval "[ -n \"\$$mvar\" ] || $err \"$1, $mdir: $mvar unset\""
+ st=""
+ for _st in repo file; do
+ _seval="if [ -n \"\$sub$_st\" ] || [ -n \"\$sub${_st}_bkup\" ]"
+ eval "$_seval; then st=\"\$st \$_st\"; fi"
done
+ st="${st# }"
+ [ "$st" = "repo file" ] && $err "$mdir: repo/file both defined"
- rm -Rf "$tmpgit/$1" || $err "!rm '$mdir' '$1'"
+ [ -z "$st" ] && return 0 # subrepo/subfile not defined
- tmpclone "$subrepo" "$subrepo_bkup" "$tmpgit/$1" "$subrev" \
- "$mdir/${1##*/}/patches"
+ for mvar in "sub${st}" "sub${st}_bkup" "subhash"; do
+ eval "[ -n \"\$$mvar\" ] || $err \"$1, $mdir: $mvar unset\""
+ done
+
+ if [ "$st" = "repo" ]; then
+ rm -Rf "$tmpgit/$1" || $err "!rm '$mdir' '$1'"
+ tmpclone "$subrepo" "$subrepo_bkup" "$tmpgit/$1" "$subhash" \
+ "$mdir/${1##*/}/patches"
+ else
+ download "$subfile" "$subfile_bkup" "$tmpgit/$1" "$subhash"
+ fi
}
tmpclone()
diff --git a/include/lib.sh b/include/lib.sh
index 39d3bc99..9d66ea8d 100755
--- a/include/lib.sh
+++ b/include/lib.sh
@@ -6,6 +6,8 @@
export LC_COLLATE=C
export LC_ALL=C
+_ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
+
tmpdir_was_set="y"
cbdir="src/coreboot/default"
ifdtool="elf/ifdtool/default/ifdtool"
@@ -210,7 +212,7 @@ e()
[ $# -gt 1 ] && es_t="$2"
es2="already exists"
estr="[ -$es_t \"\$1\" ] || return 1"
- [ $# -gt 2 ] && estr="[ -$es_t \"\$1\" ] && return 1" && es2="not found"
+ [ $# -gt 2 ] && estr="[ -$es_t \"\$1\" ] && return 1" && es2="missing"
eval "$estr"
printf "%s %s\n" "$1" "$es2" 1>&2
@@ -225,3 +227,27 @@ singletree()
[ -f "$targetfile" ] && return 1
done
}
+
+download()
+{
+ dl_fail="y" # 1 url, 2 url backup, 3 destination, 4 checksum
+ vendor_checksum "$4" "$3" || dl_fail="n"
+ [ "$dl_fail" = "n" ] && e "$3" f && return 0
+ x_ mkdir -p "${3%/*}"
+ for url in "$1" "$2"; do
+ [ "$dl_fail" = "n" ] && break
+ [ -z "$1" ] && continue
+ x_ rm -f "$3"
+ curl --location --retry 3 -A "$_ua" "$1" -o "$3" || \
+ wget --tries 3 -U "$_ua" "$1" -O "$3" || continue
+ vendor_checksum "$4" "$3" || dl_fail="n"
+ done
+ [ "$dl_fail" = "y" ] && $err "$1 $2 $3 $4: file missing"; return 0
+}
+
+vendor_checksum()
+{
+ [ "$(sha512sum "$2" | awk '{print $1}')" != "$1" ] || return 1
+ printf "Bad checksum for file: %s\n" "$2" 1>&2
+ rm -f "$2" || :
+}
diff --git a/include/vendor.sh b/include/vendor.sh
index 651766df..4a0e7ae6 100755
--- a/include/vendor.sh
+++ b/include/vendor.sh
@@ -3,13 +3,12 @@
# Copyright (c) 2022 Ferass El Hafidi <vitali64pmemail@protonmail.com>
# Copyright (c) 2023-2024 Leah Rowe <leah@libreboot.org>
-_ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
_7ztest="a"
e6400_unpack="$PWD/src/bios_extract/dell_inspiron_1100_unpacker.py"
me7updateparser="$PWD/util/me7_update_parser/me7_update_parser.py"
pfs_extract="$PWD/src/biosutilities/Dell_PFS_Extract.py"
-uefiextract="$PWD/src/uefitool/uefiextract"
+uefiextract="$PWD/elf/uefitool/uefiextract"
nvmutil="util/nvmutil/nvm"
vendir="vendorfiles"
appdir="$vendir/app"
@@ -115,20 +114,7 @@ fetch()
_dest="${5##*../}"
_dl="$vendir/cache/$dlsum"
- x_ mkdir -p "${_dl%/*}"
-
- dl_fail="y"
- vendor_checksum "$dlsum" "$_dl" || dl_fail="n"
- for url in "$dl" "$dl_bkup"; do
- [ "$dl_fail" = "n" ] && break
- [ -z "$url" ] && continue
- x_ rm -f "$_dl"
- curl --location --retry 3 -A "$_ua" "$url" -o "$_dl" || \
- wget --tries 3 -U "$_ua" "$url" -O "$_dl" || continue
- vendor_checksum "$dlsum" "$_dl" || dl_fail="n"
- done
- [ "$dl_fail" = "y" ] && \
- $err "fetch $dlsum: matched file unavailable"
+ download "$dl" "$dl_bkup" "$_dl" "$dlsum"
x_ rm -Rf "${_dl}_extracted"
mkdirs "$_dest" "extract_$dl_type" || return 0
@@ -139,13 +125,6 @@ fetch()
$err "extract_$dl_type (fetch): missing file: '$_dest'"
}
-vendor_checksum()
-{
- [ "$(sha512sum "$2" | awk '{print $1}')" != "$1" ] || return 1
- printf "Bad checksum for file: %s\n" "$2" 1>&2
- rm -f "$2" || :
-}
-
mkdirs()
{
e "$1" f && return 1
@@ -154,7 +133,7 @@ mkdirs()
remkdir "$appdir"
extract_archive "$_dl" "$appdir" || \
[ "$2" = "extract_e6400vga" ] || \
- $err "mkdirs $1 $2: !extract"
+ $err "mkdirs $1 $2: !extract"; return 0
}
extract_intel_me()