[Ubuntu] Get toolset value function. (#2435)

* [macOS] Fail Pester tests on error

* return it back

* [Ubuntu] add get_toolset_values function

* added fix

* fix all nitpicks

* try to get rid brackets

* removed brackets.

* pipx-package fix
This commit is contained in:
Darii Nurgaleev
2021-01-15 21:12:26 +07:00
committed by GitHub
parent 68e9c68855
commit 7c6117e6ec
13 changed files with 40 additions and 42 deletions

View File

@@ -47,4 +47,14 @@ function IsPackageInstalled {
verlte() { verlte() {
sortedVersion=$(echo -e "$1\n$2" | sort -V | head -n1) sortedVersion=$(echo -e "$1\n$2" | sort -V | head -n1)
[ "$1" = "$sortedVersion" ] [ "$1" = "$sortedVersion" ]
}
get_toolset_path() {
echo "/imagegeneration/installers/toolset.json"
}
get_toolset_value() {
local toolset_path=$(get_toolset_path)
local query=$1
echo "$(jq -r "$query" $toolset_path)"
} }

View File

@@ -56,12 +56,11 @@ else
exit 1 exit 1
fi fi
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" minimumBuildToolVersion=$(get_toolset_value '.android.build_tools_min_version')
minimumBuildToolVersion=$(jq -r '.android.build_tools_min_version' $toolset) minimumPlatformVersion=$(get_toolset_value '.android.platform_min_version')
minimumPlatformVersion=$(jq -r '.android.platform_min_version' $toolset) extras=$(get_toolset_value '.android.extra_list[]|"extras;" + .')
extras=$(jq -r '.android.extra_list[]|"extras;" + .' $toolset) addons=$(get_toolset_value '.android.addon_list[]|"add-ons;" + .')
addons=$(jq -r '.android.addon_list[]|"add-ons;" + .' $toolset) additional=$(get_toolset_value '.android.additional_tools[]')
additional=$(jq -r '.android.additional_tools[]' $toolset)
# Install the following SDKs and build tools, passing in "y" to accept licenses. # Install the following SDKs and build tools, passing in "y" to accept licenses.
components=( "${extras[@]}" "${addons[@]}" "${additional[@]}" ) components=( "${extras[@]}" "${addons[@]}" "${additional[@]}" )

View File

@@ -3,10 +3,10 @@
## File: basic.sh ## File: basic.sh
## Desc: Installs basic command line utilities and dev packages ## Desc: Installs basic command line utilities and dev packages
################################################################################ ################################################################################
source $HELPER_SCRIPTS/install.sh
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" common_packages=$(get_toolset_value .apt.common_packages[])
common_packages=$(jq -r ".apt.common_packages[]" $toolset) cmd_packages=$(get_toolset_value .apt.cmd_packages[])
cmd_packages=$(jq -r ".apt.cmd_packages[]" $toolset)
for package in $common_packages $cmd_packages; do for package in $common_packages $cmd_packages; do
echo "Install $package" echo "Install $package"
apt-get install -y --no-install-recommends $package apt-get install -y --no-install-recommends $package

View File

@@ -6,6 +6,7 @@
# Source the helpers for use with the script # Source the helpers for use with the script
source $HELPER_SCRIPTS/os.sh source $HELPER_SCRIPTS/os.sh
source $HELPER_SCRIPTS/install.sh
function InstallClang { function InstallClang {
local version=$1 local version=$1
@@ -32,10 +33,8 @@ function SetDefaultClang {
wget https://apt.llvm.org/llvm.sh wget https://apt.llvm.org/llvm.sh
chmod +x llvm.sh chmod +x llvm.sh
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" versions=$(get_toolset_value '.clang.versions[]')
default_clang_version=$(get_toolset_value '.clang.default_version')
versions=$(jq -r '.clang.versions[]' $toolset)
default_clang_version=$(jq -r '.clang.default_version' $toolset)
for version in ${versions[*]}; do for version in ${versions[*]}; do
InstallClang $version InstallClang $version

View File

@@ -29,8 +29,7 @@ sleep 10
docker info docker info
# Pull images # Pull images
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" images=$(get_toolset_value '.docker.images[]')
images=$(jq -r '.docker.images[]' $toolset)
for image in $images; do for image in $images; do
docker pull "$image" docker pull "$image"
done done

View File

@@ -9,9 +9,8 @@ source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/os.sh source $HELPER_SCRIPTS/os.sh
# Ubuntu 20 doesn't support EOL versions # Ubuntu 20 doesn't support EOL versions
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" LATEST_DOTNET_PACKAGES=$(get_toolset_value '.dotnet.aptPackages[]')
LATEST_DOTNET_PACKAGES=$(jq -r '.dotnet.aptPackages[]' $toolset) DOTNET_VERSIONS=$(get_toolset_value '.dotnet.versions[]')
versions=$(jq -r '.dotnet.versions[]' $toolset)
mksamples() mksamples()
{ {
@@ -43,7 +42,7 @@ done
# Get list of all released SDKs from channels which are not end-of-life or preview # Get list of all released SDKs from channels which are not end-of-life or preview
sdks=() sdks=()
for version in ${versions[@]}; do for version in ${DOTNET_VERSIONS[@]}; do
release_url="https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${version}/releases.json" release_url="https://dotnetcli.blob.core.windows.net/dotnet/release-metadata/${version}/releases.json"
download_with_retries "${release_url}" "." "${version}.json" download_with_retries "${release_url}" "." "${version}.json"
releases=$(cat "./${version}.json") releases=$(cat "./${version}.json")

View File

@@ -6,6 +6,7 @@
# Source the helpers for use with the script # Source the helpers for use with the script
source $HELPER_SCRIPTS/os.sh source $HELPER_SCRIPTS/os.sh
source $HELPER_SCRIPTS/install.sh
function InstallGcc { function InstallGcc {
version=$1 version=$1
@@ -18,9 +19,7 @@ function InstallGcc {
add-apt-repository ppa:ubuntu-toolchain-r/test -y add-apt-repository ppa:ubuntu-toolchain-r/test -y
apt-get update -y apt-get update -y
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" versions=$(get_toolset_value '.gcc.versions[]')
versions=$(jq -r '.gcc.versions[]' $toolset)
for version in ${versions[*]}; do for version in ${versions[*]}; do
InstallGcc $version InstallGcc $version

View File

@@ -3,7 +3,7 @@
## File: gfortran.sh ## File: gfortran.sh
## Desc: Installs GNU Fortran ## Desc: Installs GNU Fortran
################################################################################ ################################################################################
source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/os.sh source $HELPER_SCRIPTS/os.sh
function InstallFortran { function InstallFortran {
@@ -17,8 +17,7 @@ function InstallFortran {
add-apt-repository ppa:ubuntu-toolchain-r/test -y add-apt-repository ppa:ubuntu-toolchain-r/test -y
apt-get update -y apt-get update -y
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" versions=$(get_toolset_value '.gfortran.versions[]')
versions=$(jq -r '.gfortran.versions[]' $toolset)
for version in ${versions[*]} for version in ${versions[*]}
do do

View File

@@ -3,13 +3,12 @@
## File: java-tools.sh ## File: java-tools.sh
## Desc: Installs Java and related tooling (Ant, Gradle, Maven) ## Desc: Installs Java and related tooling (Ant, Gradle, Maven)
################################################################################ ################################################################################
source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/os.sh source $HELPER_SCRIPTS/os.sh
source $HELPER_SCRIPTS/etc-environment.sh source $HELPER_SCRIPTS/etc-environment.sh
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" JAVA_VERSIONS_LIST=$(get_toolset_value '.java.versions | .[]')
JAVA_VERSIONS_LIST=$(jq -r '.java.versions | .[]' $toolset) DEFAULT_JDK_VERSION=$(get_toolset_value '.java.default')
DEFAULT_JDK_VERSION=$(jq -r '.java.default' $toolset)
# Install GPG Key for Adopt Open JDK. See https://adoptopenjdk.net/installation.html # Install GPG Key for Adopt Open JDK. See https://adoptopenjdk.net/installation.html
wget -qO - "https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public" | apt-key add - wget -qO - "https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public" | apt-key add -

View File

@@ -7,15 +7,14 @@
# Source the helpers for use with the script # Source the helpers for use with the script
source $HELPER_SCRIPTS/etc-environment.sh source $HELPER_SCRIPTS/etc-environment.sh
source $HELPER_SCRIPTS/os.sh source $HELPER_SCRIPTS/os.sh
source $HELPER_SCRIPTS/install.sh
# add repository # add repository
apt-add-repository ppa:ondrej/php -y apt-add-repository ppa:ondrej/php -y
apt-get update apt-get update
# Install PHP # Install PHP
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" php_versions=$(get_toolset_value '.php.versions[]')
php_versions=$(jq -r '.php.versions[]' $toolset)
for version in $php_versions; do for version in $php_versions; do
echo "Installing PHP $version" echo "Installing PHP $version"

View File

@@ -3,14 +3,14 @@
## File: pipx-packages.sh ## File: pipx-packages.sh
## Desc: Install tools via pipx ## Desc: Install tools via pipx
################################################################################ ################################################################################
source $HELPER_SCRIPTS/install.sh
export PATH="$PATH:/opt/pipx_bin" export PATH="$PATH:/opt/pipx_bin"
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" pipx_packages=$(get_toolset_value ".pipx[] .package")
pipx_packages=$(jq -r ".pipx[] .package" $toolset)
for package in $pipx_packages; do for package in $pipx_packages; do
python_version=$(jq -r ".pipx[] | select(.package == \"$package\") .python" $toolset) python_version=$(get_toolset_value ".pipx[] | select(.package == \"$package\") .python")
if [ "$python_version" != "null" ]; then if [ "$python_version" != "null" ]; then
python_path="/opt/hostedtoolcache/Python/$python_version*/x64/bin/python$python_version" python_path="/opt/hostedtoolcache/Python/$python_version*/x64/bin/python$python_version"
echo "Install $package into python $python_path" echo "Install $package into python $python_path"

View File

@@ -76,10 +76,7 @@ function InstallPyPy
uri="https://downloads.python.org/pypy/" uri="https://downloads.python.org/pypy/"
download_with_retries $uri "/tmp" "pypyUrls.html" compressed download_with_retries $uri "/tmp" "pypyUrls.html" compressed
pypyVersions="$(cat /tmp/pypyUrls.html | grep 'linux64' | awk -v uri="$uri" -F'>|<' '{print uri$5}')" pypyVersions="$(cat /tmp/pypyUrls.html | grep 'linux64' | awk -v uri="$uri" -F'>|<' '{print uri$5}')"
toolsetVersions=$(get_toolset_value '.toolcache[] | select(.name | contains("PyPy")) | .versions[]')
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json"
toolsetVersions=$(jq -r '.toolcache[] | select(.name | contains("PyPy")) | .versions[]' $toolset)
for toolsetVersion in $toolsetVersions; do for toolsetVersion in $toolsetVersions; do
latestMajorPyPyVersion=$(echo "${pypyVersions}" | grep -E "pypy${toolsetVersion}-v[0-9]+\.[0-9]+\.[0-9]+-" | head -1) latestMajorPyPyVersion=$(echo "${pypyVersions}" | grep -E "pypy${toolsetVersion}-v[0-9]+\.[0-9]+\.[0-9]+-" | head -1)

View File

@@ -13,10 +13,9 @@ sudo gem update --system
apt-get install -y libz-dev openssl libssl-dev apt-get install -y libz-dev openssl libssl-dev
echo "Install Ruby from toolset..." echo "Install Ruby from toolset..."
toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json"
PACKAGE_TAR_NAMES=$(curl -s "https://api.github.com/repos/ruby/ruby-builder/releases/latest" | jq -r '.assets[].name') PACKAGE_TAR_NAMES=$(curl -s "https://api.github.com/repos/ruby/ruby-builder/releases/latest" | jq -r '.assets[].name')
TOOLSET_VERSIONS=$(jq -r '.toolcache[] | select(.name | contains("Ruby")) | .versions[]' $toolset) TOOLSET_VERSIONS=$(get_toolset_value '.toolcache[] | select(.name | contains("Ruby")) | .versions[]')
PLATFORM_VERSION=$(jq -r '.toolcache[] | select(.name | contains("Ruby")) | .platform_version' $toolset) PLATFORM_VERSION=$(get_toolset_value '.toolcache[] | select(.name | contains("Ruby")) | .platform_version')
RUBY_PATH="$AGENT_TOOLSDIRECTORY/Ruby" RUBY_PATH="$AGENT_TOOLSDIRECTORY/Ruby"
echo "Check if Ruby hostedtoolcache folder exist..." echo "Check if Ruby hostedtoolcache folder exist..."