Add download retry helper on Ubuntu (#955)

* Add download retry helper
This commit is contained in:
Vladimir Safonkin
2020-05-29 12:27:33 +00:00
committed by GitHub
parent 28da6d6fa1
commit 330e62af9d
2 changed files with 36 additions and 22 deletions

View File

@@ -6,6 +6,7 @@
# Source the helpers for use with the script
source $HELPER_SCRIPTS/document.sh
source $HELPER_SCRIPTS/install.sh
# This function installs PyPy using the specified arguments:
# $1=PACKAGE_URL
@@ -16,7 +17,7 @@ function InstallPyPy
PACKAGE_TAR_NAME=$(echo $PACKAGE_URL | awk -F/ '{print $NF}')
echo "Downloading tar archive '$PACKAGE_TAR_NAME' - '$PACKAGE_URL'"
PACKAGE_TAR_TEMP_PATH="/tmp/$PACKAGE_TAR_NAME"
wget -q -O $PACKAGE_TAR_TEMP_PATH $PACKAGE_URL
download_with_retries $PACKAGE_URL "/tmp" $PACKAGE_TAR_NAME
echo "Expand '$PACKAGE_TAR_NAME' to the /tmp folder"
tar xf $PACKAGE_TAR_TEMP_PATH -C /tmp
@@ -69,28 +70,11 @@ function InstallPyPy
rm -f $PACKAGE_TAR_TEMP_PATH
}
function getPyPyVersions
{
uri="https://downloads.python.org/pypy/"
i=20
while [ $i -gt 0 ]; do
((i--))
result="$(curl -4 -s --compressed $uri | grep 'linux64' | awk -v uri="$uri" -F'>|<' '{print uri$5}')"
if [ -z "$result" ]; then
sleep 30
else
echo "$result"
return
fi
done
echo "There are no more attempts to retrive PyPy version"
exit 1
}
# Installation PyPy
pypyVersions=$(getPyPyVersions)
uri="https://downloads.python.org/pypy/"
download_with_retries $uri "/tmp" "pypyUrls.html"
pypyVersions="$(cat /tmp/pypyUrls.html | grep 'linux64' | awk -v uri="$uri" -F'>|<' '{print uri$5}')"
toolsetJson="$INSTALLER_SCRIPT_FOLDER/toolset.json"
toolsetVersions=$(cat $toolsetJson | jq -r '.toolcache[] | select(.name | contains("PyPy")) | .versions[]')