diff --git a/Erlang16/tools/chocolateyInstall.ps1 b/Erlang16/tools/chocolateyInstall.ps1 index 975434b..e0d9a08 100644 --- a/Erlang16/tools/chocolateyInstall.ps1 +++ b/Erlang16/tools/chocolateyInstall.ps1 @@ -1,17 +1,40 @@ $package = 'Erlang' $version = 'R16B01' +$installFolder = 'erl5.10.2' +$releaseFolder = "$installFolder\releases\$version" try { - $params = @{ - PackageName = $package; - FileType = 'exe'; - #uses NSIS installer - http://nsis.sourceforge.net/Docs/Chapter3.html - SilentArgs = '/S'; - Url = "http://www.erlang.org/download/otp_win32_$($version).exe"; - Url64Bit = "http://www.erlang.org/download/otp_win64_$($version).exe"; + + $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'; + #uses NSIS installer - http://nsis.sourceforge.net/Docs/Chapter3.html + SilentArgs = '/S'; + Url = "http://www.erlang.org/download/otp_win32_$($version).exe"; + Url64Bit = "http://www.erlang.org/download/otp_win64_$($version).exe"; + } + + Install-ChocolateyPackage @params } - 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 { diff --git a/Erlang16/tools/chocolateyUninstall.ps1 b/Erlang16/tools/chocolateyUninstall.ps1 index 5cf46db..b426df3 100644 --- a/Erlang16/tools/chocolateyUninstall.ps1 +++ b/Erlang16/tools/chocolateyUninstall.ps1 @@ -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