summaryrefslogtreecommitdiff
path: root/resources/scripts/update
diff options
context:
space:
mode:
authorLeah Rowe <leah@libreboot.org>2023-08-05 21:13:34 +0100
committerLeah Rowe <leah@libreboot.org>2023-08-05 21:13:34 +0100
commitcdd83ab1ce61aa2354184b698e000f8dfe2ba588 (patch)
treecb56022768229841b5a3ccf998491bf5bfb70974 /resources/scripts/update
parentf18b1859dbc9c8dad8911b16f76585189b68a266 (diff)
blobs/download: try backup if bad hash on main
At present, the logic only tries backup URLs when an actual download fails (bad internet connection or the server is down). If the main download succeeds, but it has a bad checksum, the backup download is not attempted. Since wrongly hashed files are to be assumed useless, we may aswell delete and try the next file. This will guard against the possibility of a vendor changing their file, without changing the file name (non-versioned files, for example, may be subject to such changes). Signed-off-by: Leah Rowe <leah@libreboot.org>
Diffstat (limited to 'resources/scripts/update')
-rwxr-xr-xresources/scripts/update/blobs/download20
1 files changed, 14 insertions, 6 deletions
diff --git a/resources/scripts/update/blobs/download b/resources/scripts/update/blobs/download
index fc197665..f50aa871 100755
--- a/resources/scripts/update/blobs/download
+++ b/resources/scripts/update/blobs/download
@@ -452,12 +452,20 @@ fetch_update()
dl_path=${blobdir}/cache/${dlsum}
mkdir -p ${blobdir}/cache
- vendor_checksum ${dlsum} || \
- wget -U "${agent}" ${dl} -O ${dl_path} \
- || wget -U "${agent}" ${dl_bkup} -O ${dl_path}
-
- vendor_checksum ${dlsum} || fail \
- "Cannot guarantee intergity of vendor update for: ${board}"
+ dl_fail="y"
+ vendor_checksum ${dlsum} && dl_fail="n"
+ for x in "${dl}" "${dl_bkup}"; do
+ if [ "${dl_fail}" = "n" ]; then
+ break
+ fi
+ rm -f "${dl_path}"
+ wget -U "${agent}" ${x} -O ${dl_path}
+ vendor_checksum ${dlsum} && dl_fail="n"
+ done
+ if [ "${dl_fail}" = "y" ]; then
+ printf "Could not download blob file\n" 1>&2
+ return 1
+ fi
}
vendor_checksum()