[master] Update dependencies from dotnet/arcade dotnet/core-setup dotnet/corefx ...
[mono-project.git] / eng / common / dotnet-install.sh
blob94ea3438820818e90c699974712a8529fafe95a5
1 #!/usr/bin/env bash
3 source="${BASH_SOURCE[0]}"
4 # resolve $source until the file is no longer a symlink
5 while [[ -h "$source" ]]; do
6 scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
7 source="$(readlink "$source")"
8 # if $source was a relative symlink, we need to resolve it relative to the path where the
9 # symlink file was located
10 [[ $source != /* ]] && source="$scriptroot/$source"
11 done
12 scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
14 version='Latest'
15 architecture=''
16 runtime='dotnet'
17 runtimeSourceFeed=''
18 runtimeSourceFeedKey=''
19 while [[ $# > 0 ]]; do
20 opt="$(echo "$1" | awk '{print tolower($0)}')"
21 case "$opt" in
22 -version|-v)
23 shift
24 version="$1"
26 -architecture|-a)
27 shift
28 architecture="$1"
30 -runtime|-r)
31 shift
32 runtime="$1"
34 -runtimesourcefeed)
35 shift
36 runtimeSourceFeed="$1"
38 -runtimesourcefeedkey)
39 shift
40 runtimeSourceFeedKey="$1"
43 echo "Invalid argument: $1"
44 exit 1
46 esac
47 shift
48 done
50 # Use uname to determine what the CPU is.
51 cpuname=$(uname -p)
52 # Some Linux platforms report unknown for platform, but the arch for machine.
53 if [[ "$cpuname" == "unknown" ]]; then
54 cpuname=$(uname -m)
57 case $cpuname in
58 aarch64)
59 buildarch=arm64
61 amd64|x86_64)
62 buildarch=x64
64 armv7l)
65 buildarch=arm
67 i686)
68 buildarch=x86
71 echo "Unknown CPU $cpuname detected, treating it as x64"
72 buildarch=x64
74 esac
76 . "$scriptroot/tools.sh"
77 dotnetRoot="$repo_root/.dotnet"
78 if [[ $architecture != "" ]] && [[ $architecture != $buildarch ]]; then
79 dotnetRoot="$dotnetRoot/$architecture"
82 InstallDotNet $dotnetRoot $version "$architecture" $runtime true $runtimeSourceFeed $runtimeSourceFeedKey || {
83 local exit_code=$?
84 echo "dotnet-install.sh failed (exit code '$exit_code')." >&2
85 ExitWithExitCode $exit_code
88 ExitWithExitCode 0