fix: Erlang bin path to user PATH, don't reinst

- 100MB download was running again, even if installed already
 - need to ensure the bin dir is in PATH for access to erl
 - Handle PATH manip in install and uninstall
This commit is contained in:
Iristyle
2013-07-17 11:18:06 -04:00
parent 6309b75baf
commit 9f1c28998c
2 changed files with 39 additions and 8 deletions

View File

@@ -1,7 +1,22 @@
$package = 'Erlang'
$version = 'R16B01'
$installFolder = 'erl5.10.2'
$releaseFolder = "$installFolder\releases\$version"
try {
$installedPath = (Join-Path "${Env:\ProgramFiles(x86)}" $installFolder),
(Join-Path $Env:ProgramFiles "$installFolder\bin") |
? { Test-Path $_ } |
Select -First 1
# only way to test for installation of this version is by path on disk
if (Test-Path $installedPath)
{
Write-Host "$package $version is already installed to $installedPath"
}
else
{
$params = @{
PackageName = $package;
FileType = 'exe';
@@ -12,6 +27,14 @@ try {
}
Install-ChocolateyPackage @params
}
$binPath = (Join-Path "${Env:\ProgramFiles(x86)}" $installFolder),
(Join-Path $Env:ProgramFiles "$installFolder\bin") |
? { Test-Path $_ } |
Select -First 1
Install-ChocolateyPath $binPath
Write-ChocolateySuccess $package
} catch {

View File

@@ -19,6 +19,14 @@ try
}
Uninstall-ChocolateyPackage @uninstallParams
$binLocation = Join-Path $installPath 'bin'
$userPaths = [Environment]::GetEnvironmentVariable('Path', 'User') -split ';' |
? { ($_ -notmatch $binLocation) -and (![String]::IsNullOrEmpty($_)) } |
Select-Object -Unique
[Environment]::SetEnvironmentVariable('Path', ($userPaths -join ';'), 'User')
Write-ChocolateySuccess $package
}
catch