Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (GH-1111) Clean up messaging for licensed edition
  (GH-262) Ensure explicit source proxy bypass
  (doc) update environment variables in readme
  (maint) update uninstall to core extension
  (GH-262) source - proxy bypass logging
  (GH-605) Ensure environment proxy settings available
  (maint) formatting
  (log) update checksum error message
  (maint) TabExpansion - new options for licensed
  (GH-1173) Set proxy information at runtime
  (log) note when proxy settings became available
  (maint) add outputdirectory shorter option names
  • Loading branch information
ferventcoder committed Mar 1, 2017
2 parents 7b4d4c1 + 775c5f7 commit 0f602f7
Show file tree
Hide file tree
Showing 11 changed files with 196 additions and 121 deletions.
Binary file modified lib/NuGet-Chocolatey/NuGet.Core.dll
Binary file not shown.
9 changes: 5 additions & 4 deletions src/chocolatey.resources/helpers/ChocolateyTabExpansion.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ function script:chocoCmdOperations($commands, $command, $filter, $currentArgumen
where { $_ -like "$filter*" }
}

$script:someCommands = @('-?','search','list','info','install','outdated','upgrade','uninstall','new','download','pack','push','-h','--help','pin','source','config','feature','apikey')
$script:someCommands = @('-?','search','list','info','install','outdated','upgrade','uninstall','new','download','pack','push','sync','-h','--help','pin','source','config','feature','apikey')

$allcommands = " --debug --verbose --force --noop --help --accept-license --confirm --limit-output --execution-timeout= --cache-location='' --fail-on-error-output --use-system-powershell"
$allcommands = " --debug --verbose --force --noop --help --accept-license --confirm --limit-output --no-progress --execution-timeout= --cache-location='' --proxy='' --proxy-user= --proxy-password= --proxy-bypass-list='' --proxy-bypass-on-local --fail-on-error-output --use-system-powershell"
$proInstallUpgradeOptions = " --install-directory='Pro/Biz editions' --skip-download-cache --use-download-cache --skip-virus-check --virus-check --virus-positives-minimum="
$proNewOptions = " --file=<biz>"

