[ubuntu] Refactor bash functions (#9055)

This commit is contained in:
Shamil Mubarakshin
2023-12-26 12:50:52 +01:00
committed by GitHub
parent d16bc5f120
commit 503ae89818
38 changed files with 191 additions and 224 deletions

View File

@@ -14,7 +14,7 @@ source $HELPER_SCRIPTS/etc-environment.sh
# automatic installs. If you are using this front-end, and require
# non-default answers to questions, you will need to preseed the
# debconf database
setEtcEnvironmentVariable "DEBIAN_FRONTEND" "noninteractive"
set_etc_environment_variable "DEBIAN_FRONTEND" "noninteractive"
# dpkg can be instructed not to ask for confirmation
# when replacing a configuration file (with the --force-confdef --force-confold options)

View File

@@ -9,15 +9,15 @@ source $HELPER_SCRIPTS/os.sh
source $HELPER_SCRIPTS/etc-environment.sh
# Set ImageVersion and ImageOS env variables
setEtcEnvironmentVariable "ImageVersion" "${IMAGE_VERSION}"
setEtcEnvironmentVariable "ImageOS" "${IMAGE_OS}"
set_etc_environment_variable "ImageVersion" "${IMAGE_VERSION}"
set_etc_environment_variable "ImageOS" "${IMAGE_OS}"
# Set the ACCEPT_EULA variable to Y value to confirm your acceptance of the End-User Licensing Agreement
setEtcEnvironmentVariable "ACCEPT_EULA" "Y"
set_etc_environment_variable "ACCEPT_EULA" "Y"
# This directory is supposed to be created in $HOME and owned by user(https://github.com/actions/runner-images/issues/491)
mkdir -p /etc/skel/.config/configstore
setEtcEnvironmentVariable "XDG_CONFIG_HOME" '$HOME/.config'
set_etc_environment_variable "XDG_CONFIG_HOME" '$HOME/.config'
# Change waagent entries to use /mnt for swapfile
sed -i 's/ResourceDisk.Format=n/ResourceDisk.Format=y/g' /etc/waagent.conf
@@ -30,7 +30,7 @@ sed -i 's/::1 ip6-localhost ip6-loopback/::1 localhost ip6-localhost ip6-loo
# Prepare directory and env variable for toolcache
AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
mkdir $AGENT_TOOLSDIRECTORY
setEtcEnvironmentVariable "AGENT_TOOLSDIRECTORY" "${AGENT_TOOLSDIRECTORY}"
set_etc_environment_variable "AGENT_TOOLSDIRECTORY" "${AGENT_TOOLSDIRECTORY}"
chmod -R 777 $AGENT_TOOLSDIRECTORY
# https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html
@@ -62,6 +62,6 @@ fi
# Disable to load providers
# https://github.com/microsoft/azure-pipelines-agent/issues/3834
if isUbuntu22; then
if is_ubuntu22; then
sed -i 's/openssl_conf = openssl_init/#openssl_conf = openssl_init/g' /etc/ssl/openssl.cnf
fi

View File

@@ -9,7 +9,7 @@ source $HELPER_SCRIPTS/etc-environment.sh
# Update /etc/environment to include /snap/bin in PATH
# because /etc/profile.d is ignored by `--norc` shell launch option
prependEtcEnvironmentPath "/snap/bin"
prepend_etc_environment_path "/snap/bin"
# Put snapd auto refresh on hold
# as it may generate too much traffic on Canonical's snap server

View File

@@ -20,7 +20,7 @@ chmod 755 $IMAGE_FOLDER
ENVPATH=$(grep 'PATH=' /etc/environment | head -n 1 | sed -z 's/^PATH=*//')
ENVPATH=${ENVPATH#"\""}
ENVPATH=${ENVPATH%"\""}
addEtcEnvironmentVariable "PATH" "${ENVPATH}"
add_etc_environment_variable "PATH" "${ENVPATH}"
echo "Updated /etc/environment: $(cat /etc/environment)"
# Сlean yarn and npm cache

View File

@@ -14,7 +14,7 @@ ACTION_ARCHIVE_CACHE_DIR=/opt/actionarchivecache
mkdir -p $ACTION_ARCHIVE_CACHE_DIR
chmod -R 777 $ACTION_ARCHIVE_CACHE_DIR
echo "Setting up ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE variable to ${ACTION_ARCHIVE_CACHE_DIR}"
setEtcEnvironmentVariable "ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE" "${ACTION_ARCHIVE_CACHE_DIR}"
set_etc_environment_variable "ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE" "${ACTION_ARCHIVE_CACHE_DIR}"
# Download latest release from github.com/actions/action-versions and untar to /opt/actionarchivecache
downloadUrl=$(resolve_github_release_asset_url "actions/action-versions" "endswith(\"action-versions.tar.gz\")" "latest")

View File

@@ -11,7 +11,7 @@ source $HELPER_SCRIPTS/install.sh
# Install Alibaba Cloud CLI
# Pin tool version on ubuntu20 due to issues with GLIBC_2.32 not available
if isUbuntu20; then
if is_ubuntu20; then
toolset_version=$(get_toolset_value '.aliyunCli.version')
download_url="https://github.com/aliyun/aliyun-cli/releases/download/v$toolset_version/aliyun-cli-linux-$toolset_version-amd64.tgz"
else
@@ -22,7 +22,7 @@ fi
archive_path=$(download_with_retry "$download_url")
# Supply chain security - Alibaba Cloud CLI
if isUbuntu20; then
if is_ubuntu20; then
external_hash=$(get_toolset_value '.aliyunCli.sha256')
else
external_hash=$(get_checksum_from_url "$hash_url" "aliyun-cli-linux.*amd64.tgz" "SHA256")

View File

@@ -36,10 +36,10 @@ get_full_ndk_version() {
ANDROID_ROOT=/usr/local/lib/android
ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager
setEtcEnvironmentVariable "ANDROID_SDK_ROOT" "${ANDROID_SDK_ROOT}"
set_etc_environment_variable "ANDROID_SDK_ROOT" "${ANDROID_SDK_ROOT}"
# ANDROID_HOME is deprecated, but older versions of Gradle rely on it
setEtcEnvironmentVariable "ANDROID_HOME" "${ANDROID_SDK_ROOT}"
set_etc_environment_variable "ANDROID_HOME" "${ANDROID_SDK_ROOT}"
# Create android sdk directory
mkdir -p ${ANDROID_SDK_ROOT}
@@ -87,10 +87,10 @@ ndk_default_full_version=$(get_full_ndk_version $android_ndk_major_default)
ndk_latest_full_version=$(get_full_ndk_version $android_ndk_major_latest)
ANDROID_NDK=${ANDROID_SDK_ROOT}/ndk/${ndk_default_full_version}
# ANDROID_NDK, ANDROID_NDK_HOME, and ANDROID_NDK_ROOT variables should be set as many customer builds depend on them https://github.com/actions/runner-images/issues/5879
setEtcEnvironmentVariable "ANDROID_NDK" "${ANDROID_NDK}"
setEtcEnvironmentVariable "ANDROID_NDK_HOME" "${ANDROID_NDK}"
setEtcEnvironmentVariable "ANDROID_NDK_ROOT" "${ANDROID_NDK}"
setEtcEnvironmentVariable "ANDROID_NDK_LATEST_HOME" "${ANDROID_SDK_ROOT}/ndk/${ndk_latest_full_version}"
set_etc_environment_variable "ANDROID_NDK" "${ANDROID_NDK}"
set_etc_environment_variable "ANDROID_NDK_HOME" "${ANDROID_NDK}"
set_etc_environment_variable "ANDROID_NDK_ROOT" "${ANDROID_NDK}"
set_etc_environment_variable "ANDROID_NDK_LATEST_HOME" "${ANDROID_SDK_ROOT}/ndk/${ndk_latest_full_version}"
# Prepare components for installation
extras=$(get_toolset_value '.android.extra_list[] | "extras;" + .')
@@ -119,6 +119,6 @@ sed -i "2i export JAVA_HOME=${JAVA_HOME_8_X64}" ${ANDROID_SDK_ROOT}/tools/bin/sd
# Add required permissions
chmod -R a+rwx ${ANDROID_SDK_ROOT}
reloadEtcEnvironment
reload_etc_environment
invoke_tests "Android"

View File

@@ -10,7 +10,7 @@ source $HELPER_SCRIPTS/etc-environment.sh
# AZURE_EXTENSION_DIR shell variable defines where modules are installed
# https://docs.microsoft.com/en-us/cli/azure/azure-cli-extensions-overview
export AZURE_EXTENSION_DIR=/opt/az/azcliextensions
setEtcEnvironmentVariable "AZURE_EXTENSION_DIR" "${AZURE_EXTENSION_DIR}"
set_etc_environment_variable "AZURE_EXTENSION_DIR" "${AZURE_EXTENSION_DIR}"
# install azure devops Cli extension
az extension add -n azure-devops

View File

@@ -7,14 +7,14 @@
# Source the helpers for use with the script
source $HELPER_SCRIPTS/install.sh
function InstallClang {
install_clang() {
local version=$1
echo "Installing clang-$version..."
apt-get install -y "clang-$version" "lldb-$version" "lld-$version" "clang-format-$version" "clang-tidy-$version"
}
function SetDefaultClang {
set_default_clang() {
local version=$1
echo "Make Clang ${version} default"
@@ -30,11 +30,11 @@ default_clang_version=$(get_toolset_value '.clang.default_version')
for version in ${versions[*]}; do
if [[ $version != $default_clang_version ]]; then
InstallClang $version
install_clang $version
fi
done
InstallClang $default_clang_version
SetDefaultClang $default_clang_version
install_clang $default_clang_version
set_default_clang $default_clang_version
invoke_tests "Tools" "clang"

View File

@@ -10,14 +10,14 @@ source $HELPER_SCRIPTS/os.sh
# pin podman due to https://github.com/actions/runner-images/issues/7753
# https://bugs.launchpad.net/ubuntu/+source/libpod/+bug/2024394
#
if isUbuntu20; then
if is_ubuntu20; then
install_packages=(podman buildah skopeo)
else
install_packages=(podman=3.4.4+ds1-1ubuntu1 buildah skopeo)
fi
# Packages is available in the official Ubuntu upstream starting from Ubuntu 21
if isUbuntu20; then
if is_ubuntu20; then
REPO_URL="https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable"
source /etc/os-release
sh -c "echo 'deb ${REPO_URL}/x${NAME}_${VERSION_ID}/ /' > /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list"
@@ -31,7 +31,7 @@ apt-get -y install ${install_packages[@]}
mkdir -p /etc/containers
printf "[registries.search]\nregistries = ['docker.io', 'quay.io']\n" | tee /etc/containers/registries.conf
if isUbuntu20; then
if is_ubuntu20; then
# Remove source repo
rm /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
# Document source repo

View File

@@ -14,7 +14,7 @@ gpg_key="/usr/share/keyrings/docker.gpg"
repo_path="/etc/apt/sources.list.d/docker.list"
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o $gpg_key
echo "deb [arch=amd64 signed-by=$gpg_key] $repo_url $(getOSVersionLabel) stable" > $repo_path
echo "deb [arch=amd64 signed-by=$gpg_key] $repo_url $(get_os_version_label) stable" > $repo_path
apt-get update
apt-get install --no-install-recommends docker-ce docker-ce-cli containerd.io docker-buildx-plugin

View File

@@ -31,7 +31,7 @@ apt-get update
for latest_package in ${LATEST_DOTNET_PACKAGES[@]}; do
echo "Determing if .NET Core ($latest_package) is installed"
if ! IsPackageInstalled $latest_package; then
if ! dpkg -S $latest_package &> /dev/null; then
echo "Could not find .NET Core ($latest_package), installing..."
apt-get install $latest_package -y
else
@@ -82,10 +82,10 @@ find . -name "*.tar.gz" | parallel --halt soon,fail=1 'extract_dotnet_sdk {}'
# NuGetFallbackFolder at /usr/share/dotnet/sdk/NuGetFallbackFolder is warmed up by smoke test
# Additional FTE will just copy to ~/.dotnet/NuGet which provides no benefit on a fungible machine
setEtcEnvironmentVariable DOTNET_SKIP_FIRST_TIME_EXPERIENCE 1
setEtcEnvironmentVariable DOTNET_NOLOGO 1
setEtcEnvironmentVariable DOTNET_MULTILEVEL_LOOKUP 0
prependEtcEnvironmentPath '$HOME/.dotnet/tools'
set_etc_environment_variable DOTNET_SKIP_FIRST_TIME_EXPERIENCE 1
set_etc_environment_variable DOTNET_NOLOGO 1
set_etc_environment_variable DOTNET_MULTILEVEL_LOOKUP 0
prepend_etc_environment_path '$HOME/.dotnet/tools'
# install dotnet tools
for dotnet_tool in ${DOTNET_TOOLS[@]}; do

View File

@@ -19,7 +19,7 @@ repo_path="/etc/apt/sources.list.d/mozillateam-ubuntu-ppa-focal.list"
# Install Firefox
curl -fsSL "https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x${gpg_fingerprint}" | sudo gpg --dearmor -o $gpg_key
echo "deb $repo_url $(getOSVersionLabel) main" > $repo_path
echo "deb $repo_url $(get_os_version_label) main" > $repo_path
apt-get update
apt-get install --target-release 'o=LP-PPA-mozillateam' -y firefox
@@ -44,6 +44,6 @@ tar -xzf "$driver_archive_path" -C $GECKODRIVER_DIR
chmod +x $GECKODRIVER_BIN
ln -s "$GECKODRIVER_BIN" /usr/bin/
setEtcEnvironmentVariable "GECKOWEBDRIVER" "${GECKODRIVER_DIR}"
set_etc_environment_variable "GECKOWEBDRIVER" "${GECKODRIVER_DIR}"
invoke_tests "Browsers" "Firefox"

View File

@@ -8,13 +8,6 @@
source $HELPER_SCRIPTS/os.sh
source $HELPER_SCRIPTS/install.sh
function InstallGcc {
version=$1
echo "Installing $version..."
apt-get install $version -y
}
# Install GNU C++ compiler
add-apt-repository ppa:ubuntu-toolchain-r/test -y
apt-get update -y
@@ -22,7 +15,8 @@ apt-get update -y
versions=$(get_toolset_value '.gcc.versions[]')
for version in ${versions[*]}; do
InstallGcc $version
echo "Installing $version..."
apt-get install $version -y
done
invoke_tests "Tools" "gcc"

View File

@@ -6,22 +6,15 @@
source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/os.sh
function InstallFortran {
version=$1
echo "Installing $version..."
apt-get install $version -y
}
# Install GNU Fortran compiler
add-apt-repository ppa:ubuntu-toolchain-r/test -y
apt-get update -y
versions=$(get_toolset_value '.gfortran.versions[]')
for version in ${versions[*]}
do
InstallFortran $version
for version in ${versions[*]}; do
echo "Installing $version..."
apt-get install $version -y
done
invoke_tests "Tools" "gfortran"

View File

@@ -8,35 +8,37 @@
source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/etc-environment.sh
function GetChromiumRevision {
CHROME_REVISION=$1
get_chromium_revision() {
local chrome_revision=$1
# Take the first part of the revision variable to search not only for a specific version,
# but also for similar ones, so that we can get a previous one if the required revision is not found
CHROME_REVISION_PREFIX=${CHROME_REVISION:0:${#CHROME_REVISION}/2+1}
chrome_revision_prefix=${chrome_revision:0:${#chrome_revision}/2+1}
SEARCH_URL="https://www.googleapis.com/storage/v1/b/chromium-browser-snapshots/o?delimiter=/&prefix=Linux_x64"
# Revision can include a hash instead of a number. Need to filter it out https://github.com/actions/runner-images/issues/5256
REVISIONS_AVAILABLE=$(curl -s $SEARCH_URL/${CHROME_REVISION_PREFIX} | jq -r '.prefixes[]' | grep -E "Linux_x64\/[0-9]+\/"| cut -d "/" -f 2 | sort --version-sort)
revisions_available=$(curl -s $SEARCH_URL/${chrome_revision_prefix} | jq -r '.prefixes[]' | grep -E "Linux_x64\/[0-9]+\/"| cut -d "/" -f 2 | sort --version-sort)
# If required Chromium revision is not found in the list
# we should have to decrement the revision number until we find one.
# This is mentioned in the documentation we use for this installation:
# https://www.chromium.org/getting-involved/download-chromium
LATEST_VALID_REVISION=$(echo $REVISIONS_AVAILABLE | cut -f 1 -d " ")
for REVISION in $REVISIONS_AVAILABLE; do
if [ "$CHROME_REVISION" -lt "$REVISION" ]; then
latest_valid_revision=$(echo $revisions_available | cut -f 1 -d " ")
for revision in $revisions_available; do
if [ "$chrome_revision" -lt "$revision" ]; then
break
fi
LATEST_VALID_REVISION=$REVISION
latest_valid_revision=$revision
done
echo $LATEST_VALID_REVISION
echo $latest_valid_revision
}
# Download and install Google Chrome
CHROME_DEB_URL="https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"
CHROME_DEB_PATH=$(download_with_retry "$CHROME_DEB_URL")
apt install "$CHROME_DEB_PATH" -f
setEtcEnvironmentVariable "CHROME_BIN" "/usr/bin/google-chrome"
set_etc_environment_variable "CHROME_BIN" "/usr/bin/google-chrome"
# Remove Google Chrome repo
rm -f /etc/cron.daily/google-chrome /etc/apt/sources.list.d/google-chrome.list /etc/apt/sources.list.d/google-chrome.list.save
@@ -63,11 +65,11 @@ unzip -qq "$driver_archive_path" -d /usr/local/share
chmod +x $CHROMEDRIVER_BIN
ln -s "$CHROMEDRIVER_BIN" /usr/bin/
setEtcEnvironmentVariable "CHROMEWEBDRIVER" "${CHROMEDRIVER_DIR}"
set_etc_environment_variable "CHROMEWEBDRIVER" "${CHROMEDRIVER_DIR}"
# Download and unpack Chromium
CHROME_REVISION=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].revision')
CHROMIUM_REVISION=$(GetChromiumRevision $CHROME_REVISION)
CHROMIUM_REVISION=$(get_chromium_revision $CHROME_REVISION)
CHROMIUM_URL="https://www.googleapis.com/download/storage/v1/b/chromium-browser-snapshots/o/Linux_x64%2F${CHROMIUM_REVISION}%2Fchrome-linux.zip?alt=media"
CHROMIUM_DIR="/usr/local/share/chromium"
CHROMIUM_BIN="${CHROMIUM_DIR}/chrome-linux/chrome"

View File

@@ -13,13 +13,13 @@ export BOOTSTRAP_HASKELL_INSTALL_NO_STACK_HOOK=1
export GHCUP_INSTALL_BASE_PREFIX=/usr/local
export BOOTSTRAP_HASKELL_GHC_VERSION=0
ghcup_bin=$GHCUP_INSTALL_BASE_PREFIX/.ghcup/bin
setEtcEnvironmentVariable "BOOTSTRAP_HASKELL_NONINTERACTIVE" $BOOTSTRAP_HASKELL_NONINTERACTIVE
setEtcEnvironmentVariable "GHCUP_INSTALL_BASE_PREFIX" $GHCUP_INSTALL_BASE_PREFIX
set_etc_environment_variable "BOOTSTRAP_HASKELL_NONINTERACTIVE" $BOOTSTRAP_HASKELL_NONINTERACTIVE
set_etc_environment_variable "GHCUP_INSTALL_BASE_PREFIX" $GHCUP_INSTALL_BASE_PREFIX
# Install GHCup
curl --proto '=https' --tlsv1.2 -fsSL https://get-ghcup.haskell.org | sh > /dev/null 2>&1 || true
export PATH="$ghcup_bin:$PATH"
prependEtcEnvironmentPath $ghcup_bin
prepend_etc_environment_path $ghcup_bin
availableVersions=$(ghcup list -t ghc -r | grep -v "prerelease" | awk '{print $2}')

View File

@@ -15,12 +15,12 @@ source $HELPER_SCRIPTS/install.sh
# Invoke shellenv to make brew available during runnig session
eval "$(/home/linuxbrew/.linuxbrew/bin/brew shellenv)"
setEtcEnvironmentVariable HOMEBREW_NO_AUTO_UPDATE 1
setEtcEnvironmentVariable HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS 3650
set_etc_environment_variable HOMEBREW_NO_AUTO_UPDATE 1
set_etc_environment_variable HOMEBREW_CLEANUP_PERIODIC_FULL_DAYS 3650
# Validate the installation ad hoc
echo "Validate the installation reloading /etc/environment"
reloadEtcEnvironment
reload_etc_environment
gfortran=$(brew --prefix)/bin/gfortran
# Remove gfortran symlink, not to conflict with system gfortran

View File

@@ -8,71 +8,63 @@ source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/os.sh
source $HELPER_SCRIPTS/etc-environment.sh
createJavaEnvironmentalVariable() {
local JAVA_VERSION=$1
local DEFAULT=$2
create_java_environment_variable() {
local java_version=$1
local default=$2
local INSTALL_PATH_PATTERN="/usr/lib/jvm/temurin-${JAVA_VERSION}-jdk-amd64"
local install_path_pattern="/usr/lib/jvm/temurin-${java_version}-jdk-amd64"
if [[ ${DEFAULT} == "True" ]]; then
echo "Setting up JAVA_HOME variable to ${INSTALL_PATH_PATTERN}"
setEtcEnvironmentVariable "JAVA_HOME" "${INSTALL_PATH_PATTERN}"
if [[ ${default} == "True" ]]; then
echo "Setting up JAVA_HOME variable to ${install_path_pattern}"
set_etc_environment_variable "JAVA_HOME" "${install_path_pattern}"
echo "Setting up default symlink"
update-java-alternatives -s ${INSTALL_PATH_PATTERN}
update-java-alternatives -s ${install_path_pattern}
fi
echo "Setting up JAVA_HOME_${JAVA_VERSION}_X64 variable to ${INSTALL_PATH_PATTERN}"
setEtcEnvironmentVariable "JAVA_HOME_${JAVA_VERSION}_X64" "${INSTALL_PATH_PATTERN}"
echo "Setting up JAVA_HOME_${java_version}_X64 variable to ${install_path_pattern}"
set_etc_environment_variable "JAVA_HOME_${java_version}_X64" "${install_path_pattern}"
}
enableRepositories() {
osLabel=$(getOSVersionLabel)
# Add Addoptium PPA
# apt-key is deprecated, dearmor and add manually
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor > /usr/share/keyrings/adoptium.gpg
echo "deb [signed-by=/usr/share/keyrings/adoptium.gpg] https://packages.adoptium.net/artifactory/deb/ $osLabel main" > /etc/apt/sources.list.d/adoptium.list
}
installOpenJDK() {
local JAVA_VERSION=$1
install_open_jdk() {
local java_version=$1
# Install Java from PPA repositories.
apt-get -y install temurin-${JAVA_VERSION}-jdk=\*
javaVersionPath="/usr/lib/jvm/temurin-${JAVA_VERSION}-jdk-amd64"
apt-get -y install temurin-${java_version}-jdk=\*
java_version_path="/usr/lib/jvm/temurin-${java_version}-jdk-amd64"
JAVA_TOOLCACHE_PATH="${AGENT_TOOLSDIRECTORY}/Java_Temurin-Hotspot_jdk"
java_toolcache_path="${AGENT_TOOLSDIRECTORY}/Java_Temurin-Hotspot_jdk"
fullJavaVersion=$(cat "${javaVersionPath}/release" | grep "^SEMANTIC" | cut -d "=" -f 2 | tr -d "\"" | tr "+" "-")
full_java_version=$(cat "${java_version_path}/release" | grep "^SEMANTIC" | cut -d "=" -f 2 | tr -d "\"" | tr "+" "-")
# If there is no semver in java release, then extract java version from -fullversion
[[ -z ${fullJavaVersion} ]] && fullJavaVersion=$(${javaVersionPath}/bin/java -fullversion 2>&1 | tr -d "\"" | tr "+" "-" | awk '{print $4}')
[[ -z ${full_java_version} ]] && full_java_version=$(${java_version_path}/bin/java -fullversion 2>&1 | tr -d "\"" | tr "+" "-" | awk '{print $4}')
# Convert non valid semver like 11.0.14.1-9 -> 11.0.14-9
# https://github.com/adoptium/temurin-build/issues/2248
[[ ${fullJavaVersion} =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ ]] && fullJavaVersion=$(echo $fullJavaVersion | sed -E 's/\.[0-9]+-/-/')
[[ ${full_java_version} =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+ ]] && full_java_version=$(echo $full_java_version | sed -E 's/\.[0-9]+-/-/')
# When version string is too short, add extra ".0" to make it valid semver
[[ ${fullJavaVersion} =~ ^[0-9]+- ]] && fullJavaVersion=$(echo $fullJavaVersion | sed -E 's/-/.0-/')
[[ ${fullJavaVersion} =~ ^[0-9]+\.[0-9]+- ]] && fullJavaVersion=$(echo $fullJavaVersion | sed -E 's/-/.0-/')
[[ ${full_java_version} =~ ^[0-9]+- ]] && full_java_version=$(echo $full_java_version | sed -E 's/-/.0-/')
[[ ${full_java_version} =~ ^[0-9]+\.[0-9]+- ]] && full_java_version=$(echo $full_java_version | sed -E 's/-/.0-/')
javaToolcacheVersionPath="${JAVA_TOOLCACHE_PATH}/${fullJavaVersion}"
echo "Java ${JAVA_VERSION} Toolcache Version Path: ${javaToolcacheVersionPath}"
mkdir -p "${javaToolcacheVersionPath}"
java_toolcache_version_path="${java_toolcache_path}/${full_java_version}"
echo "Java ${java_version} Toolcache Version Path: ${java_toolcache_version_path}"
mkdir -p "${java_toolcache_version_path}"
# Create a complete file
touch "${javaToolcacheVersionPath}/x64.complete"
touch "${java_toolcache_version_path}/x64.complete"
# Create symlink for Java
ln -s ${javaVersionPath} "${javaToolcacheVersionPath}/x64"
ln -s ${java_version_path} "${java_toolcache_version_path}/x64"
# add extra permissions to be able execute command without sudo
chmod -R 777 /usr/lib/jvm
}
# Fetch repositories data
enableRepositories
# Add Addoptium PPA
# apt-key is deprecated, dearmor and add manually
wget -qO - https://packages.adoptium.net/artifactory/api/gpg/key/public | gpg --dearmor > /usr/share/keyrings/adoptium.gpg
echo "deb [signed-by=/usr/share/keyrings/adoptium.gpg] https://packages.adoptium.net/artifactory/deb/ $(get_os_version_label) main" > /etc/apt/sources.list.d/adoptium.list
# Get all the updates from enabled repositories.
apt-get update
@@ -81,19 +73,19 @@ defaultVersion=$(get_toolset_value '.java.default')
jdkVersionsToInstall=($(get_toolset_value ".java.versions[]"))
for jdkVersionToInstall in ${jdkVersionsToInstall[@]}; do
installOpenJDK ${jdkVersionToInstall}
install_open_jdk ${jdkVersionToInstall}
if [[ ${jdkVersionToInstall} == ${defaultVersion} ]]
then
createJavaEnvironmentalVariable ${jdkVersionToInstall} True
create_java_environment_variable ${jdkVersionToInstall} True
else
createJavaEnvironmentalVariable ${jdkVersionToInstall} False
create_java_environment_variable ${jdkVersionToInstall} False
fi
done
# Install Ant
apt-get install -y --no-install-recommends ant ant-optional
setEtcEnvironmentVariable "ANT_HOME" "/usr/share/ant"
set_etc_environment_variable "ANT_HOME" "/usr/share/ant"
# Install Maven
mavenVersion=$(get_toolset_value '.java.maven')
@@ -114,7 +106,7 @@ gradle_archive_path=$(download_with_retry "$gradleDownloadUrl")
unzip -qq -d /usr/share "$gradle_archive_path"
ln -s /usr/share/gradle-"${gradleLatestVersion}"/bin/gradle /usr/bin/gradle
gradle_home_dir=$(find /usr/share -depth -maxdepth 1 -name "gradle*")
setEtcEnvironmentVariable "GRADLE_HOME" "${gradle_home_dir}"
set_etc_environment_variable "GRADLE_HOME" "${gradle_home_dir}"
# Delete java repositories and keys
rm -f /etc/apt/sources.list.d/adoptium.list
@@ -122,5 +114,5 @@ rm -f /etc/apt/sources.list.d/zulu.list
rm -f /usr/share/keyrings/adoptium.gpg
rm -f /usr/share/keyrings/zulu.gpg
reloadEtcEnvironment
reload_etc_environment
invoke_tests "Java"

View File

@@ -16,7 +16,7 @@ export LEIN_HOME=/usr/local/lib/lein
lein
LEIN_JAR=$(find $LEIN_HOME -name "leiningen-*-standalone.jar")
setEtcEnvironmentVariable "LEIN_JAR" "${LEIN_JAR}"
setEtcEnvironmentVariable "LEIN_HOME" "${LEIN_HOME}"
set_etc_environment_variable "LEIN_JAR" "${LEIN_JAR}"
set_etc_environment_variable "LEIN_HOME" "${LEIN_HOME}"
invoke_tests "Tools" "Leiningen"

View File

@@ -46,6 +46,6 @@ unzip -qq "$EDGEDRIVER_ARCHIVE_PATH" -d "$EDGEDRIVER_DIR"
chmod +x $EDGEDRIVER_BIN
ln -s $EDGEDRIVER_BIN /usr/bin
setEtcEnvironmentVariable "EDGEWEBDRIVER" "${EDGEDRIVER_DIR}"
set_etc_environment_variable "EDGEWEBDRIVER" "${EDGEDRIVER_DIR}"
invoke_tests "Browsers" "Edge"

View File

@@ -14,7 +14,7 @@ curl -fsSL https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
&& rm miniconda.sh
CONDA=/usr/share/miniconda
setEtcEnvironmentVariable "CONDA" "${CONDA}"
set_etc_environment_variable "CONDA" "${CONDA}"
ln -s $CONDA/bin/conda /usr/bin/conda

View File

@@ -9,7 +9,7 @@ source $HELPER_SCRIPTS/os.sh
source $HELPER_SCRIPTS/install.sh
REPO_URL="https://repo.mongodb.org/apt/ubuntu"
osLabel=$(getOSVersionLabel)
osLabel=$(get_os_version_label)
toolsetVersion=$(get_toolset_value '.mongodb.version')
# Install Mongo DB

View File

@@ -9,7 +9,7 @@ source $HELPER_SCRIPTS/os.sh
LSB_CODENAME=$(lsb_release -cs)
# There are no packages for Ubuntu 22 in the repo, but developers confirmed that packages from Ubuntu 20 should work
if isUbuntu22; then
if is_ubuntu22; then
LSB_CODENAME="focal"
fi

View File

@@ -11,7 +11,7 @@ export NVM_DIR="/etc/skel/.nvm"
mkdir $NVM_DIR
VERSION=$(curl -fsSL https://api.github.com/repos/nvm-sh/nvm/releases/latest | jq -r '.tag_name')
curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/$VERSION/install.sh | bash
setEtcEnvironmentVariable "NVM_DIR" '$HOME/.nvm'
set_etc_environment_variable "NVM_DIR" '$HOME/.nvm'
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm' | tee -a /etc/skel/.bash_profile
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

View File

@@ -11,7 +11,7 @@ source $HELPER_SCRIPTS/install.sh
# add repository for old Ubuntu images
# details in thread: https://github.com/actions/runner-images/issues/6331
if isUbuntu20; then
if is_ubuntu20; then
apt-add-repository ppa:ondrej/php -y
apt-get update
fi
@@ -94,7 +94,7 @@ sudo mv composer.phar /usr/bin/composer
php -r "unlink('composer-setup.php');"
# Add composer bin folder to path
prependEtcEnvironmentPath '$HOME/.config/composer/vendor/bin'
prepend_etc_environment_path '$HOME/.config/composer/vendor/bin'
#Create composer folder for user to preserve folder permissions
mkdir -p /etc/skel/.composer
@@ -106,7 +106,7 @@ mv phpunit /usr/local/bin/phpunit
# ubuntu 20.04 libzip-dev is libzip5 based and is not compatible libzip-dev of ppa:ondrej/php
# see https://github.com/actions/runner-images/issues/1084
if isUbuntu20; then
if is_ubuntu20; then
rm /etc/apt/sources.list.d/ondrej-*.list
apt-get update
fi

View File

@@ -12,7 +12,7 @@ REPO_URL="https://apt.postgresql.org/pub/repos/apt/"
# Preparing repo for PostgreSQL
wget -qO - https://www.postgresql.org/media/keys/ACCC4CF8.asc | gpg --dearmor > /usr/share/keyrings/postgresql.gpg
echo "deb [signed-by=/usr/share/keyrings/postgresql.gpg] $REPO_URL $(getOSVersionLabel)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
echo "deb [signed-by=/usr/share/keyrings/postgresql.gpg] $REPO_URL $(get_os_version_label)-pgdg main" > /etc/apt/sources.list.d/pgdg.list
# Fetch PostgreSQL version to install from the toolset
toolsetVersion=$(get_toolset_value '.postgresql.version')

View File

@@ -7,70 +7,69 @@
source $HELPER_SCRIPTS/install.sh
# This function installs PyPy using the specified arguments:
# $1=PACKAGE_URL
function InstallPyPy
{
PACKAGE_URL=$1
# $1=package_url
install_pypy() {
local package_url=$1
PACKAGE_TAR_NAME=$(echo "$PACKAGE_URL" | awk -F/ '{print $NF}')
PACKAGE_NAME=${PACKAGE_TAR_NAME/.tar.bz2/}
package_tar_name=$(echo "$package_url" | awk -F/ '{print $NF}')
package_name=${package_tar_name/.tar.bz2/}
echo "Downloading tar archive '$PACKAGE_NAME'"
PACKAGE_TAR_TEMP_PATH=$(download_with_retry $PACKAGE_URL)
echo "Downloading tar archive '$package_name'"
package_tar_temp_path=$(download_with_retry $package_url)
echo "Expand '$PACKAGE_NAME' to the /tmp folder"
tar xf "$PACKAGE_TAR_TEMP_PATH" -C /tmp
echo "Expand '$package_name' to the /tmp folder"
tar xf "$package_tar_temp_path" -C /tmp
# Get Python version
MAJOR_VERSION=$(echo ${PACKAGE_NAME/pypy/} | cut -d. -f1)
PYTHON_MAJOR="python$MAJOR_VERSION"
major_version=$(echo ${package_name/pypy/} | cut -d. -f1)
python_major="python$major_version"
if [ $MAJOR_VERSION != 2 ]; then
PYPY_MAJOR="pypy$MAJOR_VERSION"
if [ $major_version != 2 ]; then
pypy_major="pypy$major_version"
else
PYPY_MAJOR="pypy"
pypy_major="pypy"
fi
PACKAGE_TEMP_FOLDER="/tmp/$PACKAGE_NAME"
PYTHON_FULL_VERSION=$("$PACKAGE_TEMP_FOLDER/bin/$PYPY_MAJOR" -c "import sys;print('{}.{}.{}'.format(sys.version_info[0],sys.version_info[1],sys.version_info[2]))")
PYPY_FULL_VERSION=$("$PACKAGE_TEMP_FOLDER/bin/$PYPY_MAJOR" -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))")
echo "Put '$PYPY_FULL_VERSION' to PYPY_VERSION file"
echo $PYPY_FULL_VERSION > "$PACKAGE_TEMP_FOLDER/PYPY_VERSION"
package_temp_folder="/tmp/$package_name"
python_full_version=$("$package_temp_folder/bin/$pypy_major" -c "import sys;print('{}.{}.{}'.format(sys.version_info[0],sys.version_info[1],sys.version_info[2]))")
pypy_full_version=$("$package_temp_folder/bin/$pypy_major" -c "import sys;print('{}.{}.{}'.format(*sys.pypy_version_info[0:3]))")
echo "Put '$pypy_full_version' to PYPY_VERSION file"
echo $pypy_full_version > "$package_temp_folder/PYPY_VERSION"
# PyPy folder structure
PYPY_TOOLCACHE_PATH=$AGENT_TOOLSDIRECTORY/PyPy
PYPY_TOOLCACHE_VERSION_PATH=$PYPY_TOOLCACHE_PATH/$PYTHON_FULL_VERSION
PYPY_TOOLCACHE_VERSION_ARCH_PATH=$PYPY_TOOLCACHE_VERSION_PATH/x64
pypy_toolcache_path=$AGENT_TOOLSDIRECTORY/PyPy
pypy_toolcache_version_path=$pypy_toolcache_path/$python_full_version
pypy_toolcache_version_arch_path=$pypy_toolcache_version_path/x64
echo "Check if PyPy hostedtoolcache folder exist..."
if [ ! -d $PYPY_TOOLCACHE_PATH ]; then
mkdir -p $PYPY_TOOLCACHE_PATH
if [ ! -d $pypy_toolcache_path ]; then
mkdir -p $pypy_toolcache_path
fi
echo "Create PyPy '$PYPY_TOOLCACHE_VERSION_PATH' folder"
mkdir $PYPY_TOOLCACHE_VERSION_PATH
echo "Create PyPy '$pypy_toolcache_version_path' folder"
mkdir $pypy_toolcache_version_path
echo "Move PyPy '$PACKAGE_TEMP_FOLDER' binaries to '$PYPY_TOOLCACHE_VERSION_ARCH_PATH' folder"
mv $PACKAGE_TEMP_FOLDER $PYPY_TOOLCACHE_VERSION_ARCH_PATH
echo "Move PyPy '$package_temp_folder' binaries to '$pypy_toolcache_version_arch_path' folder"
mv $package_temp_folder $pypy_toolcache_version_arch_path
echo "Create additional symlinks (Required for UsePythonVersion Azure DevOps task)"
cd $PYPY_TOOLCACHE_VERSION_ARCH_PATH/bin
cd $pypy_toolcache_version_arch_path/bin
# Starting from PyPy 7.3.4 these links are already included in the package
[ -f ./$PYTHON_MAJOR ] || ln -s $PYPY_MAJOR $PYTHON_MAJOR
[ -f ./python ] || ln -s $PYTHON_MAJOR python
[ -f ./$python_major ] || ln -s $pypy_major $python_major
[ -f ./python ] || ln -s $python_major python
chmod +x ./python ./$PYTHON_MAJOR
chmod +x ./python ./$python_major
echo "Install latest Pip"
./python -m ensurepip
./python -m pip install --ignore-installed pip
echo "Create complete file"
touch $PYPY_TOOLCACHE_VERSION_PATH/x64.complete
touch $pypy_toolcache_version_path/x64.complete
echo "Remove '$PACKAGE_TAR_TEMP_PATH'"
rm -f $PACKAGE_TAR_TEMP_PATH
echo "Remove '$package_tar_temp_path'"
rm -f $package_tar_temp_path
}
# Installation PyPy
@@ -87,7 +86,7 @@ for toolsetVersion in $toolsetVersions; do
exit 1
fi
InstallPyPy $latestMajorPyPyVersion
install_pypy $latestMajorPyPyVersion
done
chown -R "$SUDO_USER:$SUDO_USER" "$AGENT_TOOLSDIRECTORY/PyPy"

View File

@@ -19,9 +19,9 @@ export PIPX_HOME=/opt/pipx
python3 -m pip install pipx
python3 -m pipx ensurepath
# Update /etc/environment
setEtcEnvironmentVariable "PIPX_BIN_DIR" $PIPX_BIN_DIR
setEtcEnvironmentVariable "PIPX_HOME" $PIPX_HOME
prependEtcEnvironmentPath $PIPX_BIN_DIR
set_etc_environment_variable "PIPX_BIN_DIR" $PIPX_BIN_DIR
set_etc_environment_variable "PIPX_HOME" $PIPX_HOME
prepend_etc_environment_path $PIPX_BIN_DIR
# Test pipx
if ! command -v pipx; then
echo "pipx was not installed or not found on PATH"
@@ -29,6 +29,6 @@ if ! command -v pipx; then
fi
# Adding this dir to PATH will make installed pip commands are immediately available.
prependEtcEnvironmentPath '$HOME/.local/bin'
prepend_etc_environment_path '$HOME/.local/bin'
invoke_tests "Tools" "Python"

View File

@@ -8,7 +8,7 @@
source $HELPER_SCRIPTS/os.sh
# install R
osLabel=$(getOSVersionLabel)
osLabel=$(get_os_version_label)
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | gpg --dearmor > /usr/share/keyrings/rlang.gpg
echo "deb [signed-by=/usr/share/keyrings/rlang.gpg] https://cloud.r-project.org/bin/linux/ubuntu $osLabel-cran40/" > /etc/apt/sources.list.d/rlang.list

View File

@@ -19,7 +19,7 @@ source $CARGO_HOME/env
# Install common tools
rustup component add rustfmt clippy
if isUbuntu22; then
if is_ubuntu22; then
cargo install bindgen-cli cbindgen cargo-audit cargo-outdated
else
cargo install --locked bindgen-cli cbindgen cargo-audit cargo-outdated
@@ -29,6 +29,6 @@ fi
rm -rf ${CARGO_HOME}/registry/*
# Update /etc/environemnt
prependEtcEnvironmentPath '$HOME/.cargo/bin'
prepend_etc_environment_path '$HOME/.cargo/bin'
invoke_tests "Tools" "Rust"

View File

@@ -19,6 +19,6 @@ SELENIUM_FULL_VERSION=$(echo $SELENIUM_DOWNLOAD_URL | awk -F"selenium-server-|.j
touch "/usr/share/java/selenium-server-$SELENIUM_FULL_VERSION"
# Add SELENIUM_JAR_PATH environment variable
setEtcEnvironmentVariable "SELENIUM_JAR_PATH" "$SELENIUM_JAR_PATH"
set_etc_environment_variable "SELENIUM_JAR_PATH" "$SELENIUM_JAR_PATH"
invoke_tests "Tools" "Selenium"

View File

@@ -9,7 +9,7 @@ source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/os.sh
# Install libssl1.1 dependency
if isUbuntu22; then
if is_ubuntu22; then
libssl_deb_path=$(download_with_retry "http://security.ubuntu.com/ubuntu/pool/main/o/openssl/libssl1.1_1.1.1f-1ubuntu2.20_amd64.deb")
libssl_hash="0b3251aee55db6e20d02f4b9a2b703c9874a85ab6a20b12f4870f52f91633d37"
use_checksum_comparison "$libssl_deb_path" "$libssl_hash"

View File

@@ -42,6 +42,6 @@ ln -s "$SWIFT_BIN_ROOT/swift" /usr/local/bin/swift
ln -s "$SWIFT_BIN_ROOT/swiftc" /usr/local/bin/swiftc
ln -s "$SWIFT_LIB_ROOT/libsourcekitdInProc.so" /usr/local/lib/libsourcekitdInProc.so
setEtcEnvironmentVariable "SWIFT_PATH" "${SWIFT_BIN_ROOT}"
set_etc_environment_variable "SWIFT_PATH" "${SWIFT_BIN_ROOT}"
invoke_tests "Common" "Swift"

View File

@@ -9,7 +9,7 @@ source $HELPER_SCRIPTS/etc-environment.sh
# Set env variable for vcpkg
VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg
setEtcEnvironmentVariable "VCPKG_INSTALLATION_ROOT" "${VCPKG_INSTALLATION_ROOT}"
set_etc_environment_variable "VCPKG_INSTALLATION_ROOT" "${VCPKG_INSTALLATION_ROOT}"
# Install vcpkg
git clone https://github.com/Microsoft/vcpkg $VCPKG_INSTALLATION_ROOT

View File

@@ -8,68 +8,67 @@
# values containg slashes (i.e. directory path)
# The values containing '%' will break the functions
getEtcEnvironmentVariable () {
variable_name="$1"
get_etc_environment_variable() {
local variable_name=$1
# remove `variable_name=` and possible quotes from the line
grep "^${variable_name}=" /etc/environment | sed -E "s%^${variable_name}=\"?([^\"]+)\"?.*$%\1%"
}
addEtcEnvironmentVariable () {
variable_name="$1"
variable_value="$2"
add_etc_environment_variable() {
local variable_name=$1
local variable_value=$2
echo "${variable_name}=${variable_value}" | sudo tee -a /etc/environment
}
replaceEtcEnvironmentVariable () {
variable_name="$1"
variable_value="$2"
replace_etc_environment_variable() {
local variable_name=$1
local variable_value=$2
# modify /etc/environemnt in place by replacing a string that begins with variable_name
sudo sed -i -e "s%^${variable_name}=.*$%${variable_name}=\"${variable_value}\"%" /etc/environment
}
setEtcEnvironmentVariable () {
variable_name="$1"
variable_value="$2"
set_etc_environment_variable() {
local variable_name=$1
local variable_value=$2
if grep "^${variable_name}=" /etc/environment > /dev/null
then
replaceEtcEnvironmentVariable $variable_name $variable_value
if grep "^${variable_name}=" /etc/environment > /dev/null; then
replace_etc_environment_variable $variable_name $variable_value
else
addEtcEnvironmentVariable $variable_name $variable_value
add_etc_environment_variable $variable_name $variable_value
fi
}
prependEtcEnvironmentVariable () {
variable_name="$1"
element="$2"
prepend_etc_environment_variable() {
local variable_name=$1
local element=$2
# TODO: handle the case if the variable does not exist
existing_value=$(getEtcEnvironmentVariable "${variable_name}")
setEtcEnvironmentVariable "${variable_name}" "${element}:${existing_value}"
existing_value=$(get_etc_environment_variable "${variable_name}")
set_etc_environment_variable "${variable_name}" "${element}:${existing_value}"
}
appendEtcEnvironmentVariable () {
variable_name="$1"
element="$2"
append_etc_environment_variable() {
local variable_name=$1
local element=$2
# TODO: handle the case if the variable does not exist
existing_value=$(getEtcEnvironmentVariable "${variable_name}")
setEtcEnvironmentVariable "${variable_name}" "${existing_value}:${element}"
existing_value=$(get_etc_environment_variable "${variable_name}")
set_etc_environment_variable "${variable_name}" "${existing_value}:${element}"
}
prependEtcEnvironmentPath () {
element="$1"
prepend_etc_environment_path() {
local element=$1
prependEtcEnvironmentVariable PATH "${element}"
prepend_etc_environment_variable PATH "${element}"
}
appendEtcEnvironmentPath () {
element="$1"
append_etc_environment_path() {
local element=$1
appendEtcEnvironmentVariable PATH "${element}"
append_etc_environment_variable PATH "${element}"
}
# Process /etc/environment as if it were shell script with `export VAR=...` expressions
@@ -81,10 +80,10 @@ appendEtcEnvironmentPath () {
# TODO: there might be the others variables to be processed in the same way as "PATH" variable
# ie MANPATH, INFOPATH, LD_*, etc. In the current implementation the values from /etc/evironments
# replace the values of the current environment
reloadEtcEnvironment () {
reload_etc_environment() {
# add `export ` to every variable of /etc/environemnt except PATH and eval the result shell script
eval $(grep -v '^PATH=' /etc/environment | sed -e 's%^%export %')
# handle PATH specially
etc_path=$(getEtcEnvironmentVariable PATH)
etc_path=$(get_etc_environment_variable PATH)
export PATH="$PATH:$etc_path"
}

View File

@@ -5,8 +5,8 @@
################################################################################
download_with_retry() {
url=$1
download_path=$2
local url=$1
local download_path=$2
if [ -z "$download_path" ]; then
download_path="/tmp/$(basename "$url")"
@@ -45,15 +45,6 @@ download_with_retry() {
echo "$download_path"
}
## Use dpkg to figure out if a package has already been installed
## Example use:
## if ! IsPackageInstalled packageName; then
## echo "packageName is not installed!"
## fi
IsPackageInstalled() {
dpkg -S $1 &> /dev/null
}
get_toolset_value() {
local toolset_path="/imagegeneration/installers/toolset.json"
local query=$1

View File

@@ -4,17 +4,14 @@
## Desc: Helper functions for OS releases
################################################################################
function isUbuntu20
{
is_ubuntu20() {
lsb_release -d | grep -q 'Ubuntu 20'
}
function isUbuntu22
{
is_ubuntu22() {
lsb_release -d | grep -q 'Ubuntu 22'
}
function getOSVersionLabel
{
get_os_version_label() {
lsb_release -cs
}