mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 05:37:34 +00:00
Ports: Move handling for simple downloads into a separate function
This commit is contained in:
parent
a37b95f465
commit
c71815bc91
1 changed files with 52 additions and 45 deletions
|
@ -310,27 +310,25 @@ do_download_file() {
|
|||
fi
|
||||
}
|
||||
|
||||
# FIXME: Don't allow overriding fetch, support multiple protocols instead. See #20004
|
||||
func_defined fetch || fetch() {
|
||||
pre_fetch
|
||||
|
||||
for f in "${files[@]}"; do
|
||||
read url filename auth_sum <<< $(echo "${f}")
|
||||
fetch_simple() {
|
||||
url="${1}"
|
||||
filename="${2}"
|
||||
checksum="${3}"
|
||||
|
||||
tried_download_again=0
|
||||
|
||||
while true; do
|
||||
do_download_file "$url" "${PORT_META_DIR}/${filename}"
|
||||
do_download_file "${url}" "${PORT_META_DIR}/${filename}"
|
||||
|
||||
calc_sum="$(sha256sum "${PORT_META_DIR}/${filename}" | cut -f1 -d' ')"
|
||||
actual_checksum="$(sha256sum "${PORT_META_DIR}/${filename}" | cut -f1 -d' ')"
|
||||
|
||||
if [ "$calc_sum" = "$auth_sum" ]; then
|
||||
if [ "${actual_checksum}" = "${checksum}" ]; then
|
||||
break
|
||||
fi
|
||||
|
||||
echo "SHA256 checksum of downloaded file '${filename}' does not match!"
|
||||
echo "Expected: ${auth_sum}"
|
||||
echo "Actual: ${calc_sum}"
|
||||
echo "Expected: ${checksum}"
|
||||
echo "Actual: ${actual_checksum}"
|
||||
rm -f "${PORT_META_DIR}/${filename}"
|
||||
echo "Removed erroneous download."
|
||||
if [ "${tried_download_again}" -eq 1 ]; then
|
||||
|
@ -345,15 +343,15 @@ func_defined fetch || fetch() {
|
|||
case "$filename" in
|
||||
*.tar.gz|*.tar.bz|*.tar.bz2|*.tar.xz|*.tar.lz|*.tar.zst|.tbz*|*.txz|*.tgz)
|
||||
run_nocd tar -xf "${PORT_META_DIR}/${filename}"
|
||||
run touch .${filename}_extracted
|
||||
run touch ".${filename}_extracted"
|
||||
;;
|
||||
*.gz)
|
||||
run_nocd gunzip "${PORT_META_DIR}/${filename}"
|
||||
run touch .${filename}_extracted
|
||||
run touch ".${filename}_extracted"
|
||||
;;
|
||||
*.zip)
|
||||
run_nocd bsdtar xf "${PORT_META_DIR}/${filename}" || run_nocd unzip -qo "${PORT_META_DIR}/${filename}"
|
||||
run touch .${filename}_extracted
|
||||
run touch ".${filename}_extracted"
|
||||
;;
|
||||
*)
|
||||
echo "Note: no case for file $filename."
|
||||
|
@ -361,6 +359,15 @@ func_defined fetch || fetch() {
|
|||
;;
|
||||
esac
|
||||
fi
|
||||
}
|
||||
|
||||
# FIXME: Don't allow overriding fetch, support multiple protocols instead. See #20004
|
||||
func_defined fetch || fetch() {
|
||||
pre_fetch
|
||||
|
||||
for f in "${files[@]}"; do
|
||||
read url filename auth_sum <<< $(echo "${f}")
|
||||
fetch_simple "${url}" "${filename}" "${auth_sum}"
|
||||
done
|
||||
|
||||
post_fetch
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue