Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 327939c

Browse files
author
Ian Hays
authored
[1.1] Clean up the portable-linux init-tools logic (#17497)
* [1.1] Clean up the portable-linux init-tools logic Changed around the logic to only use the platform specific CLIs when restoring for a specific distro type and version, falling back to the portable linux CLI when the RID doesn't match. Also cleaned up the nested if statements a bit. Previously we would fall back to the previous distro version's CLI for a new version of a known distro. * [1.1] Update init-tools to be closer to master * [1.1] Remove extra echos in init-tools.sh * [1.1] Update osx restore
1 parent 6a96fba commit 327939c

File tree

1 file changed

+43
-70
lines changed

1 file changed

+43
-70
lines changed

init-tools.sh

Lines changed: 43 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -15,76 +15,6 @@ __PROJECT_JSON_FILE=$__PROJECT_JSON_PATH/project.json
1515
__PROJECT_JSON_CONTENTS="{ \"dependencies\": { \"Microsoft.DotNet.BuildTools\": \"$__BUILD_TOOLS_PACKAGE_VERSION\" }, \"frameworks\": { \"netcoreapp1.0\": { } } }"
1616
__INIT_TOOLS_DONE_MARKER=$__PROJECT_JSON_PATH/done
1717

18-
# Extended version of platform detection logic from dotnet/cli/scripts/obtain/dotnet-install.sh 16692fc
19-
get_current_linux_name() {
20-
# Detect Distro
21-
if [ "$(cat /etc/*-release | grep -cim1 ubuntu)" -eq 1 ]; then
22-
if [ "$(cat /etc/*-release | grep -cim1 16.04)" -eq 1 ]; then
23-
echo "ubuntu.16.04"
24-
return 0
25-
fi
26-
if [ "$(cat /etc/*-release | grep -cim1 16.10)" -eq 1 ]; then
27-
echo "ubuntu.16.10"
28-
return 0
29-
fi
30-
if [ "$(cat /etc/*-release | grep -cim1 18.04)" -eq 1 ]; then
31-
echo "ubuntu.18.04"
32-
return 0
33-
fi
34-
echo "ubuntu"
35-
return 0
36-
elif [ "$(cat /etc/*-release | grep -cim1 centos)" -eq 1 ]; then
37-
echo "centos"
38-
return 0
39-
elif [ "$(cat /etc/*-release | grep -cim1 rhel)" -eq 1 ]; then
40-
echo "rhel"
41-
return 0
42-
elif [ "$(cat /etc/*-release | grep -cim1 debian)" -eq 1 ]; then
43-
echo "debian"
44-
return 0
45-
elif [ "$(cat /etc/*-release | grep -cim1 fedora)" -eq 1 ]; then
46-
echo -n "fedora."; cat /etc/*-release | grep VERSION_ID= | cut -d "=" -f2
47-
return 0;
48-
elif [ "$(cat /etc/*-release | grep -cim1 opensuse)" -eq 1 ]; then
49-
if [ "$(cat /etc/*-release | grep -cim1 13.2)" -eq 1 ]; then
50-
echo "opensuse.13.2"
51-
return 0
52-
fi
53-
if [ "$(cat /etc/*-release | grep -cim1 42.1)" -eq 1 ]; then
54-
echo "opensuse.42.1"
55-
return 0
56-
fi
57-
echo "opensuse.42.3"
58-
return 0
59-
fi
60-
61-
# Cannot determine Linux distribution, assuming Ubuntu 14.04.
62-
echo "ubuntu"
63-
return 0
64-
}
65-
66-
if [ -z "$__DOTNET_PKG" ]; then
67-
OSName=$(uname -s)
68-
case $OSName in
69-
Darwin)
70-
OS=OSX
71-
__DOTNET_PKG=dotnet-dev-osx-x64
72-
ulimit -n 2048
73-
;;
74-
75-
Linux)
76-
__DOTNET_PKG="dotnet-dev-$(get_current_linux_name)-x64"
77-
OS=Linux
78-
;;
79-
80-
*)
81-
echo "Unsupported OS '$OSName' detected. Downloading ubuntu-x64 tools."
82-
OS=Linux
83-
__DOTNET_PKG=dotnet-dev-ubuntu-x64
84-
;;
85-
esac
86-
fi
87-
8818
display_error_message()
8919
{
9020
echo "Please check the detailed log that follows." 1>&2
@@ -95,6 +25,49 @@ if [ ! -e $__INIT_TOOLS_DONE_MARKER ]; then
9525
if [ -e $__TOOLRUNTIME_DIR ]; then rm -rf -- $__TOOLRUNTIME_DIR; fi
9626
echo "Running: $__scriptpath/init-tools.sh" > $__init_tools_log
9727
if [ ! -e $__DOTNET_PATH ]; then
28+
if [ -z "$__DOTNET_PKG" ]; then
29+
__PKG_ARCH=x64
30+
31+
OSName=$(uname -s)
32+
case $OSName in
33+
Darwin)
34+
__PKG_RID=osx
35+
OS=OSX
36+
ulimit -n 2048
37+
;;
38+
39+
Linux)
40+
__PKG_RID=linux
41+
OS=Linux
42+
43+
if [ -e /etc/os-release ]; then
44+
source /etc/os-release
45+
__DISTRO_NAME=$ID.$VERSION_ID
46+
if [ "$__DISTRO_NAME" == 'ubuntu.16.04' ] ||
47+
[ "$__DISTRO_NAME" == 'ubuntu.16.10' ] ||
48+
[ "$__DISTRO_NAME" == 'ubuntu.18.04' ] ||
49+
[ "$__DISTRO_NAME" == 'debian.8' ] ||
50+
[ "$__DISTRO_NAME" == 'fedora.23' ] ||
51+
[ "$__DISTRO_NAME" == 'fedora.24' ] ||
52+
[ "$__DISTRO_NAME" == 'fedora.27' ] ||
53+
[ "$__DISTRO_NAME" == 'opensuse.13.2' ] ||
54+
[ "$__DISTRO_NAME" == 'opensuse.42.1' ] ||
55+
[ "$__DISTRO_NAME" == 'opensuse.42.3' ] ; then
56+
__PKG_RID=$__DISTRO_NAME
57+
fi
58+
fi
59+
60+
;;
61+
*)
62+
echo "Unsupported OS '$OSName' detected. Downloading linux-$__PKG_ARCH tools."
63+
OS=Linux
64+
__PKG_RID=linux
65+
;;
66+
esac
67+
68+
__DOTNET_PKG=dotnet-dev-$__PKG_RID-$__PKG_ARCH
69+
fi
70+
9871
echo "Installing dotnet cli..."
9972
__DOTNET_LOCATION="https://dotnetcli.blob.core.windows.net/dotnet/Sdk/${__DOTNET_TOOLS_VERSION}/${__DOTNET_PKG}.${__DOTNET_TOOLS_VERSION}.tar.gz"
10073
# curl has HTTPS CA trust-issues less often than wget, so lets try that first.

0 commit comments

Comments
 (0)