2019-05-07 12:30:40 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
source="${BASH_SOURCE[0]}"
|
|
|
|
# resolve $source until the file is no longer a symlink
|
|
|
|
while [[ -h "$source" ]]; do
|
|
|
|
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
|
|
|
|
source="$(readlink "$source")"
|
|
|
|
# if $source was a relative symlink, we need to resolve it relative to the path where the
|
|
|
|
# symlink file was located
|
|
|
|
[[ $source != /* ]] && source="$scriptroot/$source"
|
|
|
|
done
|
|
|
|
scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
|
|
|
|
|
2019-11-22 13:41:58 +00:00
|
|
|
. "$scriptroot/tools.sh"
|
|
|
|
|
2019-05-07 12:30:40 +00:00
|
|
|
version='Latest'
|
|
|
|
architecture=''
|
|
|
|
runtime='dotnet'
|
2019-10-24 22:05:36 +00:00
|
|
|
runtimeSourceFeed=''
|
|
|
|
runtimeSourceFeedKey=''
|
2019-05-07 12:30:40 +00:00
|
|
|
while [[ $# > 0 ]]; do
|
2021-01-09 13:53:15 +00:00
|
|
|
opt="$(echo "$1" | tr "[:upper:]" "[:lower:]")"
|
2019-05-07 12:30:40 +00:00
|
|
|
case "$opt" in
|
|
|
|
-version|-v)
|
|
|
|
shift
|
|
|
|
version="$1"
|
|
|
|
;;
|
|
|
|
-architecture|-a)
|
|
|
|
shift
|
|
|
|
architecture="$1"
|
|
|
|
;;
|
|
|
|
-runtime|-r)
|
|
|
|
shift
|
|
|
|
runtime="$1"
|
|
|
|
;;
|
2019-10-24 22:05:36 +00:00
|
|
|
-runtimesourcefeed)
|
|
|
|
shift
|
|
|
|
runtimeSourceFeed="$1"
|
|
|
|
;;
|
|
|
|
-runtimesourcefeedkey)
|
|
|
|
shift
|
|
|
|
runtimeSourceFeedKey="$1"
|
|
|
|
;;
|
2019-05-07 12:30:40 +00:00
|
|
|
*)
|
2019-11-22 13:41:58 +00:00
|
|
|
Write-PipelineTelemetryError -Category 'Build' -Message "Invalid argument: $1"
|
2019-05-07 12:30:40 +00:00
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
2021-02-06 13:50:54 +00:00
|
|
|
# Use uname to determine what the CPU is, see https://en.wikipedia.org/wiki/Uname#Examples
|
|
|
|
cpuname=$(uname -m)
|
2019-10-24 22:05:36 +00:00
|
|
|
case $cpuname in
|
2022-04-12 12:45:17 +00:00
|
|
|
arm64|aarch64)
|
2019-10-24 22:05:36 +00:00
|
|
|
buildarch=arm64
|
2023-06-17 12:26:35 +00:00
|
|
|
if [ "$(getconf LONG_BIT)" -lt 64 ]; then
|
|
|
|
# This is 32-bit OS running on 64-bit CPU (for example Raspberry Pi OS)
|
|
|
|
buildarch=arm
|
|
|
|
fi
|
2019-10-24 22:05:36 +00:00
|
|
|
;;
|
2021-12-21 14:21:59 +00:00
|
|
|
loongarch64)
|
|
|
|
buildarch=loongarch64
|
|
|
|
;;
|
2019-10-24 22:05:36 +00:00
|
|
|
amd64|x86_64)
|
|
|
|
buildarch=x64
|
|
|
|
;;
|
2020-02-28 13:39:56 +00:00
|
|
|
armv*l)
|
2019-10-24 22:05:36 +00:00
|
|
|
buildarch=arm
|
|
|
|
;;
|
2022-04-12 12:45:17 +00:00
|
|
|
i[3-6]86)
|
2019-10-24 22:05:36 +00:00
|
|
|
buildarch=x86
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Unknown CPU $cpuname detected, treating it as x64"
|
|
|
|
buildarch=x64
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2021-06-12 12:58:31 +00:00
|
|
|
dotnetRoot="${repo_root}.dotnet"
|
2019-10-24 22:05:36 +00:00
|
|
|
if [[ $architecture != "" ]] && [[ $architecture != $buildarch ]]; then
|
|
|
|
dotnetRoot="$dotnetRoot/$architecture"
|
|
|
|
fi
|
|
|
|
|
|
|
|
InstallDotNet $dotnetRoot $version "$architecture" $runtime true $runtimeSourceFeed $runtimeSourceFeedKey || {
|
2019-05-07 12:30:40 +00:00
|
|
|
local exit_code=$?
|
2019-11-22 13:41:58 +00:00
|
|
|
Write-PipelineTelemetryError -Category 'InitializeToolset' -Message "dotnet-install.sh failed (exit code '$exit_code')." >&2
|
2019-05-07 12:30:40 +00:00
|
|
|
ExitWithExitCode $exit_code
|
|
|
|
}
|
|
|
|
|
|
|
|
ExitWithExitCode 0
|