Expand All @@ -47,14 +47,15 @@ $commandOptions = @{
outdated = "-? --source='' --user= --password=" + $allcommands
upgrade = "-y -whatif -? --pre --version= --except='' --params='' --install-arguments='' --override-arguments --ignore-dependencies --source='' --source='windowsfeatures' --source='webpi' --user= --password= --prerelease --forcex86 --not-silent --package-parameters='' --allow-downgrade --allow-multiple-versions --require-checksums --use-package-exit-codes --ignore-package-exit-codes --skip-automation-scripts --fail-on-unfound --fail-on-not-installed --ignore-checksums --allow-empty-checksums --allow-empty-checksums-secure --download-checksum='' --download-checksum-type='' --download-checksum-x64='' --download-checksum-type-x64=''" + $allcommands + $proInstallUpgradeOptions
uninstall = "-y -whatif -? --force-dependencies --remove-dependencies --all-versions --source='windowsfeatures' --source='webpi' --version= --uninstall-arguments='' --override-arguments --not-silent --params='' --package-parameters='' --use-package-exit-codes --ignore-package-exit-codes --skip-automation-scripts --use-autouninstaller --skip-autouninstaller --fail-on-autouninstaller --ignore-autouninstaller-failure" + $allcommands
new = "--template-name= --file='Biz editions only' --automaticpackage --version= --maintainer='' packageversion= maintainername='' maintainerrepo='' installertype= url='' url64='' silentargs='' --use-built-in-template -?" + $allcommands
new = "--template-name= --file='Biz editions only' --from-programs-and-features='Biz editions only' --output-directory='' --automaticpackage --version= --maintainer='' packageversion= maintainername='' maintainerrepo='' installertype= url='' url64='' silentargs='' --use-built-in-template --keep-remote --use-original-location --checksum --checksum64 --build-package -?" + $allcommands
pack = "--version= -?" + $allcommands
push = "--source='' --api-key= --timeout= -?" + $allcommands
source = "--name= --source='' --user= --password= --priority= -?" + $allcommands
config = "--name= --value= -?" + $allcommands
feature = "--name= -?" + $allcommands
apikey = "--source='' --api-key= -?" + $allcommands
download = "--recompile --resources-location --outputdirectory -?" + $allcommands
download = "--internalize --ignore-dependencies --resources-location= --download-location= --outputdirectory= --source='' --version='' --prerelease --user= --password= --cert='' --certpassword= -?" + $allcommands
sync = "--output-directory= -?" + $allcommands
}

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ param(
Write-Debug "Command [`'$checksumExe`' $params] exited with `'$exitCode`'."

if ($exitCode -ne 0) {
throw "Checksum for '$file' did not meet '$checksum' for checksum type '$checksumType'. Consider passing --ignore-checksums if necessary."
throw "Checksum for '$file' did not meet '$checksum' for checksum type '$checksumType'. Consider passing the actual checksums through with `--checksum --checksum64` once you validate the checksums are appropriate. A less secure option is to pass `--ignore-checksums` if necessary."
}

#$fileCheckSumActual = $md5Output.Split(' ')[0]
Expand Down
194 changes: 112 additions & 82 deletions src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
.Add("maintainer=",
"Maintainer - the name of the maintainer. Can also be passed as the property MaintainerName=somevalue",
option => configuration.NewCommand.TemplateProperties.Add(TemplateValues.MaintainerPropertyName, option.remove_surrounding_quotes()))
.Add("outputdirectory=",
.Add("out=|outdir=|outputdirectory=|output-directory=",
"OutputDirectory - Specifies the directory for the created Chocolatey package file. If not specified, uses the current directory. Available in 0.9.10+.",
option => configuration.OutputDirectory = option)
.Add("built-in|built-in-template|originaltemplate|original-template|use-original-template|use-built-in-template",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
.Add("version=",
"Version - The version you would like to insert into the package.",
option => configuration.Version = option.remove_surrounding_quotes())
.Add("outputdirectory=",
.Add("out=|outdir=|outputdirectory=|output-directory=",
"OutputDirectory - Specifies the directory for the created Chocolatey package file. If not specified, uses the current directory.",
option => configuration.OutputDirectory = option)
;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,7 @@ public static void set_environment_variables(ChocolateyConfiguration config)
if (config.Features.ScriptsCheckLastExitCode) Environment.SetEnvironmentVariable(ApplicationParameters.Environment.ChocolateyCheckLastExitCode, "true");
Environment.SetEnvironmentVariable("chocolateyRequestTimeout", config.WebRequestTimeoutSeconds.to_string() + "000");
Environment.SetEnvironmentVariable("chocolateyResponseTimeout", config.CommandExecutionTimeoutSeconds.to_string() + "000");


if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("https_proxy"))) Environment.SetEnvironmentVariable("chocolateyProxyLocation", Environment.GetEnvironmentVariable("https_proxy"));
if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("http_proxy")) && string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("chocolateyProxyLocation"))) Environment.SetEnvironmentVariable("chocolateyProxyLocation", Environment.GetEnvironmentVariable("http_proxy"));
if (!string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("no_proxy"))) Environment.SetEnvironmentVariable("chocolateyProxyBypassList", Environment.GetEnvironmentVariable("no_proxy"));


if (!string.IsNullOrWhiteSpace(config.Proxy.Location))
{
var proxyCreds = string.Empty;
Expand All @@ -109,7 +104,13 @@ public static void set_environment_variables(ChocolateyConfiguration config)
Environment.SetEnvironmentVariable("https_proxy", "{0}{1}".format_with(proxyCreds, config.Proxy.Location));
Environment.SetEnvironmentVariable("chocolateyProxyLocation", config.Proxy.Location);

if (!string.IsNullOrWhiteSpace(config.Proxy.BypassList)) Environment.SetEnvironmentVariable("chocolateyProxyBypassList", config.Proxy.BypassList);
if (!string.IsNullOrWhiteSpace(config.Proxy.BypassList))
{
Environment.SetEnvironmentVariable("chocolateyProxyBypassList", config.Proxy.BypassList);
Environment.SetEnvironmentVariable("no_proxy", config.Proxy.BypassList);

}

if (config.Proxy.BypassOnLocal) Environment.SetEnvironmentVariable("chocolateyProxyBypassOnLocal", "true");
}

