summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-09-29 23:03:45 +0100
committerLeah Rowe <leah@libreboot.org>2023-09-29 23:04:30 +0100
commit416704fb4e284770798a914c93434e3d91e6b900 (patch)
treebe7ad5fe71b05090790a1d3ea5d433f01af03d89
parent6519cea9cff998d3484cbbbb3fbbedb886b93dfd (diff)
include/blobutil: try curl first, then wget
Don't use only wget. Some systems may only have curl. The user can always install wget anyway, but why not support both? I've added the right user agent string. Signed-off-by: Leah Rowe <leah@libreboot.org>
-rwxr-xr-xinclude/blobutil.sh19
-rwxr-xr-xscript/update/blobs/download6
2 files changed, 13 insertions, 12 deletions
diff --git a/include/blobutil.sh b/include/blobutil.sh
index a32a8ba6..a14f92c1 100755
--- a/include/blobutil.sh
+++ b/include/blobutil.sh
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-3.0-only
# SPDX-FileCopyrightText: 2023 Leah Rowe <leah@libreboot.org>
-agent="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
+_ua="Mozilla/5.0 (Windows NT 10.0; rv:91.0) Gecko/20100101 Firefox/91.0"
_7ztest="a"
_b=""
@@ -30,7 +30,7 @@ for x in EC_url_bkup EC_hash DL_hash DL_url DL_url_bkup E6400_VGA_DL_hash \
setvars="${setvars}; ${x}=\"\""
done
-for x in archive rom board modifygbe new_mac release releasearchive dl_path; do
+for x in archive rom board modifygbe new_mac release releasearchive _dl; do
setvars="${setvars}; ${x}=\"\""
done
@@ -62,24 +62,25 @@ fetch()
[ "${5# }" = "${5}" ] || err "fetch: space not allowed in _dest: '${5}'"
[ "${5#/}" = "${5}" ] || err "fetch: absolute path not allowed: '${5}'"
_dest="${5##*../}"
- dl_path="${blobdir}/cache/${dlsum}"
+ _dl="${blobdir}/cache/${dlsum}"
- mkdir -p "${dl_path%/*}" || err "fetch: !mkdir ${dl_path%/*}"
+ mkdir -p "${_dl%/*}" || err "fetch: !mkdir ${_dl%/*}"
dl_fail="y"
- vendor_checksum "${dlsum}" "${dl_path}" && dl_fail="n"
+ vendor_checksum "${dlsum}" "${_dl}" && dl_fail="n"
for url in "${dl}" "${dl_bkup}"; do
[ "${dl_fail}" = "n" ] && break
[ -z "${url}" ] && continue
- rm -f "${dl_path}" || err "fetch: !rm -f ${dl_path}"
- wget --tries 3 -U "${agent}" "${url}" -O "${dl_path}" || \
+ rm -f "${_dl}" || err "fetch: !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_path}" && dl_fail="n"
+ vendor_checksum "${dlsum}" "${_dl}" && dl_fail="n"
done
[ "${dl_fail}" = "y" ] && \
err "fetch ${dlsum}: matched file unavailable"
- rm -Rf "${dl_path}_extracted" || err "!rm ${dl_path}_extracted"
+ rm -Rf "${_dl}_extracted" || err "!rm ${_dl}_extracted"
mkdirs "${_dest}" "extract_${dl_type}" || return 0
eval "extract_${dl_type}"
diff --git a/script/update/blobs/download b/script/update/blobs/download
index 9d41857e..5c832c5f 100755
--- a/script/update/blobs/download
+++ b/script/update/blobs/download
@@ -154,7 +154,7 @@ extract_e6400vga()
err "extract_e6400vga: E6400 VGA offset not defined"
[ "${E6400_VGA_romname}" = "" ] && \
err "extract_e6400vga: E6400 VGA ROM name not defined"
- tail -c +${E6400_VGA_offset} "${dl_path}" | \
+ tail -c +${E6400_VGA_offset} "${_dl}" | \
gunzip >"${appdir}/bios.bin" || :
(
cd "${appdir}" || err "extract_e6400vga: can't cd ${appdir}"
@@ -172,7 +172,7 @@ extract_e6400vga()
extract_sch5545ec()
{
# full system ROM (UEFI), to extract with UEFIExtract:
- _bios="${dl_path}_extracted/Firmware"
+ _bios="${_dl}_extracted/Firmware"
_bios="${_bios}/1 ${dlsum} -- 1 System BIOS vA.28.bin"
# this is the SCH5545 firmware, inside of the extracted UEFI ROM:
_sch5545ec_fw="${_bios}.dump/4 7A9354D9-0468-444A-81CE-0BF617D890DF"
@@ -193,7 +193,7 @@ mkdirs()
mkdir -p "${1%/*}" || err "mkdirs ${1} ${2}: !mkdir ${1%/*}"
rm -Rf "${appdir}" || err "mkdirs ${1} ${2}: can't remove ${appdir}"
mkdir -p "${appdir}/" || err "mkdirs ${1} ${2}: !mkdir ${appdir}"
- extract_archive "${dl_path}" "${appdir}" || \
+ extract_archive "${_dl}" "${appdir}" || \
[ "${2}" = "extract_e6400vga" ] || err "mkdirs ${1} ${2}: !extract"
}