From 7a84f6df8903178fea71251f12910727f278d4e7 Mon Sep 17 00:00:00 2001 From: Iristyle Date: Mon, 3 Dec 2012 14:31:12 -0500 Subject: [PATCH] Add ToolsRoot so Chocolatey_Bin_Root is \tools --- ToolsRoot/ToolsRoot.nuspec | 19 +++++++++++++++++++ ToolsRoot/tools/chocolateyInstall.ps1 | 22 ++++++++++++++++++++++ ToolsRoot/tools/chocolateyUninstall.ps1 | 23 +++++++++++++++++++++++ 3 files changed, 64 insertions(+) create mode 100644 ToolsRoot/ToolsRoot.nuspec create mode 100644 ToolsRoot/tools/chocolateyInstall.ps1 create mode 100644 ToolsRoot/tools/chocolateyUninstall.ps1 diff --git a/ToolsRoot/ToolsRoot.nuspec b/ToolsRoot/ToolsRoot.nuspec new file mode 100644 index 0000000..0810dd1 --- /dev/null +++ b/ToolsRoot/ToolsRoot.nuspec @@ -0,0 +1,19 @@ + + + + toolsroot + 0.1.0 + Tools Root + Ethan J. Brown + Ethan J. Brown + + false + Set's the chocolatey_bin_root environment variable to a default value of '\tools' if not already set. This allows packages such as Ruby, Python etc. to install in \tools instead of the system root. + + Sets the chocolatey_bin_root default value to \tools. + path + + + diff --git a/ToolsRoot/tools/chocolateyInstall.ps1 b/ToolsRoot/tools/chocolateyInstall.ps1 new file mode 100644 index 0000000..60281fb --- /dev/null +++ b/ToolsRoot/tools/chocolateyInstall.ps1 @@ -0,0 +1,22 @@ +$packageName = 'ToolsRoot' + +try +{ + $variableName = 'Chocolatey_Bin_Root' + if (!(Get-Item Env:$variableName -ErrorAction SilentlyContinue)) + { + $path = '\tools' + [Environment]::SetEnvironmentVariable($variableName, $path, 'User') + Set-Item Env:$variableName $path + + $binRoot = Join-Path $Env:SystemDrive $path + Write-Host "Configured $variableName as $binRoot" + } + + Write-ChocolateySuccess $package +} +catch +{ + Write-ChocolateyFailure $package "$($_.Exception.Message)" + throw +} diff --git a/ToolsRoot/tools/chocolateyUninstall.ps1 b/ToolsRoot/tools/chocolateyUninstall.ps1 new file mode 100644 index 0000000..6b87445 --- /dev/null +++ b/ToolsRoot/tools/chocolateyUninstall.ps1 @@ -0,0 +1,23 @@ +$package = 'ToolsRoot' + +try +{ + $variableName = 'Chocolatey_Bin_Root' + $binRoot = Get-Item Env:$variableName -ErrorAction SilentlyContinue | + Select -ExpandProperty Value -First 1 + + if ($binRoot) + { + [Environment]::SetEnvironmentVariable($variableName, '', 'User') + Set-Item Env:$variableName $null + + Write-Host "Removed $variableName [was $binRoot]" + } + + Write-ChocolateySuccess $package +} +catch +{ + Write-ChocolateyFailure $package "$($_.Exception.Message)" + throw +}