[ubuntu] Unify approach to /etc/environment (#8904)

* [ubuntu] Unify approach to /etc/environment

* [ubuntu] fix typo in XDG_CONFIG_HOME name
This commit is contained in:
Shamil Mubarakshin
2023-11-28 15:19:44 +01:00
committed by GitHub
parent da1c04b81a
commit 435ba67550
17 changed files with 78 additions and 46 deletions

View File

@@ -4,6 +4,9 @@
## Desc: Configure dpkg ## Desc: Configure dpkg
################################################################################ ################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPTS/etc-environment.sh
# This is the anti-frontend. It never interacts with you at all, # This is the anti-frontend. It never interacts with you at all,
# and makes the default answers be used for all questions. It # and makes the default answers be used for all questions. It
# might mail error messages to root, but that's it; otherwise it # might mail error messages to root, but that's it; otherwise it
@@ -11,7 +14,7 @@
# automatic installs. If you are using this front-end, and require # automatic installs. If you are using this front-end, and require
# non-default answers to questions, you will need to preseed the # non-default answers to questions, you will need to preseed the
# debconf database # debconf database
echo 'DEBIAN_FRONTEND=noninteractive' | tee -a /etc/environment setEtcEnvironmentVariable "DEBIAN_FRONTEND" "noninteractive"
# dpkg can be instructed not to ask for confirmation # dpkg can be instructed not to ask for confirmation
# when replacing a configuration file (with the --force-confdef --force-confold options) # when replacing a configuration file (with the --force-confdef --force-confold options)

View File

@@ -6,17 +6,18 @@
# 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/etc-environment.sh
# Set ImageVersion and ImageOS env variables # Set ImageVersion and ImageOS env variables
echo ImageVersion=$IMAGE_VERSION | tee -a /etc/environment setEtcEnvironmentVariable "ImageVersion" "${IMAGE_VERSION}"
echo ImageOS=$IMAGE_OS | tee -a /etc/environment setEtcEnvironmentVariable "ImageOS" "${IMAGE_OS}"
# Set the ACCEPT_EULA variable to Y value to confirm your acceptance of the End-User Licensing Agreement # Set the ACCEPT_EULA variable to Y value to confirm your acceptance of the End-User Licensing Agreement
echo ACCEPT_EULA=Y | tee -a /etc/environment setEtcEnvironmentVariable "ACCEPT_EULA" "Y"
# This directory is supposed to be created in $HOME and owned by user(https://github.com/actions/runner-images/issues/491) # 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 mkdir -p /etc/skel/.config/configstore
echo 'XDG_CONFIG_HOME=$HOME/.config' | tee -a /etc/environment setEtcEnvironmentVariable "XDG_CONFIG_HOME" '$HOME/.config'
# Change waagent entries to use /mnt for swapfile # Change waagent entries to use /mnt for swapfile
sed -i 's/ResourceDisk.Format=n/ResourceDisk.Format=y/g' /etc/waagent.conf sed -i 's/ResourceDisk.Format=n/ResourceDisk.Format=y/g' /etc/waagent.conf
@@ -29,7 +30,7 @@ sed -i 's/::1 ip6-localhost ip6-loopback/::1 localhost ip6-localhost ip6-loo
# Prepare directory and env variable for toolcache # Prepare directory and env variable for toolcache
AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache AGENT_TOOLSDIRECTORY=/opt/hostedtoolcache
mkdir $AGENT_TOOLSDIRECTORY mkdir $AGENT_TOOLSDIRECTORY
echo "AGENT_TOOLSDIRECTORY=$AGENT_TOOLSDIRECTORY" | tee -a /etc/environment setEtcEnvironmentVariable "AGENT_TOOLSDIRECTORY" "${AGENT_TOOLSDIRECTORY}"
chmod -R 777 $AGENT_TOOLSDIRECTORY chmod -R 777 $AGENT_TOOLSDIRECTORY
# https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html # https://www.elastic.co/guide/en/elasticsearch/reference/current/vm-max-map-count.html

View File

@@ -4,6 +4,9 @@
## Desc: Post deployment system configuration actions ## Desc: Post deployment system configuration actions
################################################################################ ################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPT_FOLDER/etc-environment.sh
mv -f /imagegeneration/post-generation /opt mv -f /imagegeneration/post-generation /opt
echo "chmod -R 777 /opt" echo "chmod -R 777 /opt"
@@ -17,7 +20,7 @@ chmod 755 $IMAGE_FOLDER
ENVPATH=$(grep 'PATH=' /etc/environment | head -n 1 | sed -z 's/^PATH=*//') ENVPATH=$(grep 'PATH=' /etc/environment | head -n 1 | sed -z 's/^PATH=*//')
ENVPATH=${ENVPATH#"\""} ENVPATH=${ENVPATH#"\""}
ENVPATH=${ENVPATH%"\""} ENVPATH=${ENVPATH%"\""}
echo "PATH=$ENVPATH" | sudo tee -a /etc/environment addEtcEnvironmentVariable "PATH" "${ENVPATH}"
echo "Updated /etc/environment: $(cat /etc/environment)" echo "Updated /etc/environment: $(cat /etc/environment)"
# Сlean yarn and npm cache # Сlean yarn and npm cache

View File

@@ -14,7 +14,7 @@ ACTION_ARCHIVE_CACHE_DIR=/opt/actionarchivecache
mkdir -p $ACTION_ARCHIVE_CACHE_DIR mkdir -p $ACTION_ARCHIVE_CACHE_DIR
chmod -R 777 $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}" echo "Setting up ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE variable to ${ACTION_ARCHIVE_CACHE_DIR}"
addEtcEnvironmentVariable ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE ${ACTION_ARCHIVE_CACHE_DIR} setEtcEnvironmentVariable "ACTIONS_RUNNER_ACTION_ARCHIVE_CACHE" "${ACTION_ARCHIVE_CACHE_DIR}"
# Download latest release from github.com/actions/action-versions and untar to /opt/actionarchivecache # Download latest release from github.com/actions/action-versions and untar to /opt/actionarchivecache
downloadUrl=$(get_github_package_download_url "actions/action-versions" "contains(\"action-versions.tar.gz\")") downloadUrl=$(get_github_package_download_url "actions/action-versions" "contains(\"action-versions.tar.gz\")")

View File

@@ -35,10 +35,10 @@ function get_full_ndk_version {
ANDROID_ROOT=/usr/local/lib/android ANDROID_ROOT=/usr/local/lib/android
ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk ANDROID_SDK_ROOT=${ANDROID_ROOT}/sdk
SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager SDKMANAGER=${ANDROID_SDK_ROOT}/cmdline-tools/latest/bin/sdkmanager
echo "ANDROID_SDK_ROOT=${ANDROID_SDK_ROOT}" | tee -a /etc/environment setEtcEnvironmentVariable "ANDROID_SDK_ROOT" "${ANDROID_SDK_ROOT}"
# ANDROID_HOME is deprecated, but older versions of Gradle rely on it # ANDROID_HOME is deprecated, but older versions of Gradle rely on it
echo "ANDROID_HOME=${ANDROID_SDK_ROOT}" | tee -a /etc/environment setEtcEnvironmentVariable "ANDROID_HOME" "${ANDROID_SDK_ROOT}"
# Create android sdk directory # Create android sdk directory
mkdir -p ${ANDROID_SDK_ROOT} mkdir -p ${ANDROID_SDK_ROOT}
@@ -100,10 +100,10 @@ ndkDefaultFullVersion=$(get_full_ndk_version $ANDROID_NDK_MAJOR_DEFAULT)
ndkLatestFullVersion=$(get_full_ndk_version $ANDROID_NDK_MAJOR_LATEST) ndkLatestFullVersion=$(get_full_ndk_version $ANDROID_NDK_MAJOR_LATEST)
ANDROID_NDK="$ANDROID_SDK_ROOT/ndk/$ndkDefaultFullVersion" ANDROID_NDK="$ANDROID_SDK_ROOT/ndk/$ndkDefaultFullVersion"
# 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 # 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
echo "ANDROID_NDK=${ANDROID_NDK}" | tee -a /etc/environment setEtcEnvironmentVariable "ANDROID_NDK" "${ANDROID_NDK}"
echo "ANDROID_NDK_HOME=${ANDROID_NDK}" | tee -a /etc/environment setEtcEnvironmentVariable "ANDROID_NDK_HOME" "${ANDROID_NDK}"
echo "ANDROID_NDK_ROOT=${ANDROID_NDK}" | tee -a /etc/environment setEtcEnvironmentVariable "ANDROID_NDK_ROOT" "${ANDROID_NDK}"
echo "ANDROID_NDK_LATEST_HOME=$ANDROID_SDK_ROOT/ndk/$ndkLatestFullVersion" | tee -a /etc/environment setEtcEnvironmentVariable "ANDROID_NDK_LATEST_HOME" "${ANDROID_SDK_ROOT}/ndk/${ndkLatestFullVersion}"
availablePlatforms=($($SDKMANAGER --list | sed -n '/Available Packages:/,/^$/p' | grep "platforms;android-[0-9]" | cut -d"|" -f 1)) availablePlatforms=($($SDKMANAGER --list | sed -n '/Available Packages:/,/^$/p' | grep "platforms;android-[0-9]" | cut -d"|" -f 1))
allBuildTools=($($SDKMANAGER --list | grep "build-tools;" | cut -d"|" -f 1 | sort -u)) allBuildTools=($($SDKMANAGER --list | grep "build-tools;" | cut -d"|" -f 1 | sort -u))

View File

@@ -4,10 +4,13 @@
## Desc: Install Azure DevOps CLI (az devops) ## Desc: Install Azure DevOps CLI (az devops)
################################################################################ ################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPTS/etc-environment.sh
# AZURE_EXTENSION_DIR shell variable defines where modules are installed # AZURE_EXTENSION_DIR shell variable defines where modules are installed
# https://docs.microsoft.com/en-us/cli/azure/azure-cli-extensions-overview # https://docs.microsoft.com/en-us/cli/azure/azure-cli-extensions-overview
export AZURE_EXTENSION_DIR=/opt/az/azcliextensions export AZURE_EXTENSION_DIR=/opt/az/azcliextensions
echo "AZURE_EXTENSION_DIR=$AZURE_EXTENSION_DIR" | tee -a /etc/environment setEtcEnvironmentVariable "AZURE_EXTENSION_DIR" "${AZURE_EXTENSION_DIR}"
# install azure devops Cli extension # install azure devops Cli extension
az extension add -n azure-devops az extension add -n azure-devops

View File

@@ -5,10 +5,9 @@
################################################################################ ################################################################################
# Source the helpers for use with the script # Source the helpers for use with the script
# shellcheck source=../helpers/install.sh
source "$HELPER_SCRIPTS/install.sh" source "$HELPER_SCRIPTS/install.sh"
# shellcheck source=../helpers/os.sh
source "$HELPER_SCRIPTS/os.sh" source "$HELPER_SCRIPTS/os.sh"
source $HELPER_SCRIPTS/etc-environment.sh
# Mozillateam PPA is added manually because sometimes # Mozillateam PPA is added manually because sometimes
# lanuchad portal sends empty answer when trying to add it automatically # lanuchad portal sends empty answer when trying to add it automatically
@@ -45,6 +44,6 @@ tar -xzf /tmp/geckodriver.tar.gz -C $GECKODRIVER_DIR
chmod +x $GECKODRIVER_BIN chmod +x $GECKODRIVER_BIN
ln -s "$GECKODRIVER_BIN" /usr/bin/ ln -s "$GECKODRIVER_BIN" /usr/bin/
echo "GECKOWEBDRIVER=$GECKODRIVER_DIR" | tee -a /etc/environment setEtcEnvironmentVariable "GECKOWEBDRIVER" "${GECKODRIVER_DIR}"
invoke_tests "Browsers" "Firefox" invoke_tests "Browsers" "Firefox"

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/install.sh source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/etc-environment.sh
function GetChromiumRevision { function GetChromiumRevision {
CHROME_REVISION=$1 CHROME_REVISION=$1
@@ -36,7 +37,7 @@ CHROME_DEB_URL="https://dl.google.com/linux/direct/google-chrome-stable_current_
CHROME_DEB_NAME="google-chrome-stable_current_amd64.deb" CHROME_DEB_NAME="google-chrome-stable_current_amd64.deb"
download_with_retries $CHROME_DEB_URL "/tmp" "${CHROME_DEB_NAME}" download_with_retries $CHROME_DEB_URL "/tmp" "${CHROME_DEB_NAME}"
apt install "/tmp/${CHROME_DEB_NAME}" -f apt install "/tmp/${CHROME_DEB_NAME}" -f
echo "CHROME_BIN=/usr/bin/google-chrome" | tee -a /etc/environment setEtcEnvironmentVariable "CHROME_BIN" "/usr/bin/google-chrome"
# Remove Google Chrome repo # 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 rm -f /etc/cron.daily/google-chrome /etc/apt/sources.list.d/google-chrome.list /etc/apt/sources.list.d/google-chrome.list.save
@@ -64,7 +65,7 @@ unzip -qq /tmp/$CHROMEDRIVER_ARCHIVE -d /usr/local/share
chmod +x $CHROMEDRIVER_BIN chmod +x $CHROMEDRIVER_BIN
ln -s "$CHROMEDRIVER_BIN" /usr/bin/ ln -s "$CHROMEDRIVER_BIN" /usr/bin/
echo "CHROMEWEBDRIVER=$CHROMEDRIVER_DIR" | tee -a /etc/environment setEtcEnvironmentVariable "CHROMEWEBDRIVER" "${CHROMEDRIVER_DIR}"
# Download and unpack Chromium # Download and unpack Chromium
CHROME_REVISION=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].revision') CHROME_REVISION=$(echo "${CHROME_VERSIONS_JSON}" | jq -r '.builds["'"$CHROME_VERSION"'"].revision')

View File

@@ -16,13 +16,13 @@ createJavaEnvironmentalVariable() {
if [[ ${DEFAULT} == "True" ]]; then if [[ ${DEFAULT} == "True" ]]; then
echo "Setting up JAVA_HOME variable to ${INSTALL_PATH_PATTERN}" echo "Setting up JAVA_HOME variable to ${INSTALL_PATH_PATTERN}"
addEtcEnvironmentVariable JAVA_HOME ${INSTALL_PATH_PATTERN} setEtcEnvironmentVariable "JAVA_HOME" "${INSTALL_PATH_PATTERN}"
echo "Setting up default symlink" echo "Setting up default symlink"
update-java-alternatives -s ${INSTALL_PATH_PATTERN} update-java-alternatives -s ${INSTALL_PATH_PATTERN}
fi fi
echo "Setting up JAVA_HOME_${JAVA_VERSION}_X64 variable to ${INSTALL_PATH_PATTERN}" echo "Setting up JAVA_HOME_${JAVA_VERSION}_X64 variable to ${INSTALL_PATH_PATTERN}"
addEtcEnvironmentVariable JAVA_HOME_${JAVA_VERSION}_X64 ${INSTALL_PATH_PATTERN} setEtcEnvironmentVariable "JAVA_HOME_${JAVA_VERSION}_X64" "${INSTALL_PATH_PATTERN}"
} }
enableRepositories() { enableRepositories() {
@@ -93,7 +93,7 @@ done
# Install Ant # Install Ant
apt-get install -y --no-install-recommends ant ant-optional apt-get install -y --no-install-recommends ant ant-optional
echo "ANT_HOME=/usr/share/ant" | tee -a /etc/environment setEtcEnvironmentVariable "ANT_HOME" "/usr/share/ant"
# Install Maven # Install Maven
mavenVersion=$(get_toolset_value '.java.maven') mavenVersion=$(get_toolset_value '.java.maven')
@@ -113,7 +113,8 @@ echo "gradleVersion=${gradleLatestVersion}"
download_with_retries ${gradleDownloadUrl} "/tmp" "gradleLatest.zip" download_with_retries ${gradleDownloadUrl} "/tmp" "gradleLatest.zip"
unzip -qq -d /usr/share /tmp/gradleLatest.zip unzip -qq -d /usr/share /tmp/gradleLatest.zip
ln -s /usr/share/gradle-"${gradleLatestVersion}"/bin/gradle /usr/bin/gradle ln -s /usr/share/gradle-"${gradleLatestVersion}"/bin/gradle /usr/bin/gradle
echo "GRADLE_HOME=$(find /usr/share -depth -maxdepth 1 -name "gradle*")" | tee -a /etc/environment gradle_home_dir=$(find /usr/share -depth -maxdepth 1 -name "gradle*")
setEtcEnvironmentVariable "GRADLE_HOME" "${gradle_home_dir}"
# Delete java repositories and keys # Delete java repositories and keys
rm -f /etc/apt/sources.list.d/adoptium.list rm -f /etc/apt/sources.list.d/adoptium.list

View File

@@ -4,6 +4,9 @@
## Desc: Install Leiningen ## Desc: Install Leiningen
################################################################################ ################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPTS/etc-environment.sh
LEIN_BIN=/usr/local/bin/lein LEIN_BIN=/usr/local/bin/lein
curl -fsSL https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > $LEIN_BIN curl -fsSL https://raw.githubusercontent.com/technomancy/leiningen/stable/bin/lein > $LEIN_BIN
chmod 0755 $LEIN_BIN chmod 0755 $LEIN_BIN
@@ -13,7 +16,7 @@ export LEIN_HOME=/usr/local/lib/lein
lein lein
LEIN_JAR=$(find $LEIN_HOME -name "leiningen-*-standalone.jar") LEIN_JAR=$(find $LEIN_HOME -name "leiningen-*-standalone.jar")
echo "LEIN_JAR=$LEIN_JAR" | tee -a /etc/environment setEtcEnvironmentVariable "LEIN_JAR" "${LEIN_JAR}"
echo "LEIN_HOME=$LEIN_HOME" | tee -a /etc/environment setEtcEnvironmentVariable "LEIN_HOME" "${LEIN_HOME}"
invoke_tests "Tools" "Leiningen" invoke_tests "Tools" "Leiningen"

View File

@@ -4,7 +4,9 @@
## Desc: Install Microsoft Edge and WebDriver ## Desc: Install Microsoft Edge and WebDriver
################################################################################ ################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPTS/install.sh source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/etc-environment.sh
REPO_URL="https://packages.microsoft.com/repos/edge" REPO_URL="https://packages.microsoft.com/repos/edge"
gpg_key="/usr/share/keyrings/microsoft-edge.gpg" gpg_key="/usr/share/keyrings/microsoft-edge.gpg"
@@ -44,6 +46,6 @@ unzip -qq /tmp/edgedriver_linux64.zip -d $EDGEDRIVER_DIR
chmod +x $EDGEDRIVER_BIN chmod +x $EDGEDRIVER_BIN
ln -s $EDGEDRIVER_BIN /usr/bin ln -s $EDGEDRIVER_BIN /usr/bin
echo "EDGEWEBDRIVER=$EDGEDRIVER_DIR" | tee -a /etc/environment setEtcEnvironmentVariable "EDGEWEBDRIVER" "${EDGEDRIVER_DIR}"
invoke_tests "Browsers" "Edge" invoke_tests "Browsers" "Edge"

View File

@@ -4,6 +4,9 @@
## Desc: Install miniconda ## Desc: Install miniconda
################################################################################ ################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPTS/etc-environment.sh
# Install Miniconda # Install Miniconda
curl -fsSL https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o miniconda.sh \ curl -fsSL https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -o miniconda.sh \
&& chmod +x miniconda.sh \ && chmod +x miniconda.sh \
@@ -11,7 +14,7 @@ curl -fsSL https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
&& rm miniconda.sh && rm miniconda.sh
CONDA=/usr/share/miniconda CONDA=/usr/share/miniconda
echo "CONDA=$CONDA" | tee -a /etc/environment setEtcEnvironmentVariable "CONDA" "${CONDA}"
ln -s $CONDA/bin/conda /usr/bin/conda ln -s $CONDA/bin/conda /usr/bin/conda

View File

@@ -4,11 +4,14 @@
## Desc: Install Nvm ## Desc: Install Nvm
################################################################################ ################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPTS/etc-environment.sh
export NVM_DIR="/etc/skel/.nvm" export NVM_DIR="/etc/skel/.nvm"
mkdir $NVM_DIR mkdir $NVM_DIR
VERSION=$(curl -fsSL https://api.github.com/repos/nvm-sh/nvm/releases/latest | jq -r '.tag_name') 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 curl -fsSL https://raw.githubusercontent.com/nvm-sh/nvm/$VERSION/install.sh | bash
echo 'NVM_DIR=$HOME/.nvm' | tee -a /etc/environment setEtcEnvironmentVariable "NVM_DIR" '$HOME/.nvm'
echo '[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm' | tee -a /etc/skel/.bash_profile 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" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

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/install.sh source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/etc-environment.sh
# Download Selenium server # Download Selenium server
SELENIUM_MAJOR_VERSION=$(get_toolset_value '.selenium.version') SELENIUM_MAJOR_VERSION=$(get_toolset_value '.selenium.version')
@@ -20,6 +21,6 @@ SELENIUM_FULL_VERSION=$(echo $SELENIUM_DOWNLOAD_URL | awk -F"${SELENIUM_BINARY_N
touch "$SELENIUM_JAR_PATH/$SELENIUM_BINARY_NAME-$SELENIUM_FULL_VERSION" touch "$SELENIUM_JAR_PATH/$SELENIUM_BINARY_NAME-$SELENIUM_FULL_VERSION"
# Add SELENIUM_JAR_PATH environment variable # Add SELENIUM_JAR_PATH environment variable
echo "SELENIUM_JAR_PATH=$SELENIUM_JAR_PATH/$SELENIUM_JAR_NAME" | tee -a /etc/environment setEtcEnvironmentVariable "SELENIUM_JAR_PATH" "${SELENIUM_JAR_PATH}/${SELENIUM_JAR_NAME}"
invoke_tests "Tools" "Selenium" invoke_tests "Tools" "Selenium"

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/install.sh source $HELPER_SCRIPTS/install.sh
source $HELPER_SCRIPTS/etc-environment.sh
# Install # Install
image_label="$(lsb_release -rs)" image_label="$(lsb_release -rs)"
@@ -41,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_BIN_ROOT/swiftc" /usr/local/bin/swiftc
ln -s "$SWIFT_LIB_ROOT/libsourcekitdInProc.so" /usr/local/lib/libsourcekitdInProc.so ln -s "$SWIFT_LIB_ROOT/libsourcekitdInProc.so" /usr/local/lib/libsourcekitdInProc.so
echo "SWIFT_PATH=$SWIFT_BIN_ROOT" | tee -a /etc/environment setEtcEnvironmentVariable "SWIFT_PATH" "${SWIFT_BIN_ROOT}"
invoke_tests "Common" "Swift" invoke_tests "Common" "Swift"

View File

@@ -4,9 +4,12 @@
## Desc: Install vcpkg ## Desc: Install vcpkg
################################################################################ ################################################################################
# Source the helpers for use with the script
source $HELPER_SCRIPTS/etc-environment.sh
# Set env variable for vcpkg # Set env variable for vcpkg
VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg VCPKG_INSTALLATION_ROOT=/usr/local/share/vcpkg
echo "VCPKG_INSTALLATION_ROOT=${VCPKG_INSTALLATION_ROOT}" | tee -a /etc/environment setEtcEnvironmentVariable "VCPKG_INSTALLATION_ROOT" "${VCPKG_INSTALLATION_ROOT}"
# Install vcpkg # Install vcpkg
git clone https://github.com/Microsoft/vcpkg $VCPKG_INSTALLATION_ROOT git clone https://github.com/Microsoft/vcpkg $VCPKG_INSTALLATION_ROOT

View File

@@ -8,20 +8,21 @@
# values containg slashes (i.e. directory path) # values containg slashes (i.e. directory path)
# The values containing '%' will break the functions # The values containing '%' will break the functions
function getEtcEnvironmentVariable { getEtcEnvironmentVariable () {
variable_name="$1" variable_name="$1"
# remove `variable_name=` and possible quotes from the line # remove `variable_name=` and possible quotes from the line
grep "^${variable_name}=" /etc/environment | sed -E "s%^${variable_name}=\"?([^\"]+)\"?.*$%\1%" grep "^${variable_name}=" /etc/environment | sed -E "s%^${variable_name}=\"?([^\"]+)\"?.*$%\1%"
} }
function addEtcEnvironmentVariable { addEtcEnvironmentVariable () {
variable_name="$1" variable_name="$1"
variable_value="$2" variable_value="$2"
echo "$variable_name=$variable_value" | sudo tee -a /etc/environment echo "${variable_name}=${variable_value}" | sudo tee -a /etc/environment
} }
function replaceEtcEnvironmentVariable { replaceEtcEnvironmentVariable () {
variable_name="$1" variable_name="$1"
variable_value="$2" variable_value="$2"
@@ -29,40 +30,45 @@ function replaceEtcEnvironmentVariable {
sudo sed -i -e "s%^${variable_name}=.*$%${variable_name}=\"${variable_value}\"%" /etc/environment sudo sed -i -e "s%^${variable_name}=.*$%${variable_name}=\"${variable_value}\"%" /etc/environment
} }
function setEtcEnvironmentVariable { setEtcEnvironmentVariable () {
variable_name="$1" variable_name="$1"
variable_value="$2" variable_value="$2"
if grep "$variable_name" /etc/environment > /dev/null; then if grep "^${variable_name}=" /etc/environment > /dev/null
then
replaceEtcEnvironmentVariable $variable_name $variable_value replaceEtcEnvironmentVariable $variable_name $variable_value
else else
addEtcEnvironmentVariable $variable_name $variable_value addEtcEnvironmentVariable $variable_name $variable_value
fi fi
} }
function prependEtcEnvironmentVariable { prependEtcEnvironmentVariable () {
variable_name="$1" variable_name="$1"
element="$2" element="$2"
# TODO: handle the case if the variable does not exist # TODO: handle the case if the variable does not exist
existing_value=$(getEtcEnvironmentVariable "${variable_name}") existing_value=$(getEtcEnvironmentVariable "${variable_name}")
setEtcEnvironmentVariable "${variable_name}" "${element}:${existing_value}" setEtcEnvironmentVariable "${variable_name}" "${element}:${existing_value}"
} }
function appendEtcEnvironmentVariable { appendEtcEnvironmentVariable () {
variable_name="$1" variable_name="$1"
element="$2" element="$2"
# TODO: handle the case if the variable does not exist # TODO: handle the case if the variable does not exist
existing_value=$(getEtcEnvironmentVariable "${variable_name}") existing_value=$(getEtcEnvironmentVariable "${variable_name}")
setEtcEnvironmentVariable "${variable_name}" "${existing_value}:${element}" setEtcEnvironmentVariable "${variable_name}" "${existing_value}:${element}"
} }
function prependEtcEnvironmentPath { prependEtcEnvironmentPath () {
element="$1" element="$1"
prependEtcEnvironmentVariable PATH "${element}" prependEtcEnvironmentVariable PATH "${element}"
} }
function appendEtcEnvironmentPath { appendEtcEnvironmentPath () {
element="$1" element="$1"
appendEtcEnvironmentVariable PATH "${element}" appendEtcEnvironmentVariable PATH "${element}"
} }
@@ -75,11 +81,10 @@ function appendEtcEnvironmentPath {
# TODO: there might be the others variables to be processed in the same way as "PATH" variable # 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 # ie MANPATH, INFOPATH, LD_*, etc. In the current implementation the values from /etc/evironments
# replace the values of the current environment # replace the values of the current environment
function reloadEtcEnvironment { reloadEtcEnvironment () {
# add `export ` to every variable of /etc/environemnt except PATH and eval the result shell script # 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 %') eval $(grep -v '^PATH=' /etc/environment | sed -e 's%^%export %')
# handle PATH specially # handle PATH specially
etc_path=$(getEtcEnvironmentVariable PATH) etc_path=$(getEtcEnvironmentVariable PATH)
export PATH="$PATH:$etc_path" export PATH="$PATH:$etc_path"
} }