diff --git a/images/linux/scripts/helpers/install.sh b/images/linux/scripts/helpers/install.sh index e42cd3194..c2fbdb242 100644 --- a/images/linux/scripts/helpers/install.sh +++ b/images/linux/scripts/helpers/install.sh @@ -47,4 +47,14 @@ function IsPackageInstalled { verlte() { sortedVersion=$(echo -e "$1\n$2" | sort -V | head -n1) [ "$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)" } \ No newline at end of file diff --git a/images/linux/scripts/installers/android.sh b/images/linux/scripts/installers/android.sh index c59715399..50eff48f5 100644 --- a/images/linux/scripts/installers/android.sh +++ b/images/linux/scripts/installers/android.sh @@ -56,12 +56,11 @@ else exit 1 fi -toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" -minimumBuildToolVersion=$(jq -r '.android.build_tools_min_version' $toolset) -minimumPlatformVersion=$(jq -r '.android.platform_min_version' $toolset) -extras=$(jq -r '.android.extra_list[]|"extras;" + .' $toolset) -addons=$(jq -r '.android.addon_list[]|"add-ons;" + .' $toolset) -additional=$(jq -r '.android.additional_tools[]' $toolset) +minimumBuildToolVersion=$(get_toolset_value '.android.build_tools_min_version') +minimumPlatformVersion=$(get_toolset_value '.android.platform_min_version') +extras=$(get_toolset_value '.android.extra_list[]|"extras;" + .') +addons=$(get_toolset_value '.android.addon_list[]|"add-ons;" + .') +additional=$(get_toolset_value '.android.additional_tools[]') # Install the following SDKs and build tools, passing in "y" to accept licenses. components=( "${extras[@]}" "${addons[@]}" "${additional[@]}" ) diff --git a/images/linux/scripts/installers/basic.sh b/images/linux/scripts/installers/basic.sh index 49045cb7a..270cc75c8 100644 --- a/images/linux/scripts/installers/basic.sh +++ b/images/linux/scripts/installers/basic.sh @@ -3,10 +3,10 @@ ## File: basic.sh ## Desc: Installs basic command line utilities and dev packages ################################################################################ +source $HELPER_SCRIPTS/install.sh -toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" -common_packages=$(jq -r ".apt.common_packages[]" $toolset) -cmd_packages=$(jq -r ".apt.cmd_packages[]" $toolset) +common_packages=$(get_toolset_value .apt.common_packages[]) +cmd_packages=$(get_toolset_value .apt.cmd_packages[]) for package in $common_packages $cmd_packages; do echo "Install $package" apt-get install -y --no-install-recommends $package diff --git a/images/linux/scripts/installers/clang.sh b/images/linux/scripts/installers/clang.sh index 287da3863..5f9138eba 100644 --- a/images/linux/scripts/installers/clang.sh +++ b/images/linux/scripts/installers/clang.sh @@ -6,6 +6,7 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/os.sh +source $HELPER_SCRIPTS/install.sh function InstallClang { local version=$1 @@ -32,10 +33,8 @@ function SetDefaultClang { wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh -toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" - -versions=$(jq -r '.clang.versions[]' $toolset) -default_clang_version=$(jq -r '.clang.default_version' $toolset) +versions=$(get_toolset_value '.clang.versions[]') +default_clang_version=$(get_toolset_value '.clang.default_version') for version in ${versions[*]}; do InstallClang $version diff --git a/images/linux/scripts/installers/docker-moby.sh b/images/linux/scripts/installers/docker-moby.sh index 87478a7d7..3ab5410f6 100644 --- a/images/linux/scripts/installers/docker-moby.sh +++ b/images/linux/scripts/installers/docker-moby.sh @@ -29,8 +29,7 @@ sleep 10 docker info # Pull images -toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" -images=$(jq -r '.docker.images[]' $toolset) +images=$(get_toolset_value '.docker.images[]') for image in $images; do docker pull "$image" done diff --git a/images/linux/scripts/installers/dotnetcore-sdk.sh b/images/linux/scripts/installers/dotnetcore-sdk.sh index 19696118d..5acae9c27 100644 --- a/images/linux/scripts/installers/dotnetcore-sdk.sh +++ b/images/linux/scripts/installers/dotnetcore-sdk.sh @@ -9,9 +9,8 @@ source $HELPER_SCRIPTS/install.sh source $HELPER_SCRIPTS/os.sh # Ubuntu 20 doesn't support EOL versions -toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" -LATEST_DOTNET_PACKAGES=$(jq -r '.dotnet.aptPackages[]' $toolset) -versions=$(jq -r '.dotnet.versions[]' $toolset) +LATEST_DOTNET_PACKAGES=$(get_toolset_value '.dotnet.aptPackages[]') +DOTNET_VERSIONS=$(get_toolset_value '.dotnet.versions[]') mksamples() { @@ -43,7 +42,7 @@ done # Get list of all released SDKs from channels which are not end-of-life or preview 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" download_with_retries "${release_url}" "." "${version}.json" releases=$(cat "./${version}.json") diff --git a/images/linux/scripts/installers/gcc.sh b/images/linux/scripts/installers/gcc.sh index 690a70c3e..24f1a7cd1 100644 --- a/images/linux/scripts/installers/gcc.sh +++ b/images/linux/scripts/installers/gcc.sh @@ -6,6 +6,7 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/os.sh +source $HELPER_SCRIPTS/install.sh function InstallGcc { version=$1 @@ -18,9 +19,7 @@ function InstallGcc { add-apt-repository ppa:ubuntu-toolchain-r/test -y apt-get update -y -toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" - -versions=$(jq -r '.gcc.versions[]' $toolset) +versions=$(get_toolset_value '.gcc.versions[]') for version in ${versions[*]}; do InstallGcc $version diff --git a/images/linux/scripts/installers/gfortran.sh b/images/linux/scripts/installers/gfortran.sh index dfc215233..6b4ae3f63 100644 --- a/images/linux/scripts/installers/gfortran.sh +++ b/images/linux/scripts/installers/gfortran.sh @@ -3,7 +3,7 @@ ## File: gfortran.sh ## Desc: Installs GNU Fortran ################################################################################ - +source $HELPER_SCRIPTS/install.sh source $HELPER_SCRIPTS/os.sh function InstallFortran { @@ -17,8 +17,7 @@ function InstallFortran { add-apt-repository ppa:ubuntu-toolchain-r/test -y apt-get update -y -toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" -versions=$(jq -r '.gfortran.versions[]' $toolset) +versions=$(get_toolset_value '.gfortran.versions[]') for version in ${versions[*]} do diff --git a/images/linux/scripts/installers/java-tools.sh b/images/linux/scripts/installers/java-tools.sh index 91802398b..1aa1e42ce 100644 --- a/images/linux/scripts/installers/java-tools.sh +++ b/images/linux/scripts/installers/java-tools.sh @@ -3,13 +3,12 @@ ## File: java-tools.sh ## Desc: Installs Java and related tooling (Ant, Gradle, Maven) ################################################################################ - +source $HELPER_SCRIPTS/install.sh source $HELPER_SCRIPTS/os.sh source $HELPER_SCRIPTS/etc-environment.sh -toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" -JAVA_VERSIONS_LIST=$(jq -r '.java.versions | .[]' $toolset) -DEFAULT_JDK_VERSION=$(jq -r '.java.default' $toolset) +JAVA_VERSIONS_LIST=$(get_toolset_value '.java.versions | .[]') +DEFAULT_JDK_VERSION=$(get_toolset_value '.java.default') # 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 - diff --git a/images/linux/scripts/installers/php.sh b/images/linux/scripts/installers/php.sh index a102c5451..10c6a2938 100644 --- a/images/linux/scripts/installers/php.sh +++ b/images/linux/scripts/installers/php.sh @@ -7,15 +7,14 @@ # Source the helpers for use with the script source $HELPER_SCRIPTS/etc-environment.sh source $HELPER_SCRIPTS/os.sh +source $HELPER_SCRIPTS/install.sh # add repository apt-add-repository ppa:ondrej/php -y apt-get update # Install PHP -toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" - -php_versions=$(jq -r '.php.versions[]' $toolset) +php_versions=$(get_toolset_value '.php.versions[]') for version in $php_versions; do echo "Installing PHP $version" diff --git a/images/linux/scripts/installers/pipx-packages.sh b/images/linux/scripts/installers/pipx-packages.sh index 447c29390..e37f15393 100644 --- a/images/linux/scripts/installers/pipx-packages.sh +++ b/images/linux/scripts/installers/pipx-packages.sh @@ -3,14 +3,14 @@ ## File: pipx-packages.sh ## Desc: Install tools via pipx ################################################################################ +source $HELPER_SCRIPTS/install.sh export PATH="$PATH:/opt/pipx_bin" -toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" -pipx_packages=$(jq -r ".pipx[] .package" $toolset) +pipx_packages=$(get_toolset_value ".pipx[] .package") 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 python_path="/opt/hostedtoolcache/Python/$python_version*/x64/bin/python$python_version" echo "Install $package into python $python_path" diff --git a/images/linux/scripts/installers/pypy.sh b/images/linux/scripts/installers/pypy.sh index f387a7fe7..826912c68 100644 --- a/images/linux/scripts/installers/pypy.sh +++ b/images/linux/scripts/installers/pypy.sh @@ -76,10 +76,7 @@ function InstallPyPy uri="https://downloads.python.org/pypy/" download_with_retries $uri "/tmp" "pypyUrls.html" compressed pypyVersions="$(cat /tmp/pypyUrls.html | grep 'linux64' | awk -v uri="$uri" -F'>|<' '{print uri$5}')" - -toolset="$INSTALLER_SCRIPT_FOLDER/toolset.json" -toolsetVersions=$(jq -r '.toolcache[] | select(.name | contains("PyPy")) | .versions[]' $toolset) - +toolsetVersions=$(get_toolset_value '.toolcache[] | select(.name | contains("PyPy")) | .versions[]') for toolsetVersion in $toolsetVersions; do latestMajorPyPyVersion=$(echo "${pypyVersions}" | grep -E "pypy${toolsetVersion}-v[0-9]+\.[0-9]+\.[0-9]+-" | head -1) diff --git a/images/linux/scripts/installers/ruby.sh b/images/linux/scripts/installers/ruby.sh index 75f7f0229..06583260e 100644 --- a/images/linux/scripts/installers/ruby.sh +++ b/images/linux/scripts/installers/ruby.sh @@ -13,10 +13,9 @@ sudo gem update --system apt-get install -y libz-dev openssl libssl-dev 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') -TOOLSET_VERSIONS=$(jq -r '.toolcache[] | select(.name | contains("Ruby")) | .versions[]' $toolset) -PLATFORM_VERSION=$(jq -r '.toolcache[] | select(.name | contains("Ruby")) | .platform_version' $toolset) +TOOLSET_VERSIONS=$(get_toolset_value '.toolcache[] | select(.name | contains("Ruby")) | .versions[]') +PLATFORM_VERSION=$(get_toolset_value '.toolcache[] | select(.name | contains("Ruby")) | .platform_version') RUBY_PATH="$AGENT_TOOLSDIRECTORY/Ruby" echo "Check if Ruby hostedtoolcache folder exist..."