apply PR feedback

This commit is contained in:
Krzysztof Wicher 2016-03-14 11:46:14 -07:00
parent 138cfb4f69
commit 8fca17e56f
2 changed files with 37 additions and 43 deletions

View file

@ -26,9 +26,9 @@
Default: %LocalAppData%\Microsoft\.dotnet Default: %LocalAppData%\Microsoft\.dotnet
Path to where to install dotnet. Note that binaries will be placed directly in a given directory. Path to where to install dotnet. Note that binaries will be placed directly in a given directory.
.PARAMETER Architecture .PARAMETER Architecture
Default: auto - this value represents currently running OS architecture Default: <auto> - this value represents currently running OS architecture
Architecture of dotnet binaries to be installed. Architecture of dotnet binaries to be installed.
Possible values are: auto, x64 and x86 Possible values are: <auto>, x64 and x86
.PARAMETER DebugSymbols .PARAMETER DebugSymbols
If set the installer will include symbols in the installation. If set the installer will include symbols in the installation.
.PARAMETER DryRun .PARAMETER DryRun
@ -49,8 +49,8 @@
param( param(
[string]$Channel="preview", [string]$Channel="preview",
[string]$Version="Latest", [string]$Version="Latest",
[string]$InstallDir="<usershare>", [string]$InstallDir="<auto>",
[string]$Architecture="auto", [string]$Architecture="<auto>",
[switch]$DebugSymbols, # TODO: Switch does not work yet. Symbols zip is not being uploaded yet. [switch]$DebugSymbols, # TODO: Switch does not work yet. Symbols zip is not being uploaded yet.
[switch]$DryRun, [switch]$DryRun,
[switch]$NoPath, [switch]$NoPath,
@ -90,7 +90,7 @@ function Get-CLIArchitecture-From-Architecture([string]$Architecture) {
Say-Invocation $MyInvocation Say-Invocation $MyInvocation
switch ($Architecture.ToLower()) { switch ($Architecture.ToLower()) {
{ $_ -eq "auto" } { return Get-CLIArchitecture-From-Architecture $(Get-Machine-Architecture) } { $_ -eq "<auto>" } { return Get-CLIArchitecture-From-Architecture $(Get-Machine-Architecture) }
{ ($_ -eq "amd64") -or ($_ -eq "x64") } { return "x64" } { ($_ -eq "amd64") -or ($_ -eq "x64") } { return "x64" }
{ $_ -eq "x86" } { return "x86" } { $_ -eq "x86" } { return "x86" }
default { throw "Architecture not supported. If you think this is a bug, please report it at https://github.com/dotnet/cli/issues" } default { throw "Architecture not supported. If you think this is a bug, please report it at https://github.com/dotnet/cli/issues" }
@ -167,7 +167,7 @@ function Get-User-Share-Path() {
function Resolve-Installation-Path([string]$InstallDir) { function Resolve-Installation-Path([string]$InstallDir) {
Say-Invocation $MyInvocation Say-Invocation $MyInvocation
if ($InstallDir -eq "<usershare>") { if ($InstallDir -eq "<auto>") {
return Get-User-Share-Path return Get-User-Share-Path
} }
return $InstallDir return $InstallDir

View file

@ -13,7 +13,7 @@ set -u
set -o pipefail set -o pipefail
# Use in the the functions: eval $invocation # Use in the the functions: eval $invocation
invocation='say_verbose "Calling: ${red:-}${FUNCNAME[0]} ${green:-}$*${normal:-}"' invocation='say_verbose "Calling: ${yellow:-}${FUNCNAME[0]} ${green:-}$*${normal:-}"'
# standard output may be used as a return value in the functions # standard output may be used as a return value in the functions
# we need a way to write text on the screen in the functions so that # we need a way to write text on the screen in the functions so that
@ -110,12 +110,6 @@ check_pre_reqs() {
fi fi
if [ "$(uname)" = "Linux" ]; then if [ "$(uname)" = "Linux" ]; then
[ -z "$(ldconfig -p | grep libunwind)" ] && say_err "Unable to locate libunwind. Install libunwind to continue" && _failing=true
[ -z "$(ldconfig -p | grep libssl)" ] && say_err "Unable to locate libssl. Install libssl to continue" && _failing=true
[ -z "$(ldconfig -p | grep libcurl)" ] && say_err "Unable to locate libcurl. Install libcurl to continue" && _failing=true
[ -z "$(ldconfig -p | grep libicu)" ] && say_err "Unable to locate libicu. Install libicu to continue" && _failing=true
[ -z "$(ldconfig -p | grep gettext)" ] && say_err "Unable to locate gettext. Install gettext to continue" && _failing=true
if ! [ -x "$(command -v ldconfig)" ]; then if ! [ -x "$(command -v ldconfig)" ]; then
echo "ldconfig is not in PATH, trying /sbin/ldconfig." echo "ldconfig is not in PATH, trying /sbin/ldconfig."
LDCONFIG_COMMAND="/sbin/ldconfig" LDCONFIG_COMMAND="/sbin/ldconfig"
@ -123,11 +117,11 @@ check_pre_reqs() {
LDCONFIG_COMMAND="ldconfig" LDCONFIG_COMMAND="ldconfig"
fi fi
[ -z "$($LDCONFIG_COMMAND -p | grep libunwind)" ] && say_err "Unable to locate libunwind. Install libunwind to continue" && _failing=true [ -z "$($LDCONFIG_COMMAND -p | grep libunwind)" ] && say_err "Unable to locate libunwind. Install libunwind to continue" && failing=true
[ -z "$($LDCONFIG_COMMAND -p | grep libssl)" ] && say_err "Unable to locate libssl. Install libssl to continue" && _failing=true [ -z "$($LDCONFIG_COMMAND -p | grep libssl)" ] && say_err "Unable to locate libssl. Install libssl to continue" && failing=true
[ -z "$($LDCONFIG_COMMAND -p | grep libcurl)" ] && say_err "Unable to locate libcurl. Install libcurl to continue" && _failing=true [ -z "$($LDCONFIG_COMMAND -p | grep libcurl)" ] && say_err "Unable to locate libcurl. Install libcurl to continue" && failing=true
[ -z "$($LDCONFIG_COMMAND -p | grep libicu)" ] && say_err "Unable to locate libicu. Install libicu to continue" && _failing=true [ -z "$($LDCONFIG_COMMAND -p | grep libicu)" ] && say_err "Unable to locate libicu. Install libicu to continue" && failing=true
[ -z "$($LDCONFIG_COMMAND -p | grep gettext)" ] && say_err "Unable to locate gettext. Install gettext to continue" && _failing=true [ -z "$($LDCONFIG_COMMAND -p | grep gettext)" ] && say_err "Unable to locate gettext. Install gettext to continue" && failing=true
fi fi
if [ "$failing" = true ]; then if [ "$failing" = true ]; then
@ -148,7 +142,7 @@ to_lowercase() {
# args: # args:
# input - $1 # input - $1
remove_trailing_backslash() { remove_trailing_slash() {
eval $invocation eval $invocation
echo "${1%/}" echo "${1%/}"
@ -157,7 +151,7 @@ remove_trailing_backslash() {
# args: # args:
# input - $1 # input - $1
remove_beginning_backslash() { remove_beginning_slash() {
eval $invocation eval $invocation
echo "${1#/}" echo "${1#/}"
@ -176,8 +170,8 @@ combine_paths() {
return 1 return 1
fi fi
local root_path=$(remove_trailing_backslash $1) local root_path=$(remove_trailing_slash $1)
local child_path=$(remove_beginning_backslash $2) local child_path=$(remove_beginning_slash $2)
say_verbose "combine_paths: root_path=$root_path" say_verbose "combine_paths: root_path=$root_path"
say_verbose "combine_paths: child_path=$child_path" say_verbose "combine_paths: child_path=$child_path"
echo "$root_path/$child_path" echo "$root_path/$child_path"
@ -194,13 +188,13 @@ get_machine_architecture() {
# args: # args:
# architecture - $1 # architecture - $1
get_cli_architecture_from_architecture() { get_normalized_architecture_from_architecture() {
eval $invocation eval $invocation
local architecture=$(to_lowercase $1) local architecture=$(to_lowercase $1)
case $architecture in case $architecture in
auto) \<auto\>)
echo "$(get_cli_architecture_from_architecture $(get_machine_architecture))" echo "$(get_normalized_architecture_from_architecture $(get_machine_architecture))"
return 0 return 0
;; ;;
amd64|x64) amd64|x64)
@ -213,7 +207,7 @@ get_cli_architecture_from_architecture() {
;; ;;
esac esac
say_err "Architecture not supported. If you think this is a bug, please report it at https://github.com/dotnet/cli/issues" say_err "Architecture ``$architecture`` not supported. If you think this is a bug, please report it at https://github.com/dotnet/cli/issues"
return 1 return 1
} }
@ -243,13 +237,13 @@ get_commit_hash_from_version_info() {
# args: # args:
# azure_feed - $1 # azure_feed - $1
# azure_channel - $2 # azure_channel - $2
# cli_architecture - $3 # normalized_architecture - $3
get_latest_version_info() { get_latest_version_info() {
eval $invocation eval $invocation
local azure_feed=$1 local azure_feed=$1
local azure_channel=$2 local azure_channel=$2
local cli_architecture=$3 local normalized_architecture=$3
local osname=$(get_current_os_name) local osname=$(get_current_os_name)
@ -287,19 +281,19 @@ get_azure_channel_from_channel() {
# args: # args:
# azure_feed - $1 # azure_feed - $1
# azure_channel - $2 # azure_channel - $2
# cli_architecture - $3 # normalized_architecture - $3
# version - $4 # version - $4
get_specific_version_from_version() { get_specific_version_from_version() {
eval $invocation eval $invocation
local azure_feed=$1 local azure_feed=$1
local azure_channel=$2 local azure_channel=$2
local cli_architecture=$3 local normalized_architecture=$3
local version=$(to_lowercase $4) local version=$(to_lowercase $4)
case $version in case $version in
latest) latest)
local version_info="$(get_latest_version_info $1 $2 $3)" local version_info="$(get_latest_version_info $azure_feed $azure_channel $normalized_architecture)"
say_verbose "get_specific_version_from_version: version_info=$version_info" say_verbose "get_specific_version_from_version: version_info=$version_info"
echo "$version_info" | get_version_from_version_info echo "$version_info" | get_version_from_version_info
return 0 return 0
@ -318,19 +312,19 @@ get_specific_version_from_version() {
# args: # args:
# azure_feed - $1 # azure_feed - $1
# azure_channel - $2 # azure_channel - $2
# cli_architecture - $3 # normalized_architecture - $3
# specific_version - $4 # specific_version - $4
construct_download_link() { construct_download_link() {
eval $invocation eval $invocation
local azure_feed=$1 local azure_feed=$1
local azure_channel=$2 local azure_channel=$2
local cli_architecture=$3 local normalized_architecture=$3
local specific_version=$4 local specific_version=$4
local osname=$(get_current_os_name) local osname=$(get_current_os_name)
local download_link="$azure_feed/$azure_channel/Binaries/$specific_version/dotnet-$osname-$cli_architecture.$specific_version.tar.gz" local download_link="$azure_feed/$azure_channel/Binaries/$specific_version/dotnet-$osname-$normalized_architecture.$specific_version.tar.gz"
echo "$download_link" echo "$download_link"
return 0 return 0
} }
@ -354,7 +348,7 @@ resolve_installation_path() {
eval $invocation eval $invocation
local install_dir=$1 local install_dir=$1
if [ "$install_dir" == "<usershare>" ]; then if [ "$install_dir" == "<auto>" ]; then
local user_share_path=$(get_user_share_path) local user_share_path=$(get_user_share_path)
say_verbose "resolve_installation_path: share_path=$user_share_path" say_verbose "resolve_installation_path: share_path=$user_share_path"
echo "$user_share_path" echo "$user_share_path"
@ -438,17 +432,17 @@ calculate_vars() {
azure_channel=$(get_azure_channel_from_channel "$channel") azure_channel=$(get_azure_channel_from_channel "$channel")
say_verbose "azure_channel=$azure_channel" say_verbose "azure_channel=$azure_channel"
cli_architecture=$(get_cli_architecture_from_architecture "$architecture") normalized_architecture=$(get_normalized_architecture_from_architecture "$architecture")
say_verbose "cli_architecture=$cli_architecture" say_verbose "normalized_architecture=$normalized_architecture"
specific_version=$(get_specific_version_from_version $azure_feed $azure_channel $cli_architecture $version) specific_version=$(get_specific_version_from_version $azure_feed $azure_channel $normalized_architecture $version)
say_verbose "specific_version=$specific_version" say_verbose "specific_version=$specific_version"
if [ -z "$specific_version" ]; then if [ -z "$specific_version" ]; then
say_err "Could not get version information." say_err "Could not get version information."
return 1 return 1
fi fi
download_link=$(construct_download_link $azure_feed $azure_channel $cli_architecture $specific_version) download_link=$(construct_download_link $azure_feed $azure_channel $normalized_architecture $specific_version)
say_verbose "download_link=$download_link" say_verbose "download_link=$download_link"
install_root=$(resolve_installation_path $install_dir) install_root=$(resolve_installation_path $install_dir)
@ -462,7 +456,7 @@ install_dotnet() {
local local_version local local_version
local version_text local version_text
if [ -z "$local_version_info" ]; then if [ -z "$local_version_info" ]; then
version_text="<No CLI installed>" version_text="<No .NET CLI installed>"
else else
local_version=$(echo "$local_version_info" | get_version_from_version_info) local_version=$(echo "$local_version_info" | get_version_from_version_info)
version_text=$local_version version_text=$local_version
@ -470,7 +464,7 @@ install_dotnet() {
say_verbose "Local CLI version is: $version_text" say_verbose "Local CLI version is: $version_text"
if [ ! -z "${local_version:-}" ] && [ "$specific_version" == "$local_version" ]; then if [ ! -z "${local_version:-}" ] && [ "$specific_version" == "$local_version" ]; then
say "Your version of CLI is up-to-date." say "Your version of .NET CLI is up-to-date."
return 0 return 0
fi fi
@ -492,8 +486,8 @@ bin_folder_relative_path="/bin"
channel="preview" channel="preview"
version="Latest" version="Latest"
install_dir="<usershare>" install_dir="<auto>"
architecture="auto" architecture="<auto>"
debug_symbols=false debug_symbols=false
dry_run=false dry_run=false
no_path=false no_path=false