Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (doc) update changelog/nuspec
  (chocolateyGH-631) Remove Get-BinRoot, Add Get-ToolsLocation
  (chocolateyGH-606) Check for License in User Profile
  (chocolateyGH-629) Install-ChocolateyInstallPackage Validate Parameters
  (doc) Update changelog/nuspec
  • Loading branch information
ferventcoder committed Feb 12, 2016
2 parents 0426b74 + f30c1dc commit 8ae225b
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 69 deletions.
10 changes: 8 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ For 590 - if you set a custom cache directory for downloads, it will no longer u
* Use the actual download file name instead of providing one - see [#435](https://github.com/chocolatey/choco/issues/435)
* Support for custom headers - see [#332](https://github.com/chocolatey/choco/issues/332)
* [Security] Show moderation-related information in search results - see [#493](https://github.com/chocolatey/choco/issues/493)

* New Helper - Get-ToolsLocation helper (replacement for Get-BinRoot) - see [#631](https://github.com/chocolatey/choco/issues/631)

### BUG FIXES

* [Security] Fix - Only load the Chocolatey PowerShell module from a known location - see [#560](https://github.com/chocolatey/choco/issues/560)
Expand All @@ -56,7 +57,8 @@ For 590 - if you set a custom cache directory for downloads, it will no longer u
* [POSH Host] Fix - Message after Download progress is on the same line sometimes - see [#525](https://github.com/chocolatey/choco/issues/525)
* [POSH Host] Fix - PowerShell internal process - "The handle is invalid." - see [#526](https://github.com/chocolatey/choco/issues/526)
* Fix - Verbose shows in output on debug switch - see [#611](https://github.com/chocolatey/choco/issues/611)

* Fix: Get-ChocolateyUnzip captures files that don't belong to the package - see [#616](https://github.com/chocolatey/choco/issues/616)
* Fix: Package succeeds but software install silently fails when Install-ChocolateyInstallPackage has the wrong arguments - see [#629](https://github.com/chocolatey/choco/issues/629)

### IMPROVEMENTS

Expand All @@ -68,6 +70,10 @@ For 590 - if you set a custom cache directory for downloads, it will no longer u
* [Security] Warn about environment changes - see [#563](https://github.com/chocolatey/choco/issues/563)
* Warn when execution timeout has elapsed - see [#561](https://github.com/chocolatey/choco/issues/561)
* Update nuspec to make it easier to get started - see [#535](https://github.com/chocolatey/choco/issues/535)
* Suppress verbose output to verbose - like with 7-zip - see [#476](https://github.com/chocolatey/choco/issues/476)
* Choco push moderation message only on push to dot org - see [#601](https://github.com/chocolatey/choco/issues/601)
* Allow tools/bin root to be root of the drive again - see [#628](https://github.com/chocolatey/choco/issues/628)
* Pro - Also check for license in User Profile location - see [#606](https://github.com/chocolatey/choco/issues/606)
* Pro - Set download cache information if available - see [#562](https://github.com/chocolatey/choco/issues/562)
* Pro - Allow commands to be added - see [#583](https://github.com/chocolatey/choco/issues/583)
* Pro - Load/Provide hooks for licensed version - see [#584](https://github.com/chocolatey/choco/issues/584)
Expand Down
9 changes: 8 additions & 1 deletion nuget/chocolatey/chocolatey.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,8 @@ For 590 - if you set a custom cache directory for downloads, it will no longer u
* Use the actual download file name instead of providing one - see [#435](https://github.com/chocolatey/choco/issues/435)
* Support for custom headers - see [#332](https://github.com/chocolatey/choco/issues/332)
* [Security] Show moderation-related information in search results - see [#493](https://github.com/chocolatey/choco/issues/493)

* New Helper - Get-ToolsLocation helper (replacement for Get-BinRoot) - see [#631](https://github.com/chocolatey/choco/issues/631)

### BUG FIXES

* [Security] Fix - Only load the Chocolatey PowerShell module from a known location - see [#560](https://github.com/chocolatey/choco/issues/560)
Expand All @@ -112,6 +113,8 @@ For 590 - if you set a custom cache directory for downloads, it will no longer u
* [POSH Host] Fix - Message after Download progress is on the same line sometimes - see [#525](https://github.com/chocolatey/choco/issues/525)
* [POSH Host] Fix - PowerShell internal process - "The handle is invalid." - see [#526](https://github.com/chocolatey/choco/issues/526)
* Fix - Verbose shows in output on debug switch - see [#611](https://github.com/chocolatey/choco/issues/611)
* Fix: Get-ChocolateyUnzip captures files that don't belong to the package - see [#616](https://github.com/chocolatey/choco/issues/616)
* Fix: Package succeeds but software install silently fails when Install-ChocolateyInstallPackage has the wrong arguments - see [#629](https://github.com/chocolatey/choco/issues/629)

### IMPROVEMENTS

Expand All @@ -123,6 +126,10 @@ For 590 - if you set a custom cache directory for downloads, it will no longer u
* [Security] Warn about environment changes - see [#563](https://github.com/chocolatey/choco/issues/563)
* Warn when execution timeout has elapsed - see [#561](https://github.com/chocolatey/choco/issues/561)
* Update nuspec to make it easier to get started - see [#535](https://github.com/chocolatey/choco/issues/535)
* Suppress verbose output to verbose - like with 7-zip - see [#476](https://github.com/chocolatey/choco/issues/476)
* Choco push moderation message only on push to dot org - see [#601](https://github.com/chocolatey/choco/issues/601)
* Allow tools/bin root to be root of the drive again - see [#628](https://github.com/chocolatey/choco/issues/628)
* Pro - Also check for license in User Profile location - see [#606](https://github.com/chocolatey/choco/issues/606)
* Pro - Set download cache information if available - see [#562](https://github.com/chocolatey/choco/issues/562)
* Pro - Allow commands to be added - see [#583](https://github.com/chocolatey/choco/issues/583)
* Pro - Load/Provide hooks for licensed version - see [#584](https://github.com/chocolatey/choco/issues/584)
Expand Down
4 changes: 3 additions & 1 deletion src/chocolatey.resources/chocolatey.resources.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
<ItemGroup>
<EmbeddedResource Include="helpers\chocolateyInstaller.psm1" />
<EmbeddedResource Include="helpers\functions\Format-FileSize.ps1" />
<EmbeddedResource Include="helpers\functions\Get-BinRoot.ps1" />
<EmbeddedResource Include="helpers\functions\Get-CheckSumValid.ps1" />
<EmbeddedResource Include="helpers\functions\Get-ChocolateyUnzip.ps1" />
<EmbeddedResource Include="helpers\functions\Get-ChocolateyWebFile.ps1" />
Expand Down Expand Up @@ -126,6 +125,9 @@
<ItemGroup>
<EmbeddedResource Include="helpers\functions\Get-FileName.ps1" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="helpers\functions\Get-ToolsLocation.ps1" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
Expand Down
61 changes: 0 additions & 61 deletions src/chocolatey.resources/helpers/functions/Get-BinRoot.ps1

This file was deleted.

55 changes: 55 additions & 0 deletions src/chocolatey.resources/helpers/functions/Get-ToolsLocation.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Copyright 2011 - Present RealDimensions Software, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

function Get-ToolsLocation {
Write-Debug "Running 'Get-ToolsLocation'";
$invocation = $MyInvocation
if ($invocation -ne $null -and $invocation.InvocationName -ne $null -and $invocation.InvocationName.ToLower() -eq 'Get-BinRoot') {
Write-Host "Get-BinRoot is going to be deprecated in v1 and removed in v2. It is being replaced with Get-ToolsLocation, however many packages no longer require a special separate directory since package folders no longer have versions on them. Some do though and should continue to use Get-ToolsLocation."
}

$toolsLocation = $env:ChocolateyToolsLocation

if ($toolsLocation -eq $null) {
$binRoot = $env:ChocolateyBinRoot
$olderRoot = $env:chocolatey_bin_root

if ($binRoot -eq $null -and $olderRoot -eq $null) {
$toolsLocation = Join-Path $env:systemdrive 'tools'
} else {
if ($olderRoot -ne $null) {
if ($binRoot -eq $null) {
$binRoot = $olderRoot
}
Set-EnvironmentVariable -Name "chocolatey_bin_root" -Value '' -Scope User
}

$toolsLocation = $binRoot
Set-EnvironmentVariable -Name "ChocolateyBinRoot" -Value '' -Scope User
}
}

# Add a drive letter if one doesn't exist
if (-not($toolsLocation -imatch "^\w:")) {
$toolsLocation = join-path $env:systemdrive $toolsLocation
}

if (-not($env:ChocolateyToolsLocation -eq $toolsLocation)) {
Set-EnvironmentVariable -Name "ChocolateyToolsLocation" -Value $toolsLocation -Scope User
}

return $toolsLocation
}

Set-Alias Get-BinRoot Get-ToolsLocation -Force -Scope Global -Option AllScope
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,19 @@ param(
)
Write-Debug "Running 'Install-ChocolateyInstallPackage' for $packageName with file:`'$file`', args: `'$silentArgs`', fileType: `'$fileType`', validExitCodes: `'$validExitCodes`' ";
$installMessage = "Installing $packageName..."
write-host $installMessage
Write-Host $installMessage

if ($file -eq '' -or $file -eq $null) {
throw 'Package parameters incorrect, File cannot be empty.'
}
if ($fileType -eq '' -or $fileType -eq $null) {
throw 'Package parameters incorrect, FileType cannot be empty.'
}
$installerTypeLower = $fileType.ToLower()
if ($installerTypeLower -ne 'msi' -and $installerTypeLower -ne 'exe' -and $installerTypeLower -ne 'msu') {
Write-Warning "FileType '$fileType' is unrecognized, using 'exe' instead."
$fileType = 'exe'
}

$ignoreFile = $file + '.ignore'
try {
Expand All @@ -72,19 +84,20 @@ param(
$additionalInstallArgs = $env:chocolateyInstallArguments;
if ($additionalInstallArgs -eq $null) { $additionalInstallArgs = ''; }
$overrideArguments = $env:chocolateyInstallOverride;

if ($fileType -like 'msi') {
$msiArgs = "/i `"$file`""
if ($overrideArguments) {
$msiArgs = "$msiArgs $additionalInstallArgs";
write-host "Overriding package arguments with `'$additionalInstallArgs`'";
Write-Host "Overriding package arguments with `'$additionalInstallArgs`'";
} else {
$msiArgs = "$msiArgs $silentArgs $additionalInstallArgs";
}

Start-ChocolateyProcessAsAdmin "$msiArgs" 'msiexec' -validExitCodes $validExitCodes
#Start-Process -FilePath msiexec -ArgumentList $msiArgs -Wait
}

if ($fileType -like 'exe') {
if ($overrideArguments) {
Start-ChocolateyProcessAsAdmin "$additionalInstallArgs" $file -validExitCodes $validExitCodes
Expand Down
1 change: 1 addition & 0 deletions src/chocolatey/infrastructure.app/ApplicationParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public static class ApplicationParameters
public static readonly string ChocolateyConfigFileResource = @"chocolatey.infrastructure.app.configuration.chocolatey.config";
public static readonly string GlobalConfigFileLocation = _fileSystem.combine_paths(InstallLocation, "config", "chocolatey.config");
public static readonly string LicenseFileLocation = _fileSystem.combine_paths(InstallLocation, "license", "chocolatey.license.xml");
public static readonly string UserLicenseFileLocation = _fileSystem.combine_paths(System.Environment.GetFolderPath(System.Environment.SpecialFolder.UserProfile, System.Environment.SpecialFolderOption.DoNotVerify), "chocolatey.license.xml");
public static readonly string LicensedAssemblyLocation = _fileSystem.combine_paths(InstallLocation, "extensions", "chocolatey", "chocolatey.licensed.dll");
public static readonly string LicensedComponentRegistry = @"chocolatey.licensed.infrastructure.app.registration.ContainerBinding";
public static readonly string LicensedConfigurationBuilder = @"chocolatey.licensed.infrastructure.app.builders.ConfigurationBuilder";
Expand Down
12 changes: 11 additions & 1 deletion src/chocolatey/infrastructure/licensing/LicenseValidation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public static ChocolateyLicense validate()
};

string licenseFile = ApplicationParameters.LicenseFileLocation;
//no file system at this point
var userLicenseFile = ApplicationParameters.UserLicenseFileLocation;
if (File.Exists(userLicenseFile)) licenseFile = userLicenseFile;

//no IFileSystem at this point
if (File.Exists(licenseFile))
{
var license = new LicenseValidator(PUBLIC_KEY, licenseFile);
Expand All @@ -43,6 +46,13 @@ public static ChocolateyLicense validate()
license.AssertValidLicense();
chocolateyLicense.IsValid = true;
}
catch (LicenseFileNotFoundException e)
{
chocolateyLicense.IsValid = false;
chocolateyLicense.InvalidReason = e.Message;
"chocolatey".Log().Error("A license was not found for a licensed version of Chocolatey:{0} {1}{0} {2}".format_with(Environment.NewLine, e.Message,
"A license was also not found in the user profile: '{0}'.".format_with(ApplicationParameters.UserLicenseFileLocation)));
}
catch (Exception e)
{
//license may be invalid
Expand Down

0 comments on commit 8ae225b

Please sign in to comment.