mirror of
https://github.com/actions/runner-images-sangeeth.git
synced 2025-12-14 22:09:26 +00:00
committed by
GitHub
parent
28da6d6fa1
commit
330e62af9d
30
images/linux/scripts/helpers/install.sh
Normal file
30
images/linux/scripts/helpers/install.sh
Normal file
@@ -0,0 +1,30 @@
|
||||
#!/bin/bash
|
||||
################################################################################
|
||||
## File: install.sh
|
||||
## Desc: Helper functions for installing tools
|
||||
################################################################################
|
||||
|
||||
download_with_retries() {
|
||||
# Due to restrictions of bash functions, positional arguments are used here.
|
||||
# In case if you using latest argument NAME, you should also set value to all previous parameters.
|
||||
# Example: download_with_retries $ANDROID_SDK_URL "." "android_sdk.zip"
|
||||
local URL="$1"
|
||||
local DEST="${2:-.}"
|
||||
local NAME="${3:-${URL##*/}}"
|
||||
|
||||
echo "Downloading $URL..."
|
||||
i=20
|
||||
while [ $i -gt 0 ]; do
|
||||
((i--))
|
||||
wget $URL --output-document="$DEST/$NAME" \
|
||||
--no-verbose
|
||||
if [ $? != 0 ]; then
|
||||
sleep 30
|
||||
else
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
echo "Could not download $URL"
|
||||
return 1
|
||||
}
|
||||
@@ -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[]')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user