Expand Down
8 changes: 6 additions & 2 deletions src/chocolatey/infrastructure.app/nuget/NugetCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public static IPackageRepository GetRemoteRepository(ChocolateyConfiguration con

if (!string.IsNullOrWhiteSpace(configuration.Proxy.BypassList))
{
"chocolatey".Log().Debug("Proxy has a bypass list of '{0}'.");
proxy.BypassList = configuration.Proxy.BypassList.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
}

Expand All @@ -94,7 +95,6 @@ public static IPackageRepository GetRemoteRepository(ChocolateyConfiguration con
var bypassProxy = false;
if (configuration.MachineSources.Any(m => m.Name.is_equal_to(source) || m.Key.is_equal_to(source)))
{

try
{
var machineSource = configuration.MachineSources.FirstOrDefault(m => m.Key.is_equal_to(source));
Expand All @@ -105,7 +105,11 @@ public static IPackageRepository GetRemoteRepository(ChocolateyConfiguration con
source = machineSource.Key;
}

if (machineSource != null) bypassProxy = machineSource.BypassProxy;
if (machineSource != null)
{
bypassProxy = machineSource.BypassProxy;
if (bypassProxy) "chocolatey".Log().Debug("Source '{0}' is configured to bypass proxies.".format_with(source));
}
}
catch (Exception ex)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ experience to the next level at
@"
Did you know the proceeds of Pro (and some proceeds from other
licensed editions) go into bettering the community infrastructure?
Your support ensures an active community, it makes you look smarter,
Your support ensures an active community, keeps Chocolatey tip top,
plus it nets you some awesome features!
https://chocolatey.org/compare",
@"
Expand All @@ -87,8 +87,7 @@ installed software without an uninstall script? Find out more at
@"
Did you know Chocolatey goes to eleven? And it turns great developers /
system admins into something amazing! Singlehandedly solve your
organization's struggles with software management and look uber cool
while doing so.
organization's struggles with software management and save the day!
https://chocolatey.org/compare"
};
private const string PRO_BUSINESS_LIST_MESSAGE = @"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,38 +76,74 @@ You should read up on the Shim Generation section to familiarize yourself
### Need to mount an ISO?
https://chocolatey.org/docs/how-to-mount-an-iso-in-chocolatey-package
### Environment Variables
Chocolatey makes a number of environment variables available (You can access any of these with $env:TheVariableNameBelow):
* TEMP = Overridden to the CacheLocation, but may be the same as the original TEMP folder
* ChocolateyInstall = Top level folder where Chocolatey is installed
* chocolateyPackageName = The name of the package, equivalent to the id in the nuspec (0.9.9+)
* chocolateyPackageVersion = The version of the package, equivalent to the version in the nuspec (0.9.9+)
* chocolateyPackageFolder = The top level location of the package folder
* TEMP/TMP - Overridden to the CacheLocation, but may be the same as the original TEMP folder
* ChocolateyInstall - Top level folder where Chocolatey is installed
* ChocolateyPackageName - The name of the package, equivalent to the `<id />` field in the nuspec (0.9.9+)
* ChocolateyPackageTitle - The title of the package, equivalent to the `<title />` field in the nuspec (0.10.1+)
* ChocolateyPackageVersion - The version of the package, equivalent to the `<version />` field in the nuspec (0.9.9+)
* ChocolateyPackageFolder - The top level location of the package folder - the folder where Chocolatey has downloaded and extracted the NuGet package, typically `C:\ProgramData\chocolatey\lib\packageName`.
#### Advanced Environment Variables
The following are more advanced settings:
* chocolateyPackageParameters = (0.9.8.22+)
* CHOCOLATEY_VERSION = The version of Choco you normally see. Use if you are 'lighting' things up based on choco version. (0.9.9+)
- Otherwise take a dependency on the specific version you need.
* chocolateyForceX86 = If available and set to 'true', then user has requested 32bit version. (0.9.9+)
- Automatically handled in built in Choco functions.
* OS_PLATFORM = Like Windows, OSX, Linux. (0.9.9+)
* OS_VERSION = The version of OS, like 6.1 something something for Windows. (0.9.9+)
* OS_NAME = The reported name of the OS. (0.9.9+)
* ChocolateyPackageParameters - Parameters to use with packaging, not the same as install arguments (which are passed directly to the native installer). Based on `--package-parameters`. (0.9.8.22+)
* CHOCOLATEY_VERSION - The version of Choco you normally see. Use if you are 'lighting' things up based on choco version. (0.9.9+) - Otherwise take a dependency on the specific version you need.
* ChocolateyForceX86 = If available and set to 'true', then user has requested 32bit version. (0.9.9+) - Automatically handled in built in Choco functions.
* OS_PLATFORM - Like Windows, OSX, Linux. (0.9.9+)
* OS_VERSION - The version of OS, like 6.1 something something for Windows. (0.9.9+)
* OS_NAME - The reported name of the OS. (0.9.9+)
* IS_PROCESSELEVATED = Is the process elevated? (0.9.9+)
* ChocolateyToolsLocation - formerly 'ChocolateyBinRoot' ('ChocolateyBinRoot' will be removed with Chocolatey v2.0.0), this is where tools being installed outside of Chocolatey packaging will go. (0.9.10+)
#### Set By Options and Configuration
Some environment variables are set based on options that are passed, configuration and/or features that are turned on:
* ChocolateyEnvironmentDebug - Was `--debug` passed? If using the built-in PowerShell host, this is always true (but only logs debug messages to console if `--debug` was passed) (0.9.10+)
* ChocolateyEnvironmentVerbose - Was `--verbose` passed? If using the built-in PowerShell host, this is always true (but only logs verbose messages to console if `--verbose` was passed). (0.9.10+)
* ChocolateyForce - Was `--force` passed? (0.9.10+)
* ChocolateyForceX86 - Was `-x86` passed? (CHECK)
* ChocolateyRequestTimeout - How long before a web request will time out. Set by config `webRequestTimeoutSeconds` (CHECK)
* ChocolateyResponseTimeout - How long to wait for a download to complete? Set by config `commandExecutionTimeoutSeconds` (CHECK)
* ChocolateyPowerShellHost - Are we using the built-in PowerShell host? Set by `--use-system-powershell` or the feature `powershellHost` (0.9.10+)
#### Business Edition Variables
* ChocolateyInstallArgumentsSensitive - Encrypted arguments passed from command line `--install-arguments-sensitive` that are not logged anywhere. (0.10.1+ and licensed editions 1.6.0+)
* ChocolateyPackageParametersSensitive - Package parameters passed from command line `--package-parameters-senstivite` that are not logged anywhere. (0.10.1+ and licensed editions 1.6.0+)
* ChocolateyLicensedVersion - What version is the licensed edition on?
* ChocolateyLicenseType - What edition / type of the licensed edition is installed?
#### Experimental Environment Variables
The following are experimental or use not recommended:
* OS_IS64BIT = This may not return correctly - it may depend on the process the app is running under (0.9.9+)
* CHOCOLATEY_VERSION_PRODUCT = the version of Choco that may match CHOCOLATEY_VERSION but may be different (0.9.9+)
- it's based on git describe
* CHOCOLATEY_VERSION_PRODUCT = the version of Choco that may match CHOCOLATEY_VERSION but may be different (0.9.9+) - based on git describe
* IS_ADMIN = Is the user an administrator? But doesn't tell you if the process is elevated. (0.9.9+)
* chocolateyInstallOverride = Not for use in package automation scripts. (0.9.9+)
* chocolateyInstallArguments = the installer arguments meant for the native installer. You should use chocolateyPackageParameters intead. (0.9.9+)
#### Not Useful Or Anti-Pattern If Used
* ChocolateyInstallOverride = Not for use in package automation scripts. Based on `--override-arguments` being passed. (0.9.9+)
* ChocolateyInstallArguments = The installer arguments meant for the native installer. You should use chocolateyPackageParameters intead. Based on `--install-arguments` being passed. (0.9.9+)
* ChocolateyIgnoreChecksums - Was `--ignore-checksums` passed or the feature `checksumFiles` turned off? (0.9.9.9+)
* ChocolateyAllowEmptyChecksums - Was `--allow-empty-checksums` passed or the feature `allowEmptyChecksums` turned on? (0.10.0+)
* ChocolateyAllowEmptyChecksumsSecure - Was `--allow-empty-checksums-secure` passed or the feature `allowEmptyChecksumsSecure` turned on? (0.10.0+)
* ChocolateyCheckLastExitCode - Should Chocolatey check LASTEXITCODE? Is the feature `scriptsCheckLastExitCode` turned on? (0.10.3+)
* ChocolateyChecksum32 - Was `--download-checksum` passed? (0.10.0+)
* ChocolateyChecksumType32 - Was `--download-checksum-type` passed? (0.10.0+)
* ChocolateyChecksum64 - Was `--download-checksum-x64` passed? (0.10.0)+
* ChocolateyChecksumType64 - Was `--download-checksum-type-x64` passed? (0.10.0)+
* ChocolateyPackageExitCode - The exit code of the script that just ran - usually set by `Set-PowerShellExitCode` (CHECK)
* ChocolateyLastPathUpdate - Set by Chocolatey as part of install, but not used for anything in particular in packaging.
* ChocolateyProxyLocation - The explicit proxy location as set in the configuration `proxy` (0.9.9.9+)
* ChocolateyDownloadCache - Use available download cache? Set by `--skip-download-cache`, `--use-download-cache`, or feature `downloadCache` (0.9.10+ and licensed editions 1.1.0+)
* ChocolateyProxyBypassList - Explicitly set locations to ignore in configuration `proxyBypassList` (0.10.4+)
* ChocolateyProxyBypassOnLocal - Should the proxy bypass on local connections? Set based on configuration `proxyBypassOnLocal` (0.10.4+)
* http_proxy - Set by original `http_proxy` passthrough, or same as `ChocolateyProxyLocation` if explicitly set. (0.10.4+)
* https_proxy - Set by original `https_proxy` passthrough, or same as `ChocolateyProxyLocation` if explicitly set. (0.10.4+)
* no_proxy- Set by original `no_proxy` passthrough, or same as `ChocolateyProxyBypassList` if explicitly set. (0.10.4+)
";
}
Expand Down
8 changes: 6 additions & 2 deletions src/chocolatey/infrastructure.app/templates/NuspecTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,13 @@ public class NuspecTemplate
<dependency id="""" version=""[_MIN_VERSION_INCLUSIVE, MAX_VERSION_INCLUSIVE]"" />
<dependency id="""" version=""[_MIN_VERSION_INCLUSIVE, MAX_VERSION_EXCLUSIVE)"" />
<dependency id="""" />
<dependency id=""chocolatey-uninstall.extension"" />
<dependency id=""chocolatey-core.extension"" version=""1.1.0"" />
</dependencies>-->
<!-- chocolatey-uninstall.extension - If supporting 0.9.9.x (or below) and including a chocolateyUninstall.ps1 file to uninstall an EXE/MSI, you probably want to include chocolatey-uninstall.extension as a dependency. Please verify whether you are using a helper function from that package. -->
<!-- chocolatey-core.extension - https://chocolatey.org/packages/chocolatey-core.extension
- You want to use Get-UninstallRegistryKey on less than 0.9.10 (in chocolateyUninstall.ps1)
- You want to use Get-PackageParameters and on less than 0.11.0
- You want to take advantage of other functions in the core community maintainer's team extension package
-->
<!--<provides>NOT YET IMPLEMENTED</provides>-->
<!--<conflicts>NOT YET IMPLEMENTED</conflicts>-->
Expand Down

0 comments on commit 0f602f7

Please sign in to comment.