mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
Ports: Try to download files again when verification fails
This commit is contained in:
parent
5a3f63ea00
commit
64d05152f7
1 changed files with 86 additions and 51 deletions
|
@ -118,19 +118,21 @@ fetch() {
|
||||||
gpg --list-keys $auth_import_key || gpg --keyserver hkps://keyserver.ubuntu.com --recv-key $auth_import_key
|
gpg --list-keys $auth_import_key || gpg --keyserver hkps://keyserver.ubuntu.com --recv-key $auth_import_key
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
tried_download_again=0
|
||||||
|
|
||||||
|
while true; do
|
||||||
OLDIFS=$IFS
|
OLDIFS=$IFS
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for f in $files; do
|
for f in $files; do
|
||||||
IFS=$OLDIFS
|
IFS=$OLDIFS
|
||||||
read url filename auth_sum<<< $(echo "$f")
|
read url filename auth_sum<<< $(echo "$f")
|
||||||
echo "URL: ${url}"
|
echo "Downloading URL: ${url}"
|
||||||
|
|
||||||
# FIXME: Serenity's curl port does not support https, even with openssl installed.
|
# FIXME: Serenity's curl port does not support https, even with openssl installed.
|
||||||
if which curl && ! curl https://example.com -so /dev/null; then
|
if which curl >/dev/null 2>&1 && ! curl https://example.com -so /dev/null; then
|
||||||
url=$(echo "$url" | sed "s/^https:\/\//http:\/\//")
|
url=$(echo "$url" | sed "s/^https:\/\//http:\/\//")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# download files
|
# download files
|
||||||
if [ -f "$filename" ]; then
|
if [ -f "$filename" ]; then
|
||||||
echo "$filename already exists"
|
echo "$filename already exists"
|
||||||
|
@ -141,6 +143,15 @@ fetch() {
|
||||||
run_nocd pro "$url" > "$filename"
|
run_nocd pro "$url" > "$filename"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
verification_failed=0
|
||||||
|
|
||||||
|
OLDIFS=$IFS
|
||||||
|
IFS=$'\n'
|
||||||
|
for f in $files; do
|
||||||
|
IFS=$OLDIFS
|
||||||
|
read url filename auth_sum<<< $(echo "$f")
|
||||||
|
|
||||||
# check sha256sum if given
|
# check sha256sum if given
|
||||||
if [ "$auth_type" = "sha256" ]; then
|
if [ "$auth_type" = "sha256" ]; then
|
||||||
|
@ -150,12 +161,55 @@ fetch() {
|
||||||
if [ "$calc_sum" != "$auth_sum" ]; then
|
if [ "$calc_sum" != "$auth_sum" ]; then
|
||||||
# remove downloaded file to re-download on next run
|
# remove downloaded file to re-download on next run
|
||||||
rm -f $filename
|
rm -f $filename
|
||||||
echo "${auth_type}sums mismatching, removed erronous download. Please run script again."
|
echo "${auth_type}sums mismatching, removed erronous download."
|
||||||
|
if [ $tried_download_again -eq 1 ]; then
|
||||||
|
echo "Please run script again."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
echo "Trying to download the files again."
|
||||||
|
tried_download_again=1
|
||||||
|
verification_failed=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# check signature
|
||||||
|
if [ "$auth_type" = "sig" ]; then
|
||||||
|
if $NO_GPG; then
|
||||||
|
echo "WARNING: gpg signature check was disabled by --no-gpg-verification"
|
||||||
|
else
|
||||||
|
if $(gpg --verify $auth_opts); then
|
||||||
|
echo "- Signature check OK."
|
||||||
|
else
|
||||||
|
echo "- Signature check NOT OK"
|
||||||
|
for f in $files; do
|
||||||
|
rm -f $f
|
||||||
|
done
|
||||||
|
rm -rf "$workdir"
|
||||||
|
echo " Signature mismatching, removed erronous download."
|
||||||
|
if [ $tried_download_again -eq 1 ]; then
|
||||||
|
echo "Please run script again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "Trying to download the files again."
|
||||||
|
tried_download_again=1
|
||||||
|
verification_failed=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ $verification_failed -ne 1 ]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
# extract
|
# extract
|
||||||
|
OLDIFS=$IFS
|
||||||
|
IFS=$'\n'
|
||||||
|
for f in $files; do
|
||||||
|
IFS=$OLDIFS
|
||||||
|
read url filename auth_sum<<< $(echo "$f")
|
||||||
|
|
||||||
if [ ! -f "$workdir"/.${filename}_extracted ]; then
|
if [ ! -f "$workdir"/.${filename}_extracted ]; then
|
||||||
case "$filename" in
|
case "$filename" in
|
||||||
*.tar.gz|*.tgz)
|
*.tar.gz|*.tgz)
|
||||||
|
@ -184,25 +238,6 @@ fetch() {
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# check signature
|
|
||||||
if [ "$auth_type" = "sig" ]; then
|
|
||||||
if $NO_GPG; then
|
|
||||||
echo "WARNING: gpg signature check was disabled by --no-gpg-verification"
|
|
||||||
else
|
|
||||||
if $(gpg --verify $auth_opts); then
|
|
||||||
echo "- Signature check OK."
|
|
||||||
else
|
|
||||||
echo "- Signature check NOT OK"
|
|
||||||
for f in $files; do
|
|
||||||
rm -f $f
|
|
||||||
done
|
|
||||||
rm -rf "$workdir"
|
|
||||||
echo " Signature mismatching, removed erronous download. Please run script again."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
|
|
||||||
post_fetch
|
post_fetch
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue