parent
4f927448e9
commit
0d5270086f
85
dnvm.ps1
85
dnvm.ps1
|
|
@ -67,7 +67,7 @@ function _WriteOut {
|
||||||
|
|
||||||
### Constants
|
### Constants
|
||||||
$ProductVersion="1.0.0"
|
$ProductVersion="1.0.0"
|
||||||
$BuildVersion="beta8-15502"
|
$BuildVersion="beta8-15506"
|
||||||
$Authors="Microsoft Open Technologies, Inc."
|
$Authors="Microsoft Open Technologies, Inc."
|
||||||
|
|
||||||
# If the Version hasn't been replaced...
|
# If the Version hasn't been replaced...
|
||||||
|
|
@ -82,6 +82,7 @@ $FullVersion="$ProductVersion-$BuildVersion"
|
||||||
Set-Variable -Option Constant "CommandName" ([IO.Path]::GetFileNameWithoutExtension($ScriptPath))
|
Set-Variable -Option Constant "CommandName" ([IO.Path]::GetFileNameWithoutExtension($ScriptPath))
|
||||||
Set-Variable -Option Constant "CommandFriendlyName" ".NET Version Manager"
|
Set-Variable -Option Constant "CommandFriendlyName" ".NET Version Manager"
|
||||||
Set-Variable -Option Constant "DefaultUserDirectoryName" ".dnx"
|
Set-Variable -Option Constant "DefaultUserDirectoryName" ".dnx"
|
||||||
|
Set-Variable -Option Constant "DefaultGlobalDirectoryName" "Microsoft DNX"
|
||||||
Set-Variable -Option Constant "OldUserDirectoryNames" @(".kre", ".k")
|
Set-Variable -Option Constant "OldUserDirectoryNames" @(".kre", ".k")
|
||||||
Set-Variable -Option Constant "RuntimePackageName" "dnx"
|
Set-Variable -Option Constant "RuntimePackageName" "dnx"
|
||||||
Set-Variable -Option Constant "DefaultFeed" "https://www.nuget.org/api/v2"
|
Set-Variable -Option Constant "DefaultFeed" "https://www.nuget.org/api/v2"
|
||||||
|
|
@ -155,6 +156,7 @@ $DeprecatedCommands = @("unalias")
|
||||||
# Load Environment variables
|
# Load Environment variables
|
||||||
$RuntimeHomes = $env:DNX_HOME
|
$RuntimeHomes = $env:DNX_HOME
|
||||||
$UserHome = $env:DNX_USER_HOME
|
$UserHome = $env:DNX_USER_HOME
|
||||||
|
$GlobalHome = $env:DNX_GLOBAL_HOME
|
||||||
$ActiveFeed = $env:DNX_FEED
|
$ActiveFeed = $env:DNX_FEED
|
||||||
$ActiveUnstableFeed = $env:DNX_UNSTABLE_FEED
|
$ActiveUnstableFeed = $env:DNX_UNSTABLE_FEED
|
||||||
|
|
||||||
|
|
@ -182,11 +184,24 @@ if($CmdPathFile) {
|
||||||
# Determine where runtimes can exist (RuntimeHomes)
|
# Determine where runtimes can exist (RuntimeHomes)
|
||||||
if(!$RuntimeHomes) {
|
if(!$RuntimeHomes) {
|
||||||
# Set up a default value for the runtime home
|
# Set up a default value for the runtime home
|
||||||
$UnencodedHomes = "%USERPROFILE%\$DefaultUserDirectoryName"
|
$UnencodedHomes = "$env:USERPROFILE\$DefaultUserDirectoryName;$GlobalHome\$DefaultGlobalDirectoryName"
|
||||||
} else {
|
} else {
|
||||||
$UnencodedHomes = $RuntimeHomes
|
$UnencodedHomes = $RuntimeHomes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Determine the default global installation directory (GlobalHome)
|
||||||
|
if(!$GlobalHome) {
|
||||||
|
if($env:ProgramData) {
|
||||||
|
$GlobalHome = "$env:ProgramData\$DefaultGlobalDirectoryName"
|
||||||
|
} else {
|
||||||
|
$GlobalHome = "$env:AllUsersProfile\$DefaultGlobalDirectoryName"
|
||||||
|
}
|
||||||
|
|
||||||
|
$env:DNX_GLOBAL_HOME="$GlobalHome"
|
||||||
|
$env:DNX_HOME="$env:DNX_HOME;$env:DNX_GLOBAL_HOME"
|
||||||
|
$UnencodedHomes = "$UnencodedHomes;$GlobalHome"
|
||||||
|
}
|
||||||
|
|
||||||
$UnencodedHomes = $UnencodedHomes.Split(";")
|
$UnencodedHomes = $UnencodedHomes.Split(";")
|
||||||
$RuntimeHomes = $UnencodedHomes | ForEach-Object { [Environment]::ExpandEnvironmentVariables($_) }
|
$RuntimeHomes = $UnencodedHomes | ForEach-Object { [Environment]::ExpandEnvironmentVariables($_) }
|
||||||
$RuntimeDirs = $RuntimeHomes | ForEach-Object { Join-Path $_ "runtimes" }
|
$RuntimeDirs = $RuntimeHomes | ForEach-Object { Join-Path $_ "runtimes" }
|
||||||
|
|
@ -221,6 +236,7 @@ _WriteDebug "Runtime Homes: $RuntimeHomes"
|
||||||
_WriteDebug "User Home: $UserHome"
|
_WriteDebug "User Home: $UserHome"
|
||||||
$AliasesDir = Join-Path $UserHome "alias"
|
$AliasesDir = Join-Path $UserHome "alias"
|
||||||
$RuntimesDir = Join-Path $UserHome "runtimes"
|
$RuntimesDir = Join-Path $UserHome "runtimes"
|
||||||
|
$GlobalRuntimesDir = Join-Path $GlobalHome "runtimes"
|
||||||
$Aliases = $null
|
$Aliases = $null
|
||||||
|
|
||||||
### Helper Functions
|
### Helper Functions
|
||||||
|
|
@ -394,7 +410,7 @@ function Get-RuntimeAliasOrRuntimeInfo(
|
||||||
}
|
}
|
||||||
|
|
||||||
filter List-Parts {
|
filter List-Parts {
|
||||||
param($aliases)
|
param($aliases, $items)
|
||||||
|
|
||||||
$location = ""
|
$location = ""
|
||||||
|
|
||||||
|
|
@ -422,6 +438,20 @@ filter List-Parts {
|
||||||
$parts2 += "x86/x64"
|
$parts2 += "x86/x64"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$aliasUsed = ""
|
||||||
|
if($items) {
|
||||||
|
$aliasUsed = $items | ForEach-Object {
|
||||||
|
if($_.Architecture -eq $parts2[3] -and $_.Runtime -eq $parts2[1] -and $_.OperatingSystem -eq $parts2[2] -and $_.Version -eq $parts1[1]) {
|
||||||
|
return $true;
|
||||||
|
}
|
||||||
|
return $false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($aliasUsed -eq $true) {
|
||||||
|
$fullAlias = ""
|
||||||
|
}
|
||||||
|
|
||||||
return New-Object PSObject -Property @{
|
return New-Object PSObject -Property @{
|
||||||
Active = $active
|
Active = $active
|
||||||
Version = $parts1[1]
|
Version = $parts1[1]
|
||||||
|
|
@ -693,7 +723,7 @@ function Get-RuntimePath($runtimeFullName) {
|
||||||
foreach($RuntimeHome in $RuntimeHomes) {
|
foreach($RuntimeHome in $RuntimeHomes) {
|
||||||
$runtimeBin = "$RuntimeHome\runtimes\$runtimeFullName\bin"
|
$runtimeBin = "$RuntimeHome\runtimes\$runtimeFullName\bin"
|
||||||
_WriteDebug " Candidate $runtimeBin"
|
_WriteDebug " Candidate $runtimeBin"
|
||||||
if (Test-Path "$runtimeBin") {
|
if (Test-Path $runtimeBin) {
|
||||||
_WriteDebug " Found in $runtimeBin"
|
_WriteDebug " Found in $runtimeBin"
|
||||||
return $runtimeBin
|
return $runtimeBin
|
||||||
}
|
}
|
||||||
|
|
@ -976,7 +1006,7 @@ function dnvm-list {
|
||||||
$RuntimeHomes | ForEach-Object {
|
$RuntimeHomes | ForEach-Object {
|
||||||
_WriteDebug "Scanning $_ for runtimes..."
|
_WriteDebug "Scanning $_ for runtimes..."
|
||||||
if (Test-Path "$_\runtimes") {
|
if (Test-Path "$_\runtimes") {
|
||||||
$items += Get-ChildItem "$_\runtimes\$RuntimePackageName-*" | List-Parts $aliases
|
$items += Get-ChildItem "$_\runtimes\$RuntimePackageName-*" | List-Parts $aliases $items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1104,7 +1134,9 @@ function dnvm-unalias {
|
||||||
.PARAMETER Ngen
|
.PARAMETER Ngen
|
||||||
For CLR flavor only. Generate native images for runtime libraries on Desktop CLR to improve startup time. This option requires elevated privilege and will be automatically turned on if the script is running in administrative mode. To opt-out in administrative mode, use -NoNative switch.
|
For CLR flavor only. Generate native images for runtime libraries on Desktop CLR to improve startup time. This option requires elevated privilege and will be automatically turned on if the script is running in administrative mode. To opt-out in administrative mode, use -NoNative switch.
|
||||||
.PARAMETER Unstable
|
.PARAMETER Unstable
|
||||||
Upgrade from our unstable dev feed. This will give you the latest development version of the runtime.
|
Upgrade from the unstable dev feed. This will give you the latest development version of the runtime.
|
||||||
|
.PARAMETER Global
|
||||||
|
Installs to configured global dnx file location (default: C:\ProgramData)
|
||||||
#>
|
#>
|
||||||
function dnvm-upgrade {
|
function dnvm-upgrade {
|
||||||
param(
|
param(
|
||||||
|
|
@ -1140,7 +1172,10 @@ function dnvm-upgrade {
|
||||||
[switch]$Ngen,
|
[switch]$Ngen,
|
||||||
|
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[switch]$Unstable)
|
[switch]$Unstable,
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[switch]$Global)
|
||||||
|
|
||||||
if($OS -ne "win" -and ![String]::IsNullOrEmpty($OS)) {
|
if($OS -ne "win" -and ![String]::IsNullOrEmpty($OS)) {
|
||||||
#We could remove OS as an option from upgrade, but I want to take this opporunty to educate users about the difference between install and upgrade
|
#We could remove OS as an option from upgrade, but I want to take this opporunty to educate users about the difference between install and upgrade
|
||||||
|
|
@ -1150,7 +1185,7 @@ function dnvm-upgrade {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
dnvm-install "latest" -Alias:$Alias -Architecture:$Architecture -Runtime:$Runtime -OS:$OS -Force:$Force -Proxy:$Proxy -NoNative:$NoNative -Ngen:$Ngen -Unstable:$Unstable -Persistent:$true
|
dnvm-install "latest" -Alias:$Alias -Architecture:$Architecture -Runtime:$Runtime -OS:$OS -Force:$Force -Proxy:$Proxy -NoNative:$NoNative -Ngen:$Ngen -Unstable:$Unstable -Persistent:$true -Global:$Global
|
||||||
}
|
}
|
||||||
|
|
||||||
<#
|
<#
|
||||||
|
|
@ -1179,7 +1214,9 @@ function dnvm-upgrade {
|
||||||
.PARAMETER Persistent
|
.PARAMETER Persistent
|
||||||
Make the installed runtime useable across all processes run by the current user
|
Make the installed runtime useable across all processes run by the current user
|
||||||
.PARAMETER Unstable
|
.PARAMETER Unstable
|
||||||
Upgrade from our unstable dev feed. This will give you the latest development version of the runtime.
|
Upgrade from the unstable dev feed. This will give you the latest development version of the runtime.
|
||||||
|
.PARAMETER Global
|
||||||
|
Installs to configured global dnx file location (default: C:\ProgramData)
|
||||||
.DESCRIPTION
|
.DESCRIPTION
|
||||||
A proxy can also be specified by using the 'http_proxy' environment variable
|
A proxy can also be specified by using the 'http_proxy' environment variable
|
||||||
#>
|
#>
|
||||||
|
|
@ -1223,7 +1260,10 @@ function dnvm-install {
|
||||||
[switch]$Persistent,
|
[switch]$Persistent,
|
||||||
|
|
||||||
[Parameter(Mandatory=$false)]
|
[Parameter(Mandatory=$false)]
|
||||||
[switch]$Unstable)
|
[switch]$Unstable,
|
||||||
|
|
||||||
|
[Parameter(Mandatory=$false)]
|
||||||
|
[switch]$Global)
|
||||||
|
|
||||||
$selectedFeed = ""
|
$selectedFeed = ""
|
||||||
|
|
||||||
|
|
@ -1279,7 +1319,7 @@ function dnvm-install {
|
||||||
$Version = Get-PackageVersion $BaseName
|
$Version = Get-PackageVersion $BaseName
|
||||||
}
|
}
|
||||||
|
|
||||||
if([String]::IsNullOrEmpty($Architecture)) {
|
if([String]::IsNullOrEmpty($OS)) {
|
||||||
$OS = Get-PackageOS $BaseName
|
$OS = Get-PackageOS $BaseName
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -1313,7 +1353,15 @@ function dnvm-install {
|
||||||
_WriteDebug "Version: $($runtimeInfo.Version)"
|
_WriteDebug "Version: $($runtimeInfo.Version)"
|
||||||
_WriteDebug "OS: $($runtimeInfo.OS)"
|
_WriteDebug "OS: $($runtimeInfo.OS)"
|
||||||
|
|
||||||
$RuntimeFolder = Join-Path $RuntimesDir $($runtimeInfo.RuntimeName)
|
$installDir = $RuntimesDir
|
||||||
|
if (!$Global) {
|
||||||
|
$RuntimeFolder = Join-Path $RuntimesDir $($runtimeInfo.RuntimeName)
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$installDir = $GlobalRuntimesDir
|
||||||
|
$RuntimeFolder = Join-Path $GlobalRuntimesDir $($runtimeInfo.RuntimeName)
|
||||||
|
}
|
||||||
|
|
||||||
_WriteDebug "Destination: $RuntimeFolder"
|
_WriteDebug "Destination: $RuntimeFolder"
|
||||||
|
|
||||||
if((Test-Path $RuntimeFolder) -and $Force) {
|
if((Test-Path $RuntimeFolder) -and $Force) {
|
||||||
|
|
@ -1321,8 +1369,15 @@ function dnvm-install {
|
||||||
Remove-Item $RuntimeFolder -Recurse -Force
|
Remove-Item $RuntimeFolder -Recurse -Force
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Test-Path $RuntimeFolder) {
|
$installed=""
|
||||||
_WriteOut "'$($runtimeInfo.RuntimeName)' is already installed."
|
if(Test-Path (Join-Path $RuntimesDir $($runtimeInfo.RuntimeName))) {
|
||||||
|
$installed = Join-Path $RuntimesDir $($runtimeInfo.RuntimeName)
|
||||||
|
}
|
||||||
|
if(Test-Path (Join-Path $GlobalRuntimesDir $($runtimeInfo.RuntimeName))) {
|
||||||
|
$installed = Join-Path $GlobalRuntimesDir $($runtimeInfo.RuntimeName)
|
||||||
|
}
|
||||||
|
if($installed -ne "") {
|
||||||
|
_WriteOut "'$($runtimeInfo.RuntimeName)' is already installed in $installed."
|
||||||
if($runtimeInfo.OS -eq "win") {
|
if($runtimeInfo.OS -eq "win") {
|
||||||
dnvm-use $runtimeInfo.Version -Architecture:$runtimeInfo.Architecture -Runtime:$runtimeInfo.Runtime -Persistent:$Persistent -OS:$runtimeInfo.OS
|
dnvm-use $runtimeInfo.Version -Architecture:$runtimeInfo.Architecture -Runtime:$runtimeInfo.Runtime -Persistent:$Persistent -OS:$runtimeInfo.OS
|
||||||
}
|
}
|
||||||
|
|
@ -1333,7 +1388,7 @@ function dnvm-install {
|
||||||
$Runtime = $runtimeInfo.Runtime
|
$Runtime = $runtimeInfo.Runtime
|
||||||
$OS = $runtimeInfo.OS
|
$OS = $runtimeInfo.OS
|
||||||
|
|
||||||
$TempFolder = Join-Path $RuntimesDir "temp"
|
$TempFolder = Join-Path $installDir "temp"
|
||||||
$UnpackFolder = Join-Path $TempFolder $runtimeFullName
|
$UnpackFolder = Join-Path $TempFolder $runtimeFullName
|
||||||
$DownloadFile = Join-Path $UnpackFolder "$runtimeFullName.nupkg"
|
$DownloadFile = Join-Path $UnpackFolder "$runtimeFullName.nupkg"
|
||||||
|
|
||||||
|
|
|
||||||
180
dnvm.sh
180
dnvm.sh
|
|
@ -2,7 +2,7 @@
|
||||||
# Source this file from your .bash-profile or script to use
|
# Source this file from your .bash-profile or script to use
|
||||||
|
|
||||||
# "Constants"
|
# "Constants"
|
||||||
_DNVM_BUILDNUMBER="beta8-15502"
|
_DNVM_BUILDNUMBER="beta8-15506"
|
||||||
_DNVM_AUTHORS="Microsoft Open Technologies, Inc."
|
_DNVM_AUTHORS="Microsoft Open Technologies, Inc."
|
||||||
_DNVM_RUNTIME_PACKAGE_NAME="dnx"
|
_DNVM_RUNTIME_PACKAGE_NAME="dnx"
|
||||||
_DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment"
|
_DNVM_RUNTIME_FRIENDLY_NAME=".NET Execution Environment"
|
||||||
|
|
@ -46,12 +46,19 @@ if [ -z "$DNX_USER_HOME" ]; then
|
||||||
eval DNX_USER_HOME="~/$_DNVM_RUNTIME_FOLDER_NAME"
|
eval DNX_USER_HOME="~/$_DNVM_RUNTIME_FOLDER_NAME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ -z "$DNX_GLOBAL_HOME" ]; then
|
||||||
|
eval DNX_GLOBAL_HOME="/usr/local/lib/dnx"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -z "$DNX_HOME" ]; then
|
if [ -z "$DNX_HOME" ]; then
|
||||||
# Set to the user home value
|
# Set to the user home value
|
||||||
DNX_HOME="$DNX_USER_HOME"
|
eval DNX_HOME="$DNX_USER_HOME:$DNX_GLOBAL_HOME"
|
||||||
|
elif [[ $DNX_HOME != *"$DNX_GLOBAL_HOME"* ]]; then
|
||||||
|
eval DNX_HOME="$DNX_HOME:$DNX_GLOBAL_HOME"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_DNVM_USER_PACKAGES="$DNX_USER_HOME/runtimes"
|
_DNVM_USER_PACKAGES="$DNX_USER_HOME/runtimes"
|
||||||
|
_DNVM_GLOBAL_PACKAGES="$DNX_GLOBAL_HOME/runtimes"
|
||||||
_DNVM_ALIAS_DIR="$DNX_USER_HOME/alias"
|
_DNVM_ALIAS_DIR="$DNX_USER_HOME/alias"
|
||||||
_DNVM_DNVM_DIR="$DNX_USER_HOME/dnvm"
|
_DNVM_DNVM_DIR="$DNX_USER_HOME/dnvm"
|
||||||
|
|
||||||
|
|
@ -146,7 +153,7 @@ __dnvm_find_package() {
|
||||||
}
|
}
|
||||||
|
|
||||||
__dnvm_strip_path() {
|
__dnvm_strip_path() {
|
||||||
echo "$1" | sed -e "s#$_DNVM_USER_PACKAGES/[^/]*$2[^:]*:##g" -e "s#:$_DNVM_USER_PACKAGES/[^/]*$2[^:]*##g" -e "s#$_DNVM_USER_PACKAGES/[^/]*$2[^:]*##g"
|
echo "$1" | sed -e "s#$_DNVM_USER_PACKAGES/[^/]*$2[^:]*:##g" -e "s#:$_DNVM_USER_PACKAGES/[^/]*$2[^:]*##g" -e "s#$_DNVM_USER_PACKAGES/[^/]*$2[^:]*##g" | sed -e "s#$_DNVM_GLOBAL_PACKAGES/[^/]*$2[^:]*:##g" -e "s#:$_DNVM_GLOBAL_PACKAGES/[^/]*$2[^:]*##g" -e "s#$_DNVM_GLOBAL_PACKAGES/[^/]*$2[^:]*##g"
|
||||||
}
|
}
|
||||||
|
|
||||||
__dnvm_prepend_path() {
|
__dnvm_prepend_path() {
|
||||||
|
|
@ -183,7 +190,7 @@ __dnvm_package_arch() {
|
||||||
__dnvm_package_os() {
|
__dnvm_package_os() {
|
||||||
local runtimeFullName="$1"
|
local runtimeFullName="$1"
|
||||||
if [[ "$runtimeFullName" =~ "mono" ]]; then
|
if [[ "$runtimeFullName" =~ "mono" ]]; then
|
||||||
echo "linux/darwin"
|
echo "linux/osx"
|
||||||
else
|
else
|
||||||
echo "$runtimeFullName" | sed "s/$_DNVM_RUNTIME_PACKAGE_NAME-[^-.]*-\([^.-]*\).*/\1/"
|
echo "$runtimeFullName" | sed "s/$_DNVM_RUNTIME_PACKAGE_NAME-[^-.]*-\([^.-]*\).*/\1/"
|
||||||
fi
|
fi
|
||||||
|
|
@ -206,11 +213,29 @@ __dnvm_update_self() {
|
||||||
source "$dnvmFileLocation"
|
source "$dnvmFileLocation"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__dnvm_promptSudo() {
|
||||||
|
local acceptSudo="$1"
|
||||||
|
|
||||||
|
local answer=
|
||||||
|
if [ "$acceptSudo" == "0" ]; then
|
||||||
|
echo "In order to install dnx globally, dnvm will have to temporarily run as root."
|
||||||
|
read -p "You may be prompted for your password via 'sudo' during this process. Is this Ok? (y/N) " answer
|
||||||
|
else
|
||||||
|
answer="y"
|
||||||
|
fi
|
||||||
|
if echo $answer | grep -iq "^y" ; then
|
||||||
|
return 1
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
__dnvm_download() {
|
__dnvm_download() {
|
||||||
local runtimeFullName="$1"
|
local runtimeFullName="$1"
|
||||||
local downloadUrl="$2"
|
local downloadUrl="$2"
|
||||||
local runtimeFolder="$3"
|
local runtimeFolder="$3"
|
||||||
local force="$4"
|
local force="$4"
|
||||||
|
local acceptSudo="$5"
|
||||||
|
|
||||||
local pkgName=$(__dnvm_package_name "$runtimeFullName")
|
local pkgName=$(__dnvm_package_name "$runtimeFullName")
|
||||||
local pkgVersion=$(__dnvm_package_version "$runtimeFullName")
|
local pkgVersion=$(__dnvm_package_version "$runtimeFullName")
|
||||||
|
|
@ -231,12 +256,20 @@ __dnvm_download() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local useSudo=
|
||||||
mkdir -p "$runtimeFolder" > /dev/null 2>&1
|
mkdir -p "$runtimeFolder" > /dev/null 2>&1
|
||||||
|
if [ ! -d $runtimeFolder ]; then
|
||||||
|
if ! __dnvm_promptSudo $acceptSudo ; then
|
||||||
|
useSudo=sudo
|
||||||
|
sudo mkdir -p "$runtimeFolder" > /dev/null 2>&1 || return 1
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
echo "Downloading $runtimeFullName from $DNX_ACTIVE_FEED"
|
echo "Downloading $runtimeFullName from $DNX_ACTIVE_FEED"
|
||||||
echo "Download: $downloadUrl"
|
echo "Download: $downloadUrl"
|
||||||
|
|
||||||
local httpResult=$(curl -L -D - "$downloadUrl" -o "$runtimeFile" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/")
|
local httpResult=$($useSudo curl -L -D - "$downloadUrl" -o "$runtimeFile" -# | grep "^HTTP/1.1" | head -n 1 | sed "s/HTTP.1.1 \([0-9]*\).*/\1/")
|
||||||
|
|
||||||
if [[ $httpResult == "404" ]]; then
|
if [[ $httpResult == "404" ]]; then
|
||||||
printf "%b\n" "${Red}$runtimeFullName was not found in repository $DNX_ACTIVE_FEED ${RCol}"
|
printf "%b\n" "${Red}$runtimeFullName was not found in repository $DNX_ACTIVE_FEED ${RCol}"
|
||||||
|
|
@ -245,13 +278,14 @@ __dnvm_download() {
|
||||||
fi
|
fi
|
||||||
[[ $httpResult != "302" && $httpResult != "200" ]] && echo "${Red}HTTP Error $httpResult fetching $runtimeFullName from $DNX_ACTIVE_FEED ${RCol}" && return 1
|
[[ $httpResult != "302" && $httpResult != "200" ]] && echo "${Red}HTTP Error $httpResult fetching $runtimeFullName from $DNX_ACTIVE_FEED ${RCol}" && return 1
|
||||||
|
|
||||||
__dnvm_unpack $runtimeFile $runtimeFolder
|
__dnvm_unpack $runtimeFile $runtimeFolder $useSudo
|
||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
__dnvm_unpack() {
|
__dnvm_unpack() {
|
||||||
local runtimeFile="$1"
|
local runtimeFile="$1"
|
||||||
local runtimeFolder="$2"
|
local runtimeFolder="$2"
|
||||||
|
local useSudo=$3
|
||||||
|
|
||||||
echo "Installing to $runtimeFolder"
|
echo "Installing to $runtimeFolder"
|
||||||
|
|
||||||
|
|
@ -260,24 +294,24 @@ __dnvm_unpack() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
unzip $runtimeFile -d $runtimeFolder > /dev/null 2>&1
|
$useSudo unzip $runtimeFile -d $runtimeFolder > /dev/null 2>&1
|
||||||
|
|
||||||
[ -e "$runtimeFolder/[Content_Types].xml" ] && rm "$runtimeFolder/[Content_Types].xml"
|
[ -e "$runtimeFolder/[Content_Types].xml" ] && $useSudo rm "$runtimeFolder/[Content_Types].xml"
|
||||||
|
|
||||||
[ -e "$runtimeFolder/_rels/" ] && rm -rf "$runtimeFolder/_rels/"
|
[ -e "$runtimeFolder/_rels/" ] && $useSudo rm -rf "$runtimeFolder/_rels/"
|
||||||
|
|
||||||
[ -e "$runtimeFolder/package/" ] && rm -rf "$runtimeFolder/_package/"
|
[ -e "$runtimeFolder/package/" ] && $useSudo rm -rf "$runtimeFolder/_package/"
|
||||||
|
|
||||||
[ -e "$runtimeFile" ] && rm -f "$runtimeFile"
|
[ -e "$runtimeFile" ] && $useSudo rm -f "$runtimeFile"
|
||||||
|
|
||||||
#Set dnx to be executable
|
#Set dnx to be executable
|
||||||
if [[ -s "$runtimeFolder/bin/dnx" ]]; then
|
if [[ -s "$runtimeFolder/bin/dnx" ]]; then
|
||||||
chmod 775 "$runtimeFolder/bin/dnx"
|
$useSudo chmod 775 "$runtimeFolder/bin/dnx"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
#Set dnu to be executable
|
#Set dnu to be executable
|
||||||
if [[ -s "$runtimeFolder/bin/dnu" ]]; then
|
if [[ -s "$runtimeFolder/bin/dnu" ]]; then
|
||||||
chmod 775 "$runtimeFolder/bin/dnu"
|
$useSudo chmod 775 "$runtimeFolder/bin/dnu"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -306,6 +340,9 @@ __dnvm_requested_version_or_alias() {
|
||||||
if [ "$arch" != "" ]; then
|
if [ "$arch" != "" ]; then
|
||||||
local pkgArchitecture="$arch"
|
local pkgArchitecture="$arch"
|
||||||
fi
|
fi
|
||||||
|
if [ "$os" == "" ]; then
|
||||||
|
local pkgSystem=$(__dnvm_current_os)
|
||||||
|
fi
|
||||||
|
|
||||||
echo "$_DNVM_RUNTIME_PACKAGE_NAME-$runtime-$pkgSystem-$pkgArchitecture.$pkgVersion"
|
echo "$_DNVM_RUNTIME_PACKAGE_NAME-$runtime-$pkgSystem-$pkgArchitecture.$pkgVersion"
|
||||||
fi
|
fi
|
||||||
|
|
@ -316,7 +353,11 @@ __dnvm_requested_version_or_alias() {
|
||||||
# This will be more relevant if we support global installs
|
# This will be more relevant if we support global installs
|
||||||
__dnvm_locate_runtime_bin_from_full_name() {
|
__dnvm_locate_runtime_bin_from_full_name() {
|
||||||
local runtimeFullName=$1
|
local runtimeFullName=$1
|
||||||
[ -e "$_DNVM_USER_PACKAGES/$runtimeFullName/bin" ] && echo "$_DNVM_USER_PACKAGES/$runtimeFullName/bin" && return
|
for v in `echo $DNX_HOME | tr ":" "\n"`; do
|
||||||
|
if [ -e "$v/runtimes/$runtimeFullName/bin" ]; then
|
||||||
|
echo "$v/runtimes/$runtimeFullName/bin" && return
|
||||||
|
fi
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
__echo_art() {
|
__echo_art() {
|
||||||
|
|
@ -358,15 +399,17 @@ __dnvm_help() {
|
||||||
__dnvm_description
|
__dnvm_description
|
||||||
printf "%b\n" "${Cya}USAGE:${Yel} $_DNVM_COMMAND_NAME <command> [options] ${RCol}"
|
printf "%b\n" "${Cya}USAGE:${Yel} $_DNVM_COMMAND_NAME <command> [options] ${RCol}"
|
||||||
echo ""
|
echo ""
|
||||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME upgrade [-f|-force] [-u|-unstable] ${RCol}"
|
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME upgrade [-f|-force] [-u|-unstable] [-g|-global] [-y]${RCol}"
|
||||||
echo " install latest $_DNVM_RUNTIME_SHORT_NAME from feed"
|
echo " install latest $_DNVM_RUNTIME_SHORT_NAME from feed"
|
||||||
echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line"
|
echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line"
|
||||||
echo " set installed version as default"
|
echo " set installed version as default"
|
||||||
echo " -f|forces force upgrade. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed"
|
echo " -f|forces force upgrade. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed"
|
||||||
echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable feed"
|
echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable feed"
|
||||||
echo " -r|runtime The runtime flavor to install [clr or coreclr] (default: clr)"
|
echo " -r|runtime The runtime flavor to install [clr or coreclr] (default: clr)"
|
||||||
|
echo " -g|global Installs the latest $_DNVM_RUNTIME_SHORT_NAME in the configured global $_DNVM_RUNTIME_SHORT_NAME file location (default: /usr/local/lib/dnx current: $DNX_GLOBAL_HOME)"
|
||||||
|
echo " -y Assume Yes to all queries and do not prompt"
|
||||||
echo ""
|
echo ""
|
||||||
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME install <semver>|<alias>|<nupkg>|latest [-r <runtime>] [-OS <OS>] [-a|-alias <alias>] [-p|-persistent] [-f|-force] [-u|-unstable] ${RCol}"
|
printf "%b\n" "${Yel}$_DNVM_COMMAND_NAME install <semver>|<alias>|<nupkg>|latest [-r <runtime>] [-OS <OS>] [-a|-alias <alias>] [-p|-persistent] [-f|-force] [-u|-unstable] [-g|-global] [-y]${RCol}"
|
||||||
echo " <semver>|<alias> install requested $_DNVM_RUNTIME_SHORT_NAME from feed"
|
echo " <semver>|<alias> install requested $_DNVM_RUNTIME_SHORT_NAME from feed"
|
||||||
echo " <nupkg> install requested $_DNVM_RUNTIME_SHORT_NAME from local package on filesystem"
|
echo " <nupkg> install requested $_DNVM_RUNTIME_SHORT_NAME from local package on filesystem"
|
||||||
echo " latest install latest version of $_DNVM_RUNTIME_SHORT_NAME from feed"
|
echo " latest install latest version of $_DNVM_RUNTIME_SHORT_NAME from feed"
|
||||||
|
|
@ -376,6 +419,8 @@ __dnvm_help() {
|
||||||
echo " -f|force force install. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed"
|
echo " -f|force force install. Overwrite existing version of $_DNVM_RUNTIME_SHORT_NAME if already installed"
|
||||||
echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable feed"
|
echo " -u|unstable use unstable feed. Installs the $_DNVM_RUNTIME_SHORT_NAME from the unstable feed"
|
||||||
echo " -r|runtime The runtime flavor to install [mono or coreclr] (default: mono)"
|
echo " -r|runtime The runtime flavor to install [mono or coreclr] (default: mono)"
|
||||||
|
echo " -g|global Installs to the configured global $_DNVM_RUNTIME_SHORT_NAME file location (default: /usr/local/lib/dnx current: $DNX_GLOBAL_HOME)"
|
||||||
|
echo " -y Assume Yes to all queries and do not prompt"
|
||||||
echo ""
|
echo ""
|
||||||
echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line"
|
echo " adds $_DNVM_RUNTIME_SHORT_NAME bin to path of current command line"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
@ -460,6 +505,8 @@ dnvm()
|
||||||
local os=
|
local os=
|
||||||
local runtime=
|
local runtime=
|
||||||
local arch=
|
local arch=
|
||||||
|
local global=0
|
||||||
|
local acceptSudo=0
|
||||||
while [ $# -ne 0 ]
|
while [ $# -ne 0 ]
|
||||||
do
|
do
|
||||||
if [[ $1 == "-p" || $1 == "-persistent" ]]; then
|
if [[ $1 == "-p" || $1 == "-persistent" ]]; then
|
||||||
|
|
@ -477,6 +524,8 @@ dnvm()
|
||||||
elif [[ $1 == "-OS" ]]; then
|
elif [[ $1 == "-OS" ]]; then
|
||||||
local os=$2
|
local os=$2
|
||||||
shift
|
shift
|
||||||
|
elif [[ $1 == "-y" ]]; then
|
||||||
|
local acceptSudo=1
|
||||||
elif [[ $1 == "-arch" ]]; then
|
elif [[ $1 == "-arch" ]]; then
|
||||||
local arch=$2
|
local arch=$2
|
||||||
shift
|
shift
|
||||||
|
|
@ -485,7 +534,8 @@ dnvm()
|
||||||
printf "%b\n" "${Red}Architecture must be x86 or x64.${RCol}"
|
printf "%b\n" "${Red}Architecture must be x86 or x64.${RCol}"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
elif [[ $1 == "-g" || $1 == "-global" ]]; then
|
||||||
|
local global=1
|
||||||
elif [[ -n $1 ]]; then
|
elif [[ -n $1 ]]; then
|
||||||
[[ -n $versionOrAlias ]] && echo "Invalid option $1" && __dnvm_help && return 1
|
[[ -n $versionOrAlias ]] && echo "Invalid option $1" && __dnvm_help && return 1
|
||||||
local versionOrAlias=$1
|
local versionOrAlias=$1
|
||||||
|
|
@ -533,6 +583,11 @@ dnvm()
|
||||||
printf "%b\n" "${Yel}It appears you don't have Mono available. Remember to get Mono before trying to run $DNVM_RUNTIME_SHORT_NAME application. ${RCol}" >&2;
|
printf "%b\n" "${Yel}It appears you don't have Mono available. Remember to get Mono before trying to run $DNVM_RUNTIME_SHORT_NAME application. ${RCol}" >&2;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
local runtimeDir=$_DNVM_USER_PACKAGES
|
||||||
|
if [ $global == 1 ]; then
|
||||||
|
runtimeDir=$_DNVM_GLOBAL_PACKAGES
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$versionOrAlias" != *.nupkg ]]; then
|
if [[ "$versionOrAlias" != *.nupkg ]]; then
|
||||||
if [[ "$versionOrAlias" == "latest" ]]; then
|
if [[ "$versionOrAlias" == "latest" ]]; then
|
||||||
echo "Determining latest version"
|
echo "Determining latest version"
|
||||||
|
|
@ -542,12 +597,24 @@ dnvm()
|
||||||
else
|
else
|
||||||
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch" "$os")
|
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch" "$os")
|
||||||
local runtimeVersion=$(__dnvm_package_version "$runtimeFullName")
|
local runtimeVersion=$(__dnvm_package_version "$runtimeFullName")
|
||||||
|
|
||||||
read versionOrAlias downloadUrl < <(__dnvm_find_package "$runtime" "$arch" "$os" "$runtimeVersion")
|
read versionOrAlias downloadUrl < <(__dnvm_find_package "$runtime" "$arch" "$os" "$runtimeVersion")
|
||||||
[[ $? == 1 ]] && echo "Error: Could not find version $runtimeVersion in feed $DNX_ACTIVE_FEED" && return 1
|
[[ $? == 1 ]] && echo "Error: Could not find version $runtimeVersion in feed $DNX_ACTIVE_FEED" && return 1
|
||||||
fi
|
fi
|
||||||
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch" "$os")
|
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch" "$os")
|
||||||
local runtimeFolder="$_DNVM_USER_PACKAGES/$runtimeFullName"
|
local runtimeFolder="$runtimeDir/$runtimeFullName"
|
||||||
__dnvm_download "$runtimeFullName" "$downloadUrl" "$runtimeFolder" "$force"
|
|
||||||
|
local exist=0
|
||||||
|
for folder in `echo $DNX_HOME | tr ":" "\n"`; do
|
||||||
|
if [ -e "$folder/runtimes/$runtimeFullName" ]; then
|
||||||
|
echo "$runtimeFullName already installed in $folder"
|
||||||
|
exist=1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [[ $exist != 1 ]]; then
|
||||||
|
__dnvm_download "$runtimeFullName" "$downloadUrl" "$runtimeFolder" "$force" "$acceptSudo"
|
||||||
|
fi
|
||||||
[[ $? == 1 ]] && return 1
|
[[ $? == 1 ]] && return 1
|
||||||
if [[ "$os" == $(__dnvm_current_os) ]]; then
|
if [[ "$os" == $(__dnvm_current_os) ]]; then
|
||||||
$_DNVM_COMMAND_NAME use "$versionOrAlias" "$persistent" "-runtime" "$runtime" "-arch" "$arch"
|
$_DNVM_COMMAND_NAME use "$versionOrAlias" "$persistent" "-runtime" "$runtime" "-arch" "$arch"
|
||||||
|
|
@ -556,7 +623,7 @@ dnvm()
|
||||||
else
|
else
|
||||||
local runtimeFullName=$(basename $versionOrAlias | sed "s/\(.*\)\.nupkg/\1/")
|
local runtimeFullName=$(basename $versionOrAlias | sed "s/\(.*\)\.nupkg/\1/")
|
||||||
local runtimeVersion=$(__dnvm_package_version "$runtimeFullName")
|
local runtimeVersion=$(__dnvm_package_version "$runtimeFullName")
|
||||||
local runtimeFolder="$_DNVM_USER_PACKAGES/$runtimeFullName"
|
local runtimeFolder="$runtimeDir/$runtimeFullName"
|
||||||
local runtimeFile="$runtimeFolder/$runtimeFullName.nupkg"
|
local runtimeFile="$runtimeFolder/$runtimeFullName.nupkg"
|
||||||
local runtimeClr=$(__dnvm_package_runtime "$runtimeFullName")
|
local runtimeClr=$(__dnvm_package_runtime "$runtimeFullName")
|
||||||
|
|
||||||
|
|
@ -568,9 +635,18 @@ dnvm()
|
||||||
if [ -e "$runtimeFolder" ]; then
|
if [ -e "$runtimeFolder" ]; then
|
||||||
echo "$runtimeFullName already installed"
|
echo "$runtimeFullName already installed"
|
||||||
else
|
else
|
||||||
|
local useSudo=
|
||||||
mkdir -p "$runtimeFolder" > /dev/null 2>&1
|
mkdir -p "$runtimeFolder" > /dev/null 2>&1
|
||||||
|
if [ ! -d $runtimeFolder ]; then
|
||||||
|
if ! __dnvm_promptSudo $acceptSudo ; then
|
||||||
|
useSudo=sudo
|
||||||
|
sudo mkdir -p "$runtimeFolder" > /dev/null 2>&1 || return 1
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
cp -a "$versionOrAlias" "$runtimeFile"
|
cp -a "$versionOrAlias" "$runtimeFile"
|
||||||
__dnvm_unpack "$runtimeFile" "$runtimeFolder"
|
__dnvm_unpack "$runtimeFile" "$runtimeFolder" $useSudo
|
||||||
[[ $? == 1 ]] && return 1
|
[[ $? == 1 ]] && return 1
|
||||||
fi
|
fi
|
||||||
$_DNVM_COMMAND_NAME use "$runtimeVersion" "$persistent" -r "$runtimeClr"
|
$_DNVM_COMMAND_NAME use "$runtimeVersion" "$persistent" -r "$runtimeClr"
|
||||||
|
|
@ -712,7 +788,7 @@ dnvm()
|
||||||
|
|
||||||
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch" "$os")
|
local runtimeFullName=$(__dnvm_requested_version_or_alias "$versionOrAlias" "$runtime" "$arch" "$os")
|
||||||
|
|
||||||
[[ ! -d "$_DNVM_USER_PACKAGES/$runtimeFullName" ]] && echo "$runtimeFullName is not an installed $_DNVM_RUNTIME_SHORT_NAME version" && return 1
|
([[ ! -d "$_DNVM_USER_PACKAGES/$runtimeFullName" ]] && [[ ! -d "$_DNVM_GLOBAL_PACKAGES/$runtimeFullName" ]]) && echo "$runtimeFullName is not an installed $_DNVM_RUNTIME_SHORT_NAME version" && return 1
|
||||||
|
|
||||||
local action="Setting"
|
local action="Setting"
|
||||||
[[ -e "$_DNVM_ALIAS_DIR/$name.alias" ]] && action="Updating"
|
[[ -e "$_DNVM_ALIAS_DIR/$name.alias" ]] && action="Updating"
|
||||||
|
|
@ -736,7 +812,15 @@ dnvm()
|
||||||
[[ ! -d $_DNVM_USER_PACKAGES ]] && echo "$_DNVM_RUNTIME_FRIENDLY_NAME is not installed." && return 1
|
[[ ! -d $_DNVM_USER_PACKAGES ]] && echo "$_DNVM_RUNTIME_FRIENDLY_NAME is not installed." && return 1
|
||||||
|
|
||||||
local searchGlob="$_DNVM_RUNTIME_PACKAGE_NAME-*"
|
local searchGlob="$_DNVM_RUNTIME_PACKAGE_NAME-*"
|
||||||
local runtimes="$(find $_DNVM_USER_PACKAGES -name "$searchGlob" \( -type d -or -type l \) -prune -exec basename {} \;)"
|
|
||||||
|
local runtimes=""
|
||||||
|
for location in `echo $DNX_HOME | tr ":" "\n"`; do
|
||||||
|
location+="/runtimes"
|
||||||
|
local oruntimes="$(find $location -name "$searchGlob" \( -type d -or -type l \) -prune -exec basename {} \;)"
|
||||||
|
for v in `echo $oruntimes | tr "\n" " "`; do
|
||||||
|
runtimes+="$v:$location"$'\n'
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
[[ -z $runtimes ]] && echo 'No runtimes installed. You can run `dnvm install latest` or `dnvm upgrade` to install a runtime.' && return
|
[[ -z $runtimes ]] && echo 'No runtimes installed. You can run `dnvm install latest` or `dnvm upgrade` to install a runtime.' && return
|
||||||
|
|
||||||
|
|
@ -752,7 +836,7 @@ dnvm()
|
||||||
local format="%-20s %s\n"
|
local format="%-20s %s\n"
|
||||||
if [ -d "$_DNVM_ALIAS_DIR" ]; then
|
if [ -d "$_DNVM_ALIAS_DIR" ]; then
|
||||||
for __dnvm_file in $(find "$_DNVM_ALIAS_DIR" -name *.alias); do
|
for __dnvm_file in $(find "$_DNVM_ALIAS_DIR" -name *.alias); do
|
||||||
if [ ! -d "$_DNVM_USER_PACKAGES/$(cat $__dnvm_file)" ]; then
|
if [ ! -d "$_DNVM_USER_PACKAGES/$(cat $__dnvm_file)" ] && [ ! -d "$_DNVM_GLOBAL_PACKAGES/$(cat $__dnvm_file)" ]; then
|
||||||
arr[$i]="$(basename $__dnvm_file | sed 's/\.alias//')/missing/$(cat $__dnvm_file)"
|
arr[$i]="$(basename $__dnvm_file | sed 's/\.alias//')/missing/$(cat $__dnvm_file)"
|
||||||
runtimes="$runtimes $(cat $__dnvm_file)"
|
runtimes="$runtimes $(cat $__dnvm_file)"
|
||||||
else
|
else
|
||||||
|
|
@ -763,19 +847,41 @@ dnvm()
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $2 == "-detailed" ]]; then
|
if [[ $2 == "-detailed" ]]; then
|
||||||
local formatString="%-6s %-20s %-7s %-4s %-15s %-20s %s\n"
|
# Calculate widest alias
|
||||||
printf "$formatString" "Active" "Version" "Runtime" "Arch" "OperatingSystem" "Location" "Alias"
|
local widestAlias=5
|
||||||
printf "$formatString" "------" "-------" "-------" "----" "---------------" "--------" "-----"
|
for f in `echo $runtimes`; do
|
||||||
|
local pkgName=$(__dnvm_package_name "$f")
|
||||||
|
local pkgVersion=$(__dnvm_package_version "$f")
|
||||||
|
local alias=""
|
||||||
|
local delim=""
|
||||||
|
for i in "${arr[@]}"; do
|
||||||
|
if [[ ${i##*/} == "$pkgName.$pkgVersion" ]]; then
|
||||||
|
alias+="$delim${i%%/*}"
|
||||||
|
delim=", "
|
||||||
|
if [[ "${i%/*}" =~ \/missing$ ]]; then
|
||||||
|
alias+=" (missing)"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if [ "${#alias}" -gt "$widestAlias" ]; then
|
||||||
|
widestAlias=${#alias}
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
local formatString="%-6s %-20s %-7s %-12s %-15s %-${widestAlias}s %s\n"
|
||||||
|
printf "$formatString" "Active" "Version" "Runtime" "Architecture" "OperatingSystem" "Alias" "Location"
|
||||||
|
printf "$formatString" "------" "-------" "-------" "------------" "---------------" "-----" "--------"
|
||||||
else
|
else
|
||||||
local formatString="%-6s %-20s %-7s %-4s %-15s %s\n"
|
local formatString="%-6s %-20s %-7s %-12s %-15s %s\n"
|
||||||
printf "$formatString" "Active" "Version" "Runtime" "Arch" "OperatingSystem" "Alias"
|
printf "$formatString" "Active" "Version" "Runtime" "Architecture" "OperatingSystem" "Alias"
|
||||||
printf "$formatString" "------" "-------" "-------" "----" "---------------" "-----"
|
printf "$formatString" "------" "-------" "-------" "------------" "---------------" "-----"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for f in `echo $runtimes | sort -t. -k2 -k3 -k4 -k1`; do
|
for f in `echo -e "$runtimes" | sort -t. -k2 -k3 -k4 -k1`; do
|
||||||
local formattedHome=`(echo $_DNVM_USER_PACKAGES | sed s=$HOME=~=g)`
|
local location=`echo $f | sed 's/.*\([:]\)//'`
|
||||||
|
f=`echo $f | sed 's/\([:]\).*//'`
|
||||||
|
local formattedHome=`(echo $location | sed s=$HOME=~=g)`
|
||||||
local active=""
|
local active=""
|
||||||
[[ $PATH == *"$_DNVM_USER_PACKAGES/$f/bin"* ]] && local active=" *"
|
[[ $PATH == *"$location/$f/bin"* ]] && local active=" *"
|
||||||
local pkgRuntime=$(__dnvm_package_runtime "$f")
|
local pkgRuntime=$(__dnvm_package_runtime "$f")
|
||||||
local pkgName=$(__dnvm_package_name "$f")
|
local pkgName=$(__dnvm_package_name "$f")
|
||||||
local pkgVersion=$(__dnvm_package_version "$f")
|
local pkgVersion=$(__dnvm_package_version "$f")
|
||||||
|
|
@ -796,7 +902,7 @@ dnvm()
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ $2 == "-detailed" ]]; then
|
if [[ $2 == "-detailed" ]]; then
|
||||||
printf "$formatString" "$active" "$pkgVersion" "$pkgRuntime" "$pkgArch" "$pkgOs" "$formattedHome" "$alias"
|
printf "$formatString" "$active" "$pkgVersion" "$pkgRuntime" "$pkgArch" "$pkgOs" "$alias" "$formattedHome"
|
||||||
else
|
else
|
||||||
printf "$formatString" "$active" "$pkgVersion" "$pkgRuntime" "$pkgArch" "$pkgOs" "$alias"
|
printf "$formatString" "$active" "$pkgVersion" "$pkgRuntime" "$pkgArch" "$pkgOs" "$alias"
|
||||||
fi
|
fi
|
||||||
|
|
@ -813,8 +919,8 @@ dnvm()
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add the home location's bin directory to the path
|
# Add the home location's bin directory to the path if it doesn't exist
|
||||||
export PATH="$DNX_HOME/bin:$PATH"
|
[[ ":$PATH:" != *":$DNX_USER_HOME/bin:"* ]] && export PATH="$DNX_USER_HOME/bin:$PATH"
|
||||||
|
|
||||||
# Generate the command function using the constant defined above.
|
# Generate the command function using the constant defined above.
|
||||||
$_DNVM_COMMAND_NAME list default >/dev/null && $_DNVM_COMMAND_NAME use default >/dev/null || true
|
$_DNVM_COMMAND_NAME list default >/dev/null && $_DNVM_COMMAND_NAME use default >/dev/null || true
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue