mirror of
https://github.com/actions/runner-images.git
synced 2025-12-11 03:27:05 +00:00
[ubuntu] Modify installation and add .NET 9 (#13004)
This commit is contained in:
committed by
GitHub
parent
b1634b123b
commit
0742173587
@@ -9,83 +9,59 @@ source $HELPER_SCRIPTS/etc-environment.sh
|
|||||||
source $HELPER_SCRIPTS/install.sh
|
source $HELPER_SCRIPTS/install.sh
|
||||||
source $HELPER_SCRIPTS/os.sh
|
source $HELPER_SCRIPTS/os.sh
|
||||||
|
|
||||||
extract_dotnet_sdk() {
|
|
||||||
local archive_name=$1
|
|
||||||
|
|
||||||
set -e
|
|
||||||
destination="./tmp-$(basename -s .tar.gz $archive_name)"
|
|
||||||
|
|
||||||
echo "Extracting $archive_name to $destination"
|
|
||||||
mkdir "$destination" && tar -C "$destination" -xzf "$archive_name"
|
|
||||||
rsync -qav --remove-source-files "$destination/shared/" /usr/share/dotnet/shared/
|
|
||||||
rsync -qav --remove-source-files "$destination/host/" /usr/share/dotnet/host/
|
|
||||||
rsync -qav --remove-source-files "$destination/sdk/" /usr/share/dotnet/sdk/
|
|
||||||
rm -rf "$destination" "$archive_name"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Ubuntu 20 doesn't support EOL versions
|
|
||||||
latest_dotnet_packages=$(get_toolset_value '.dotnet.aptPackages[]')
|
|
||||||
dotnet_versions=$(get_toolset_value '.dotnet.versions[]')
|
dotnet_versions=$(get_toolset_value '.dotnet.versions[]')
|
||||||
dotnet_tools=$(get_toolset_value '.dotnet.tools[].name')
|
dotnet_tools=$(get_toolset_value '.dotnet.tools[].name')
|
||||||
|
|
||||||
# Disable telemetry
|
# Disable telemetry
|
||||||
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
export DOTNET_CLI_TELEMETRY_OPTOUT=1
|
||||||
|
|
||||||
# Install .NET SDK from apt
|
# Install dotnet dependencies
|
||||||
# There is a versions conflict, that leads to
|
# https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu-decision#dependencies
|
||||||
# Microsoft <-> Canonical repos dependencies mix up.
|
|
||||||
# Give Microsoft's repo higher priority to avoid collisions.
|
|
||||||
# See: https://github.com/dotnet/core/issues/7699
|
|
||||||
cat << EOF > /etc/apt/preferences.d/dotnet
|
|
||||||
Package: *net*
|
|
||||||
Pin: origin packages.microsoft.com
|
|
||||||
Pin-Priority: 1001
|
|
||||||
EOF
|
|
||||||
|
|
||||||
apt-get update
|
apt-get update
|
||||||
|
apt-get install --no-install-recommends \
|
||||||
|
ca-certificates \
|
||||||
|
libc6 \
|
||||||
|
libgcc-s1 \
|
||||||
|
libgssapi-krb5-2 \
|
||||||
|
liblttng-ust1 \
|
||||||
|
libssl3 \
|
||||||
|
libstdc++6 \
|
||||||
|
zlib1g
|
||||||
|
|
||||||
for latest_package in ${latest_dotnet_packages[@]}; do
|
if is_ubuntu22; then
|
||||||
echo "Determining if .NET Core ($latest_package) is installed"
|
apt-get install --no-install-recommends libicu70
|
||||||
if ! dpkg -S $latest_package &> /dev/null; then
|
fi
|
||||||
echo "Could not find .NET Core ($latest_package), installing..."
|
|
||||||
apt-get install $latest_package
|
|
||||||
else
|
|
||||||
echo ".NET Core ($latest_package) is already installed"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
rm /etc/apt/preferences.d/dotnet
|
if is_ubuntu24; then
|
||||||
|
apt-get install --no-install-recommends libicu74
|
||||||
|
fi
|
||||||
|
|
||||||
apt-get update
|
# Install .NET SDKs and Runtimes
|
||||||
|
mkdir -p /usr/share/dotnet
|
||||||
|
|
||||||
# Install .NET SDK from home repository
|
|
||||||
# Get list of all released SDKs from channels which are not end-of-life or preview
|
|
||||||
sdks=()
|
sdks=()
|
||||||
for version in ${dotnet_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"
|
||||||
releases=$(cat "$(download_with_retry "$release_url")")
|
releases=$(cat "$(download_with_retry "$release_url")")
|
||||||
if [[ $version == "6.0" ]]; then
|
sdks=("${sdks[@]}" $(echo "${releases}" | jq -r '.releases[].sdk.version | select(contains("preview") or contains("rc") | not)'))
|
||||||
sdks=("${sdks[@]}" $(echo "${releases}" | jq -r 'first(.releases[].sdks[]?.version | select(contains("preview") or contains("rc") | not))'))
|
sdks=("${sdks[@]}" $(echo "${releases}" | jq -r '.releases[].sdks[]?.version | select(contains("preview") or contains("rc") | not)'))
|
||||||
else
|
|
||||||
sdks=("${sdks[@]}" $(echo "${releases}" | jq -r '.releases[].sdk.version | select(contains("preview") or contains("rc") | not)'))
|
|
||||||
sdks=("${sdks[@]}" $(echo "${releases}" | jq -r '.releases[].sdks[]?.version | select(contains("preview") or contains("rc") | not)'))
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
sorted_sdks=$(echo ${sdks[@]} | tr ' ' '\n' | sort -r | uniq -w 5)
|
sorted_sdks=$(echo ${sdks[@]} | tr ' ' '\n' | sort -r | uniq -w 5)
|
||||||
|
|
||||||
# Download/install additional SDKs in parallel
|
## Download installer from dot.net
|
||||||
export -f download_with_retry
|
DOTNET_INSTALL_SCRIPT="https://dot.net/v1/dotnet-install.sh"
|
||||||
export -f extract_dotnet_sdk
|
install_script_path=$(download_with_retry $DOTNET_INSTALL_SCRIPT)
|
||||||
|
chmod +x $install_script_path
|
||||||
|
|
||||||
parallel --jobs 0 --halt soon,fail=1 \
|
for sdk in ${sorted_sdks[@]}; do
|
||||||
'url="https://dotnetcli.blob.core.windows.net/dotnet/Sdk/{}/dotnet-sdk-{}-linux-x64.tar.gz"; \
|
echo "Installing .NET SDK $sdk"
|
||||||
download_with_retry $url' ::: "${sorted_sdks[@]}"
|
$install_script_path --version $sdk --install-dir /usr/share/dotnet --no-path
|
||||||
|
done
|
||||||
|
|
||||||
find . -name "*.tar.gz" | parallel --halt soon,fail=1 'extract_dotnet_sdk {}'
|
## Dotnet installer doesn't create symlinks to executable or modify PATH
|
||||||
|
ln -s /usr/share/dotnet/dotnet /usr/bin/dotnet
|
||||||
|
|
||||||
# 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
|
|
||||||
set_etc_environment_variable DOTNET_SKIP_FIRST_TIME_EXPERIENCE 1
|
set_etc_environment_variable DOTNET_SKIP_FIRST_TIME_EXPERIENCE 1
|
||||||
set_etc_environment_variable DOTNET_NOLOGO 1
|
set_etc_environment_variable DOTNET_NOLOGO 1
|
||||||
set_etc_environment_variable DOTNET_MULTILEVEL_LOOKUP 0
|
set_etc_environment_variable DOTNET_MULTILEVEL_LOOKUP 0
|
||||||
|
|||||||
@@ -268,10 +268,6 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dotnet": {
|
"dotnet": {
|
||||||
"aptPackages": [
|
|
||||||
"dotnet-sdk-8.0",
|
|
||||||
"dotnet-sdk-9.0"
|
|
||||||
],
|
|
||||||
"versions": [
|
"versions": [
|
||||||
"8.0",
|
"8.0",
|
||||||
"9.0"
|
"9.0"
|
||||||
|
|||||||
@@ -228,11 +228,9 @@
|
|||||||
}
|
}
|
||||||
],
|
],
|
||||||
"dotnet": {
|
"dotnet": {
|
||||||
"aptPackages": [
|
|
||||||
"dotnet-sdk-8.0"
|
|
||||||
],
|
|
||||||
"versions": [
|
"versions": [
|
||||||
"8.0"
|
"8.0",
|
||||||
|
"9.0"
|
||||||
],
|
],
|
||||||
"tools": [
|
"tools": [
|
||||||
{ "name": "nbgv", "test": "nbgv --version", "getversion" : "nbgv --version" }
|
{ "name": "nbgv", "test": "nbgv --version", "getversion" : "nbgv --version" }
|
||||||
|
|||||||
Reference in New Issue
Block a user