diff --git a/.build.custom/GenerateDocs.ps1 b/GenerateDocs.ps1 similarity index 95% rename from .build.custom/GenerateDocs.ps1 rename to GenerateDocs.ps1 index e26bf035ed..1b5aaecbfa 100644 --- a/.build.custom/GenerateDocs.ps1 +++ b/GenerateDocs.ps1 @@ -19,9 +19,9 @@ $ErrorActionPreference = 'Stop' $thisDirectory = (Split-Path -parent $MyInvocation.MyCommand.Definition); $psModuleName = 'chocolateyInstaller' -$psModuleLocation = [System.IO.Path]::GetFullPath("$thisDirectory\..\src\chocolatey.resources\helpers\chocolateyInstaller.psm1") -$docsFolder = [System.IO.Path]::GetFullPath("$thisDirectory\..\docs\generated") -$chocoExe = [System.IO.Path]::GetFullPath("$thisDirectory\..\code_drop\chocolatey\console\choco.exe") +$psModuleLocation = [System.IO.Path]::GetFullPath("$thisDirectory\src\chocolatey.resources\helpers\chocolateyInstaller.psm1") +$docsFolder = [System.IO.Path]::GetFullPath("$thisDirectory\docs\generated") +$chocoExe = [System.IO.Path]::GetFullPath("$thisDirectory\code_drop\chocolatey\console\choco.exe") $lineFeed = "`r`n" $global:powerShellReferenceTOC = @' # PowerShell Functions aka Helpers Reference @@ -107,7 +107,7 @@ function Replace-CommonItems($text) { $text = $text.Replace("`n",$lineFeed) $text = $text -replace '(community feed[s]?|community repository)', '[$1](https://chocolatey.org/packages)' - $text = $text -replace '(Chocolatey for Business|Chocolatey Pro[fessional]*)', '[$1](https://chocolatey.org/compare)' + $text = $text -replace '(Chocolatey for Business|Chocolatey Professional|Chocolatey Pro)(?=[^\w])', '[$1](https://chocolatey.org/compare)' $text = $text -replace '(Pro[fessional]\s?/\s?Business)', '[$1](https://chocolatey.org/compare)' $text = $text -replace '([Ll]icensed editions)', '[$1](https://chocolatey.org/compare)' $text = $text -replace '([Ll]icensed versions)', '[$1](https://chocolatey.org/compare)' @@ -198,7 +198,7 @@ param( $commandText = $commandText -replace '^(.+):\s(.+.gif)$', '![$1]($2)' $commandText = $commandText -replace '^(\s+)\<\?xml', "~~~xml$lineFeed`$1', "`$1$lineFeed~~~" - $commandText = $commandText -replace '(Chocolatey for Business|Chocolatey Pro[fessional]*)', '[$1](https://chocolatey.org/compare)' + $commandText = $commandText -replace '(Chocolatey for Business|Chocolatey Professional|Chocolatey Pro)(?=[^\w])', '[$1](https://chocolatey.org/compare)' $commandText = $commandText -replace '(Pro[fessional]\s?/\s?Business)', '[$1](https://chocolatey.org/compare)' $commandText = $commandText -replace '([Ll]icensed editions)', '[$1](https://chocolatey.org/compare)' $commandText = $commandText -replace '([Ll]icensed versions)', '[$1](https://chocolatey.org/compare)' diff --git a/docs/generated/CommandsDownload.md b/docs/generated/CommandsDownload.md index fd95687edb..068634d51d 100644 --- a/docs/generated/CommandsDownload.md +++ b/docs/generated/CommandsDownload.md @@ -7,6 +7,9 @@ Downloads a package from a source, optionally downloading remote existing package and makes it available without any internet requirement. +See https://chocolatey.org/docs/features-automatically-recompile-packages + + ## Usage choco download ] @@ -14,7 +17,9 @@ Downloads a package from a source, optionally downloading remote ## Examples choco download sysinternals - choco download notepadplusplus.install --recompile --embed + choco download notepadplusplus.install --recompile + choco download notepadplusplus.install --recompile --resources-location \\server\share + choco download notepadplusplus.install --recompile --resources-location http://somewhere/internal ## See It In Action diff --git a/docs/generated/CommandsInstall.md b/docs/generated/CommandsInstall.md index f1b9b37dd9..0113f0a0b4 100644 --- a/docs/generated/CommandsInstall.md +++ b/docs/generated/CommandsInstall.md @@ -333,36 +333,49 @@ Includes [[default options/switches|CommandsReference#default-options-and-switch Skip Download Cache - Use the original download even if a private CDN cache is available for a package. Overrides the default feature 'downloadCache' set to 'True'. Available in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) - only. + only. See https://chocolatey.org/docs/features-private-cdn --dc, --downloadcache, --download-cache, --use-download-cache Use Download Cache - Use private CDN cache if available for a package. Overrides the default feature 'downloadCache' set to 'True'. Available - in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) only. + in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) only. See https://chocolate- + y.org/docs/features-private-cdn --svc, --skipvirus, --skip-virus, --skipviruscheck, --skip-virus-check Skip Virus Check - Skip the virus check for downloaded files on this ru- n. Overrides the default feature 'virusCheck' set to 'True'. Available - in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) only. + in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) only. See https://chocolate- + y.org/docs/features-virus-check --virus, --viruscheck, --virus-check Virus Check - check downloaded files for viruses. Overrides the default feature 'virusCheck' set to 'True'. Available in 0.9.10+. Licensed - versions only. + versions only. See https://chocolatey.org/docs/features-virus-check --viruspositivesmin, --virus-positives-minimum=VALUE Virus Check Minimum Scan Result Positives - the minimum number of scan result positives required to flag a package. Used when virusScannerType is VirusTotal. Overrides the default configuration value 'virusCheckMinimumPositives' set to '5'. Available in 0.9.10+. Licensed - versions only. + versions only. See https://chocolatey.org/docs/features-virus-check + + --install-arguments-sensitive=VALUE + InstallArgumentsSensitive - Install Arguments to pass to the native + installer in the package that are sensitive and you do not want logged. + Defaults to unspecified. Available in 0.10.1+. [Licensed versions](https://chocolatey.org/compare) only. + + --package-parameters-sensitive=VALUE + PackageParametersSensitive - Package Parameters to pass the package that + are sensitive and you do not want logged. Defaults to unspecified. + Available in 0.10.1+. [Licensed versions](https://chocolatey.org/compare) only. --dir, --directory, --installdir, --installdirectory, --install-dir, --install-directory=VALUE Install Directory Override - Override the default installation director- y. Chocolatey will automatically determine the type of installer and pass the appropriate arguments to override the install directory. The package must use Chocolatey install helpers and be installing an - installer for software. Available in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) only. + installer for software. Available in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) only. + See https://chocolatey.org/docs/features-install-directory-override ~~~ diff --git a/docs/generated/CommandsNew.md b/docs/generated/CommandsNew.md index d45b39a1fd..0ef18adfc3 100644 --- a/docs/generated/CommandsNew.md +++ b/docs/generated/CommandsNew.md @@ -128,8 +128,27 @@ Includes [[default options/switches|CommandsReference#default-options-and-switch override. Available in 0.9.10+. --file=VALUE - Inspect a file (installer) to determine everything and create a package. - Available in 0.9.10+. Business versions only. + Inspect a file (native installer or zip) to to completely create a + package with proper silent arguments! Can be 32-bit or 64-bit + architecture. Available in 0.9.10+. Business versions only. See + https://chocolatey.org/docs/features-create-packages-from-installers + + --file64=VALUE + Optional - used when specifying both a 32-bit and a 64-bit file. Can be + an installer or a zip. Available in 0.9.10+. Business versions only. + + --url=VALUE + Url to download a file from to inspect and create a package. Available + in 0.9.10+. Business versions only. + + --url64=VALUE + 64 bit Url to download a file from. Inspects this file to create a + package if url isn't also specified. Available in 0.9.10+. Business + versions only. + + --keepremote, --originallocation, --original-location, --useoriginallocation, --use-original-location, --useoriginalfileslocation, --use-original-files-location + Use Original Files Location - when using file or url, use the original + location in packaging. Available in 0.9.10+. Business versions only. ~~~ diff --git a/docs/generated/CommandsUpgrade.md b/docs/generated/CommandsUpgrade.md index 3c222f323b..d608a8a893 100644 --- a/docs/generated/CommandsUpgrade.md +++ b/docs/generated/CommandsUpgrade.md @@ -239,36 +239,49 @@ Includes [[default options/switches|CommandsReference#default-options-and-switch Skip Download Cache - Use the original download even if a private CDN cache is available for a package. Overrides the default feature 'downloadCache' set to 'True'. Available in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) - only. + only. See https://chocolatey.org/docs/features-private-cdn --dc, --downloadcache, --download-cache, --use-download-cache Use Download Cache - Use private CDN cache if available for a package. Overrides the default feature 'downloadCache' set to 'True'. Available - in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) only. + in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) only. See https://chocolate- + y.org/docs/features-private-cdn --svc, --skipvirus, --skip-virus, --skipviruscheck, --skip-virus-check Skip Virus Check - Skip the virus check for downloaded files on this ru- n. Overrides the default feature 'virusCheck' set to 'True'. Available - in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) only. + in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) only. See https://chocolate- + y.org/docs/features-virus-check --virus, --viruscheck, --virus-check Virus Check - check downloaded files for viruses. Overrides the default feature 'virusCheck' set to 'True'. Available in 0.9.10+. Licensed - versions only. + versions only. See https://chocolatey.org/docs/features-virus-check --viruspositivesmin, --virus-positives-minimum=VALUE Virus Check Minimum Scan Result Positives - the minimum number of scan result positives required to flag a package. Used when virusScannerType is VirusTotal. Overrides the default configuration value 'virusCheckMinimumPositives' set to '5'. Available in 0.9.10+. Licensed - versions only. + versions only. See https://chocolatey.org/docs/features-virus-check + + --install-arguments-sensitive=VALUE + InstallArgumentsSensitive - Install Arguments to pass to the native + installer in the package that are sensitive and you do not want logged. + Defaults to unspecified. Available in 0.10.1+. [Licensed versions](https://chocolatey.org/compare) only. + + --package-parameters-sensitive=VALUE + PackageParametersSensitive - Package Parameters to pass the package that + are sensitive and you do not want logged. Defaults to unspecified. + Available in 0.10.1+. [Licensed versions](https://chocolatey.org/compare) only. --dir, --directory, --installdir, --installdirectory, --install-dir, --install-directory=VALUE Install Directory Override - Override the default installation director- y. Chocolatey will automatically determine the type of installer and pass the appropriate arguments to override the install directory. The package must use Chocolatey install helpers and be installing an - installer for software. Available in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) only. + installer for software. Available in 0.9.10+. [Licensed versions](https://chocolatey.org/compare) only. + See https://chocolatey.org/docs/features-install-directory-override ~~~ diff --git a/docs/generated/HelpersGetChecksumValid.md b/docs/generated/HelpersGetChecksumValid.md index b74b172373..6beca1eba1 100644 --- a/docs/generated/HelpersGetChecksumValid.md +++ b/docs/generated/HelpersGetChecksumValid.md @@ -131,6 +131,8 @@ MD5 is not recommended as certain organizations need to use FIPS compliant algorithms for hashing - see https://support.microsoft.com/en-us/kb/811833 for more details. +The recommendation is to use at least SHA256. + Property | Value ---------------------- | ----- Aliases | diff --git a/docs/generated/HelpersGetChocolateyUnzip.md b/docs/generated/HelpersGetChocolateyUnzip.md index 19712dece7..ae7277a82b 100644 --- a/docs/generated/HelpersGetChocolateyUnzip.md +++ b/docs/generated/HelpersGetChocolateyUnzip.md @@ -64,9 +64,11 @@ This is the full path to the zip file. If embedding it in the package next to the install script, the path will be like `"$(Split-Path -Parent $MyInvocation.MyCommand.Definition)\\file.zip"` +In 0.10.1+, `File` is an alias for FileFullPath. + Property | Value ---------------------- | ----- -Aliases | +Aliases | file Required? | true Position? | 1 Default Value | diff --git a/docs/generated/HelpersGetChocolateyWebFile.md b/docs/generated/HelpersGetChocolateyWebFile.md index 1be90a3bca..303e0208a4 100644 --- a/docs/generated/HelpersGetChocolateyWebFile.md +++ b/docs/generated/HelpersGetChocolateyWebFile.md @@ -16,6 +16,7 @@ Get-ChocolateyWebFile ` [-ChecksumType64 ] ` [-Options ] ` [-GetOriginalFileName] ` + [-ForceDownload] ` [-IgnoredArguments ] [] ~~~ @@ -149,14 +150,16 @@ parameter. Chocolatey will automatically determine if the user is running a 64 bit OS or not and adjust accordingly. Please note that the 32 bit url will be used in the absence of this. This parameter should only be used for 64 bit native software. If the original Url -contains both (which is quite rare), set this to '$url' Otherwise remove -this parameter. +contains both (which is quite rare), set this to '$url' Otherwise +remove this parameter. Prefer HTTPS when available. Can be HTTP, FTP, or File URIs. +In 0.10.1+, `Url64` is an alias for Url64bit. + Property | Value ---------------------- | ----- -Aliases | +Aliases | url64 Required? | false Position? | 4 Default Value | @@ -195,6 +198,8 @@ MD5 is not recommended as certain organizations need to use FIPS compliant algorithms for hashing - see https://support.microsoft.com/en-us/kb/811833 for more details. +The recommendation is to use at least SHA256. + Property | Value ---------------------- | ----- Aliases | @@ -243,6 +248,8 @@ MD5 is not recommended as certain organizations need to use FIPS compliant algorithms for hashing - see https://support.microsoft.com/en-us/kb/811833 for more details. +The recommendation is to use at least SHA256. + Property | Value ---------------------- | ------------- Aliases | @@ -264,7 +271,21 @@ Accept Pipeline Input? | false ### -GetOriginalFileName OPTIONAL switch to allow Chocolatey to determine the original file name -from the url resource. +from the url resource. Available in 0.9.10+. + +Property | Value +---------------------- | ----- +Aliases | +Required? | false +Position? | named +Default Value | False +Accept Pipeline Input? | false + +### -ForceDownload +OPTIONAL switch to force download of file every time, even if the file +already exists. + +Available in 0.10.1+. Property | Value ---------------------- | ----- diff --git a/docs/generated/HelpersGetVirusCheckValid.md b/docs/generated/HelpersGetVirusCheckValid.md index 89ec583b5e..901f440b87 100644 --- a/docs/generated/HelpersGetVirusCheckValid.md +++ b/docs/generated/HelpersGetVirusCheckValid.md @@ -20,7 +20,7 @@ in Pro / Business editions. ## Notes -Only [licensed editions](https://chocolatey.org/compare) of [Chocolatey pro](https://chocolatey.org/compare)vide runtime malware protection. +Only [licensed editions](https://chocolatey.org/compare) of Chocolatey provide runtime malware protection. ## Aliases diff --git a/docs/generated/HelpersInstallChocolateyInstallPackage.md b/docs/generated/HelpersInstallChocolateyInstallPackage.md index 100d3de556..2b52bb02c6 100644 --- a/docs/generated/HelpersInstallChocolateyInstallPackage.md +++ b/docs/generated/HelpersInstallChocolateyInstallPackage.md @@ -165,8 +165,8 @@ you can get it to the path with `"$(Split-Path -parent $MyInvocation.MyCommand.Definition)\\INSTALLER_FILE"` Property | Value ----------------------- | ----- -Aliases | +---------------------- | ------------ +Aliases | fileFullPath Required? | true Position? | 4 Default Value | diff --git a/docs/generated/HelpersInstallChocolateyPackage.md b/docs/generated/HelpersInstallChocolateyPackage.md index 9392d181ef..0e17555ea8 100644 --- a/docs/generated/HelpersInstallChocolateyPackage.md +++ b/docs/generated/HelpersInstallChocolateyPackage.md @@ -22,6 +22,7 @@ Install-ChocolateyPackage ` [-ChecksumType64 ] ` [-Options ] ` [-UseOnlyPackageSilentArguments] ` + [-UseOriginalLocation] ` [-IgnoredArguments ] [] ~~~ @@ -76,7 +77,7 @@ $packageArgs = @{ validExitCodes= @(0, 3010, 1641) softwareName = 'Bob*' checksum = '12345' - checksumType = 'sha1' + checksumType = 'sha256' checksum64 = '123356' checksumType64= 'sha256' } @@ -285,6 +286,8 @@ MD5 is not recommended as certain organizations need to use FIPS compliant algorithms for hashing - see https://support.microsoft.com/en-us/kb/811833 for more details. +The recommendation is to use at least SHA256. + Property | Value ---------------------- | ----- Aliases | @@ -327,6 +330,8 @@ MD5 is not recommended as certain organizations need to use FIPS compliant algorithms for hashing - see https://support.microsoft.com/en-us/kb/811833 for more details. +The recommendation is to use at least SHA256. + Property | Value ---------------------- | ----- Aliases | @@ -358,6 +363,22 @@ Position? | named Default Value | False Accept Pipeline Input? | false +### -UseOriginalLocation +Do not download the resources. This is typically passed if Url/Url64bit +are pointed to local files or files on a share and those files should +be used in place. Available in 0.10.1+. + +NOTE: You can also use `Install-ChocolateyInstallPackage` for the same +functionality (see links). + +Property | Value +---------------------- | ----- +Aliases | +Required? | false +Position? | named +Default Value | False +Accept Pipeline Input? | false + ### -IgnoredArguments [<Object[]>] Allows splatting with arguments that do not apply. Do not use directly. diff --git a/docs/generated/HelpersInstallChocolateyPowershellCommand.md b/docs/generated/HelpersInstallChocolateyPowershellCommand.md index a172f421ac..1c5584d510 100644 --- a/docs/generated/HelpersInstallChocolateyPowershellCommand.md +++ b/docs/generated/HelpersInstallChocolateyPowershellCommand.md @@ -180,6 +180,8 @@ MD5 is not recommended as certain organizations need to use FIPS compliant algorithms for hashing - see https://support.microsoft.com/en-us/kb/811833 for more details. +The recommendation is to use at least SHA256. + Property | Value ---------------------- | ----- Aliases | @@ -228,6 +230,8 @@ MD5 is not recommended as certain organizations need to use FIPS compliant algorithms for hashing - see https://support.microsoft.com/en-us/kb/811833 for more details. +The recommendation is to use at least SHA256. + Property | Value ---------------------- | ----- Aliases | diff --git a/docs/generated/HelpersInstallChocolateyVsixPackage.md b/docs/generated/HelpersInstallChocolateyVsixPackage.md index d1a6b61a84..068ddf642a 100644 --- a/docs/generated/HelpersInstallChocolateyVsixPackage.md +++ b/docs/generated/HelpersInstallChocolateyVsixPackage.md @@ -150,6 +150,8 @@ MD5 is not recommended as certain organizations need to use FIPS compliant algorithms for hashing - see https://support.microsoft.com/en-us/kb/811833 for more details. +The recommendation is to use at least SHA256. + Property | Value ---------------------- | ----- Aliases | diff --git a/docs/generated/HelpersInstallChocolateyZipPackage.md b/docs/generated/HelpersInstallChocolateyZipPackage.md index 1d76607e6a..dc7af3beff 100644 --- a/docs/generated/HelpersInstallChocolateyZipPackage.md +++ b/docs/generated/HelpersInstallChocolateyZipPackage.md @@ -189,6 +189,8 @@ MD5 is not recommended as certain organizations need to use FIPS compliant algorithms for hashing - see https://support.microsoft.com/en-us/kb/811833 for more details. +The recommendation is to use at least SHA256. + Property | Value ---------------------- | ----- Aliases | @@ -231,6 +233,8 @@ MD5 is not recommended as certain organizations need to use FIPS compliant algorithms for hashing - see https://support.microsoft.com/en-us/kb/811833 for more details. +The recommendation is to use at least SHA256. + Property | Value ---------------------- | ----- Aliases | diff --git a/docs/generated/HelpersStartChocolateyProcessAsAdmin.md b/docs/generated/HelpersStartChocolateyProcessAsAdmin.md index ddca4582e9..95003410dd 100644 --- a/docs/generated/HelpersStartChocolateyProcessAsAdmin.md +++ b/docs/generated/HelpersStartChocolateyProcessAsAdmin.md @@ -14,6 +14,8 @@ Start-ChocolateyProcessAsAdmin ` [-Minimized] ` [-NoSleep] ` [-ValidExitCodes ] ` + [-WorkingDirectory ] ` + [-SensitiveStatements ] ` [-IgnoredArguments ] [] ~~~ @@ -132,6 +134,37 @@ Position? | named Default Value | @(0) Accept Pipeline Input? | false +### -WorkingDirectory [<String>] +The working directory for the running process. Defaults to +`Get-Location`. + +Available in 0.10.1+. + +Property | Value +---------------------- | --------------- +Aliases | +Required? | false +Position? | named +Default Value | $(Get-Location) +Accept Pipeline Input? | false + +### -SensitiveStatements [<String>] +Arguments to pass to `ExeToRun` that are not logged. + +Note that only [licensed versions](https://chocolatey.org/compare) of Chocolatey provide a way to pass +those values completely through without having them in the install +script or on the system in some way. + +Available in 0.10.1+. + +Property | Value +---------------------- | ----- +Aliases | +Required? | false +Position? | named +Default Value | +Accept Pipeline Input? | false + ### -IgnoredArguments [<Object[]>] Allows splatting with arguments that do not apply. Do not use directly. diff --git a/src/chocolatey.resources/helpers/functions/Get-CheckSumValid.ps1 b/src/chocolatey.resources/helpers/functions/Get-CheckSumValid.ps1 index 85b19916ea..fa28c3a6d0 100644 --- a/src/chocolatey.resources/helpers/functions/Get-CheckSumValid.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-CheckSumValid.ps1 @@ -164,9 +164,13 @@ param( if (!([System.IO.File]::Exists($file))) { throw "Unable to checksum a file that doesn't exist - Could not find file `'$file`'" } + if ($checksumType -eq $null -or $checksumType -eq ''){ + $checksumType = 'md5' + } + if ($checksumType -ne 'sha1' -and $checksumType -ne 'sha256' -and $checksumType -ne 'sha512' -and $checksumType -ne 'md5') { Write-Debug 'Setting checksumType to md5 due to non-set value or type is not specified correctly.' - $checksumType = 'md5' + throw "Checksum type '$checksumType' is unsupported. This type may be supported in a newer version of Chocolatey." } $checksumExe = Join-Path "$helpersPath" '..\tools\checksum.exe' diff --git a/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 b/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 index 598bbad19b..f8aaf4336b 100644 --- a/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 @@ -126,7 +126,13 @@ OPTIONAL - Specify custom headers. Available in 0.9.10+. .PARAMETER GetOriginalFileName OPTIONAL switch to allow Chocolatey to determine the original file name -from the url resource. +from the url resource. Available in 0.9.10+. + +.PARAMETER ForceDownload +OPTIONAL switch to force download of file every time, even if the file +already exists. + +Available in 0.10.1+. .PARAMETER IgnoredArguments Allows splatting with arguments that do not apply. Do not use directly. @@ -191,6 +197,7 @@ param( [parameter(Mandatory=$false)][string] $checksumType64 = $checksumType, [parameter(Mandatory=$false)][hashtable] $options = @{Headers=@{}}, [parameter(Mandatory=$false)][switch] $getOriginalFileName, + [parameter(Mandatory=$false)][switch] $forceDownload, [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) Write-Debug "Running 'Get-ChocolateyWebFile' for $packageName with url:`'$url`', fileFullPath:`'$fileFullPath`', url64bit:`'$url64bit`', checksum: `'$checksum`', checksumType: `'$checksumType`', checksum64: `'$checksum64`', checksumType64: `'$checksumType64`'"; @@ -246,11 +253,23 @@ param( throw "This package does not support $bitWidth bit architecture." } + # determine if the url can be SSL/TLS + if ($url.StartsWith('http:')) { + try { + $httpsUrl = $url.Replace("http://", "https://") + Get-WebHeaders -Url $httpsUrl -ErrorAction "Stop" | Out-Null + $url = $httpsUrl + Write-Warning "Url has SSL/TLS available, switching to HTTPS for download" + } catch { + Write-Debug "Url does not have HTTPS available" + } + } + if ($getOriginalFileName) { try { $fileDirectory = [System.IO.Path]::GetDirectoryName($fileFullPath) $originalFileName = [System.IO.Path]::GetFileName($fileFullPath) - $fileFullPath = Get-WebFileName -url $url -defaultName $originalFileName + $fileFullPath = Get-WebFileName -Url $url -DefaultName $originalFileName $fileFullPath = Join-Path $fileDirectory $fileFullPath $fileFullPath = [System.IO.Path]::GetFullPath($fileFullPath) } catch { @@ -271,16 +290,18 @@ param( $headers = @{} if ($url.StartsWith('http')) { try { - $headers = Get-WebHeaders $url -ErrorAction "Stop" + $headers = Get-WebHeaders -Url $url -ErrorAction "Stop" } catch { - if ($host.Version -lt (new-object 'Version' 3,0)) { + if ($host.Version -lt (New-Object 'Version' 3,0)) { Write-Debug "Converting Security Protocol to SSL3 only for Powershell v2" # this should last for the entire duration + $originalProtocol = [System.Net.ServicePointManager]::SecurityProtocol [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Ssl3 try { - $headers = Get-WebHeaders $url -ErrorAction "Stop" + $headers = Get-WebHeaders -Url $url -ErrorAction "Stop" } catch { Write-Host "Attempt to get headers for $url failed.`n $($_.Exception.Message)" + [System.Net.ServicePointManager]::SecurityProtocol = $originalProtocol } } else { Write-Host "Attempt to get headers for $url failed.`n $($_.Exception.Message)" @@ -288,25 +309,35 @@ param( } $needsDownload = $true - if ($headers.Count -ne 0 -and $headers.ContainsKey("Content-Length")) { - $fi = new-object System.IO.FileInfo($fileFullPath) - # if the file already exists there is no reason to download it again. - if ($fi.Exists -and $fi.Length -eq $headers["Content-Length"]) { - Write-Debug "$($packageName)'s requested file has already been downloaded. Using cached copy at - `'$fileFullPath`'." - $needsDownload = $false + $fiCached = New-Object System.IO.FileInfo($fileFullPath) + if ($fiCached.Exists -and -not ($forceDownload)) { + if ($checksum -ne $null -and $checksum -ne '') { + try { + Write-Host "File appears to be downloaded already. Verifying with package checksum to determine if it needs to be redownloaded." + Get-ChecksumValid -file $fileFullPath -checkSum $checksum -checksumType $checksumType -originalUrl $url -ErrorAction "Stop" + $needsDownload = $false + } catch { + Write-Debug "Existing file failed checksum. Will be redownloaded from url." + } + } + elseif ($headers.Count -ne 0 -and $headers.ContainsKey("Content-Length")) { + # if the file already exists there is no reason to download it again. + if ($fiCached.Length -eq $headers["Content-Length"]) { $needsDownload = $false } } } if ($needsDownload) { Write-Host "Downloading $packageName $bitPackage from `'$url`'" - Get-WebFile $url $fileFullPath -options $options + Get-WebFile -Url $url -FileName $fileFullPath -Options $options + } else { + Write-Debug "$($packageName)'s requested file has already been downloaded. Using cached copy at + '$fileFullPath'." } } elseif ($url.StartsWith('ftp')) { Write-Host "Ftp-ing $packageName - from `'$url`'" - Get-FtpFile $url $fileFullPath + from '$url'" + Get-FtpFile -Url $url -FileName $fileFullPath } else { if ($url.StartsWith('file:')) { $url = ([uri] $url).LocalPath } Write-Host "Copying $packageName @@ -317,30 +348,29 @@ param( Start-Sleep 2 #give it a sec or two to finish up copying - $fi = new-object System.IO.FileInfo($fileFullPath) + $fi = New-Object System.IO.FileInfo($fileFullPath) # validate file exists if (!($fi.Exists)) { throw "Chocolatey expected a file to be downloaded to `'$fileFullPath`' but nothing exists at that location." } - Get-VirusCheckValid -location $url -file $fileFullPath + Get-VirusCheckValid -Location $url -File $fileFullPath - if ($headers.Count -ne 0) { + if ($headers.Count -ne 0 -and ($checksum -eq $null -or $checksum -eq '')) { # validate length is what we expected - Write-Debug "Checking that `'$fileFullPath`' is the size we expect it to be." - if ($headers.ContainsKey("Content-Length") -and ($fi.Length -ne $headers["Content-Length"])) { throw "Chocolatey expected a file at `'$fileFullPath`' to be of length `'$($headers["Content-Length"])`' but the length was `'$($fi.Length)`'." } + Write-Debug "Checking that '$fileFullPath' is the size we expect it to be." + if ($headers.ContainsKey("Content-Length") -and ($fi.Length -ne $headers["Content-Length"])) { throw "Chocolatey expected a file at '$fileFullPath' to be of length '$($headers["Content-Length"])' but the length was '$($fi.Length)'." } if ($headers.ContainsKey("X-Checksum-Sha1")) { $remoteChecksum = $headers["X-Checksum-Sha1"] - Write-Debug "Verifying remote checksum of `'$remoteChecksum`' for `'$fileFullPath`'." - Get-ChecksumValid -file $fileFullPath -checkSum $remoteChecksum -checksumType 'sha1' + Write-Debug "Verifying remote checksum of '$remoteChecksum' for '$fileFullPath'." + Get-ChecksumValid -File $fileFullPath -Checksum $remoteChecksum -ChecksumType 'sha1' -OriginalUrl $url } } #skip requirement for embedded files if checksum is not provided if ($urlIsRemote -or ($checksum -ne $null -and $checksum -ne '')) { Write-Debug "Verifying package provided checksum of '$checksum' for '$fileFullPath'." - Get-ChecksumValid -file $fileFullPath -checkSum $checksum -checksumType $checksumType -originalUrl $url + Get-ChecksumValid -File $fileFullPath -Checksum $checksum -ChecksumType $checksumType -OriginalUrl $url } - return $fileFullPath } diff --git a/src/chocolatey.resources/helpers/functions/Get-WebFileName.ps1 b/src/chocolatey.resources/helpers/functions/Get-WebFileName.ps1 index 450717f3b1..c678a8c08f 100644 --- a/src/chocolatey.resources/helpers/functions/Get-WebFileName.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-WebFileName.ps1 @@ -74,7 +74,6 @@ param( Write-Debug "Running 'Get-WebFileName' to determine name with url:'$url', defaultName:'$defaultName'"; - $originalFileName = $defaultName $fileName = $null @@ -95,6 +94,11 @@ param( #continue on } + if ($url.StartsWith('ftp')) { + Write-Debug "Url is FTP, using default name." + return $originalFileName + } + $request = [System.Net.HttpWebRequest]::Create($url) if ($request -eq $null) { Write-Debug "Request was null, using default name." diff --git a/src/chocolatey.resources/helpers/functions/Get-WebHeaders.ps1 b/src/chocolatey.resources/helpers/functions/Get-WebHeaders.ps1 index d92d8e643a..5568142278 100644 --- a/src/chocolatey.resources/helpers/functions/Get-WebHeaders.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-WebHeaders.ps1 @@ -131,7 +131,6 @@ param( } $headers = @{} - try { $response = $request.GetResponse(); Write-Debug "Response Headers:" diff --git a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 index 38ead1307b..220d24b0bc 100644 --- a/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 +++ b/src/chocolatey.resources/helpers/functions/Install-ChocolateyPackage.ps1 @@ -171,6 +171,14 @@ OPTIONAL - Specify custom headers. Available in 0.9.10+. Do not allow choco to provide/merge additional silent arguments and only use the ones available with the package. Available in 0.9.10+. +.PARAMETER UseOriginalLocation +Do not download the resources. This is typically passed if Url/Url64bit +are pointed to local files or files on a share and those files should +be used in place. Available in 0.10.1+. + +NOTE: You can also use `Install-ChocolateyInstallPackage` for the same +functionality (see links). + .PARAMETER IgnoredArguments Allows splatting with arguments that do not apply. Do not use directly. @@ -262,11 +270,12 @@ param( [parameter(Mandatory=$false)][hashtable] $options = @{Headers=@{}}, [parameter(Mandatory=$false)] [alias("useOnlyPackageSilentArgs")][switch] $useOnlyPackageSilentArguments = $false, + [switch]$useOriginalLocation, [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) [string]$silentArgs = $silentArgs -join ' ' - Write-Debug "Running 'Install-ChocolateyPackage' for $packageName with url:`'$url`', args: `'$silentArgs`', fileType: `'$fileType`', url64bit: `'$url64bit`', checksum: `'$checksum`', checksumType: `'$checksumType`', checksum64: `'$checksum64`', checksumType64: `'$checksumType64`', validExitCodes: `'$validExitCodes`' "; + Write-Debug "Running 'Install-ChocolateyPackage' for $packageName with url:'$url', args:'$silentArgs', fileType:'$fileType', url64bit:'$url64bit', checksum:'$checksum', checksumType:'$checksumType', checksum64:'$checksum64', checksumType64:'$checksumType64', validExitCodes:'$validExitCodes'"; $chocTempDir = $env:TEMP $tempDir = Join-Path $chocTempDir "$($env:chocolateyPackageName)" @@ -275,6 +284,34 @@ param( if (![System.IO.Directory]::Exists($tempDir)) { [System.IO.Directory]::CreateDirectory($tempDir) | Out-Null } $file = Join-Path $tempDir "$($packageName)Install.$fileType" - $filePath = Get-ChocolateyWebFile $packageName $file $url $url64bit -checksum $checksum -checksumType $checksumType -checksum64 $checksum64 -checksumType64 $checksumType64 -options $options -getOriginalFileName - Install-ChocolateyInstallPackage $packageName $fileType $silentArgs $filePath -validExitCodes $validExitCodes -UseOnlyPackageSilentArguments:$useOnlyPackageSilentArguments + [string]$filePath = $file + if ($useOriginalLocation) { + $filePath = $url + if (Get-ProcessorBits 64) { + $forceX86 = $env:chocolateyForceX86 + if ($forceX86) { + Write-Debug "User specified '-x86' so forcing 32-bit" + } else { + $filePath = $url64bit + } + } + } else { + $filePath = Get-ChocolateyWebFile -PackageName $packageName ` + -FileFullPath $file ` + -Url $url ` + -Url64bit $url64bit ` + -Checksum $checksum ` + -ChecksumType $checksumType ` + -Checksum64 $checksum64 ` + -ChecksumType64 $checksumType64 ` + -Options $options ` + -GetOriginalFileName + } + + Install-ChocolateyInstallPackage -PackageName $packageName ` + -FileType $fileType ` + -SilentArgs $silentArgs ` + -File $filePath ` + -ValidExitCodes $validExitCodes ` + -UseOnlyPackageSilentArguments:$useOnlyPackageSilentArguments } diff --git a/src/chocolatey.resources/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1 b/src/chocolatey.resources/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1 index c99616148f..18c67bded0 100644 --- a/src/chocolatey.resources/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1 +++ b/src/chocolatey.resources/helpers/functions/Start-ChocolateyProcessAsAdmin.ps1 @@ -59,6 +59,15 @@ The working directory for the running process. Defaults to Available in 0.10.1+. +.PARAMETER SensitiveStatements +Arguments to pass to `ExeToRun` that are not logged. + +Note that only licensed versions of Chocolatey provide a way to pass +those values completely through without having them in the install +script or on the system in some way. + +Available in 0.10.1+. + .PARAMETER IgnoredArguments Allows splatting with arguments that do not apply. Do not use directly. @@ -90,11 +99,12 @@ param( [parameter(Mandatory=$false)][switch] $noSleep, [parameter(Mandatory=$false)] $validExitCodes = @(0), [parameter(Mandatory=$false)][string] $workingDirectory = $(Get-Location), + [parameter(Mandatory=$false)][string] $sensitiveStatements = '', [parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments ) [string]$statements = $statements -join ' ' - Write-Debug "Running 'Start-ChocolateyProcessAsAdmin' with exeToRun:`'$exeToRun`', statements: `'$statements`' "; + Write-Debug "Running 'Start-ChocolateyProcessAsAdmin' with exeToRun:'$exeToRun', statements: '$statements', workingDirectory: '$workingDirectory' "; try{ if ($exeToRun -ne $null) { $exeToRun = $exeToRun -replace "`0", "" } @@ -187,6 +197,10 @@ Elevating Permissions and running [`"$exeToRun`" $wrappedStatements]. This may t if ($wrappedStatements -ne '') { $psi.Arguments = "$wrappedStatements" } + if ($sensitiveStatements -ne $null -and $sensitiveStatements -ne '') { + Write-Host "Sensitive arguments have been passed. Adding to arguments." + $psi.Arguments += " $sensitiveStatements" + } $process.StartInfo = $psi # process start info @@ -225,7 +239,7 @@ Elevating Permissions and running [`"$exeToRun`" $wrappedStatements]. This may t Write-Debug "Command [`"$exeToRun`" $wrappedStatements] exited with `'$exitCode`'." if ($validExitCodes -notcontains $exitCode) { Set-PowerShellExitCode $exitCode - throw "Running [`"$exeToRun`" $statements] was not successful. Exit code was '$exitCode'. See log for possible error messages." + throw "Running [`"$exeToRun`" $wrappedStatements] was not successful. Exit code was '$exitCode'. See log for possible error messages." } else { $chocoSuccessCodes = @(0, 1605, 1614, 1641, 3010) if ($chocoSuccessCodes -notcontains $exitCode) { diff --git a/src/chocolatey.resources/tools/checksum.exe b/src/chocolatey.resources/tools/checksum.exe index 985f384fe8..9d6ce45080 100644 Binary files a/src/chocolatey.resources/tools/checksum.exe and b/src/chocolatey.resources/tools/checksum.exe differ diff --git a/src/chocolatey.resources/tools/shimgen.exe b/src/chocolatey.resources/tools/shimgen.exe index 08fb277e40..d8a322ad45 100644 Binary files a/src/chocolatey.resources/tools/shimgen.exe and b/src/chocolatey.resources/tools/shimgen.exe differ diff --git a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyInstallCommandSpecs.cs b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyInstallCommandSpecs.cs index 7cce208bb8..f43a002320 100644 --- a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyInstallCommandSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyInstallCommandSpecs.cs @@ -151,6 +151,18 @@ public void should_add_short_version_of_packageparameters_to_the_option_set() optionSet.Contains("params").ShouldBeTrue(); } + [Fact] + public void should_add_applyPackageParametersToDependencies_to_the_option_set() + { + optionSet.Contains("apply-package-parameters-to-dependencies").ShouldBeTrue(); + } + + [Fact] + public void should_add_applyInstallArgumentsToDependencies_to_the_option_set() + { + optionSet.Contains("apply-install-arguments-to-dependencies").ShouldBeTrue(); + } + [Fact] public void should_add_allowmultipleversions_to_the_option_set() { diff --git a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyUninstallCommandSpecs.cs b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyUninstallCommandSpecs.cs index 7a260134ea..3ebd5cce59 100644 --- a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyUninstallCommandSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyUninstallCommandSpecs.cs @@ -133,6 +133,18 @@ public void should_add_short_version_of_packageparameters_to_the_option_set() optionSet.Contains("params").ShouldBeTrue(); } + [Fact] + public void should_add_applyPackageParametersToDependencies_to_the_option_set() + { + optionSet.Contains("apply-package-parameters-to-dependencies").ShouldBeTrue(); + } + + [Fact] + public void should_add_applyInstallArgumentsToDependencies_to_the_option_set() + { + optionSet.Contains("apply-install-arguments-to-dependencies").ShouldBeTrue(); + } + [Fact] public void should_add_forcedependencies_to_the_option_set() { diff --git a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyUpgradeCommandSpecs.cs b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyUpgradeCommandSpecs.cs index a1706a3d00..fad894dd9f 100644 --- a/src/chocolatey.tests/infrastructure.app/commands/ChocolateyUpgradeCommandSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/commands/ChocolateyUpgradeCommandSpecs.cs @@ -145,6 +145,18 @@ public void should_add_short_version_of_packageparameters_to_the_option_set() optionSet.Contains("params").ShouldBeTrue(); } + [Fact] + public void should_add_applyPackageParametersToDependencies_to_the_option_set() + { + optionSet.Contains("apply-package-parameters-to-dependencies").ShouldBeTrue(); + } + + [Fact] + public void should_add_applyInstallArgumentsToDependencies_to_the_option_set() + { + optionSet.Contains("apply-install-arguments-to-dependencies").ShouldBeTrue(); + } + [Fact] public void should_add_allowmultipleversions_to_the_option_set() { diff --git a/src/chocolatey/chocolatey.csproj b/src/chocolatey/chocolatey.csproj index 79d71805de..0d497002cf 100644 --- a/src/chocolatey/chocolatey.csproj +++ b/src/chocolatey/chocolatey.csproj @@ -91,10 +91,12 @@ + + diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs index 18c9b162bf..fde190de50 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyInstallCommand.cs @@ -62,6 +62,12 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon .Add("params=|parameters=|pkgparameters=|packageparameters=|package-parameters=", "PackageParameters - Parameters to pass to the package. Defaults to unspecified.", option => configuration.PackageParameters = option.remove_surrounding_quotes()) + .Add("apply-install-arguments-to-dependencies", + "Apply Install Arguments To Dependencies - Should install arguments be applied to dependent packages? Defaults to false.", + option => configuration.ApplyInstallArgumentsToDependencies = option != null) + .Add("apply-package-parameters-to-dependencies", + "Apply Package Parameters To Dependencies - Should package parameters be applied to dependent packages? Defaults to false.", + option => configuration.ApplyPackageParametersToDependencies = option != null) .Add("allowdowngrade|allow-downgrade", "AllowDowngrade - Should an attempt at downgrading be allowed? Defaults to false.", option => configuration.AllowDowngrade = option != null) diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyUninstallCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyUninstallCommand.cs index 460a90ae9d..ab2358c31c 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyUninstallCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyUninstallCommand.cs @@ -58,6 +58,12 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon .Add("params=|parameters=|pkgparameters=|packageparameters=|package-parameters=", "PackageParameters - Parameters to pass to the package. Defaults to unspecified.", option => configuration.PackageParameters = option.remove_surrounding_quotes()) + .Add("apply-install-arguments-to-dependencies", + "Apply Install Arguments To Dependencies - Should install arguments be applied to dependent packages? Defaults to false.", + option => configuration.ApplyInstallArgumentsToDependencies = option != null) + .Add("apply-package-parameters-to-dependencies", + "Apply Package Parameters To Dependencies - Should package parameters be applied to dependent packages? Defaults to false.", + option => configuration.ApplyPackageParametersToDependencies = option != null) .Add("m|sxs|sidebyside|side-by-side|allowmultiple|allow-multiple|allowmultipleversions|allow-multiple-versions", "AllowMultipleVersions - Should multiple versions of a package be installed? Defaults to false.", option => configuration.AllowMultipleVersions = option != null) diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs index 67fc5334ea..3c1e7402da 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyUpgradeCommand.cs @@ -63,6 +63,12 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon .Add("params=|parameters=|pkgparameters=|packageparameters=|package-parameters=", "PackageParameters - Parameters to pass to the package. Defaults to unspecified.", option => configuration.PackageParameters = option.remove_surrounding_quotes()) + .Add("apply-install-arguments-to-dependencies", + "Apply Install Arguments To Dependencies - Should install arguments be applied to dependent packages? Defaults to false.", + option => configuration.ApplyInstallArgumentsToDependencies = option != null) + .Add("apply-package-parameters-to-dependencies", + "Apply Package Parameters To Dependencies - Should package parameters be applied to dependent packages? Defaults to false.", + option => configuration.ApplyPackageParametersToDependencies = option != null) .Add("allowdowngrade|allow-downgrade", "AllowDowngrade - Should an attempt at downgrading be allowed? Defaults to false.", option => configuration.AllowDowngrade = option != null) diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index a3968ab492..a54cca0958 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -71,7 +71,7 @@ private void output_tostring(StringBuilder propertyValues, IEnumerable + ValidInstallExitCodes = new List { 0 }; - ValidUninstallExitCodes = new List + ValidUninstallExitCodes = new List { 0 }; diff --git a/src/chocolatey/infrastructure.app/domain/installers/CustomInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/CustomInstaller.cs index fb978f6efd..b90ce6a31b 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/CustomInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/CustomInstaller.cs @@ -31,8 +31,8 @@ public CustomInstaller() UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); SilentUninstall = "/S"; OtherUninstallOptions = ""; - ValidInstallExitCodes = new List { 0 }; - ValidUninstallExitCodes = new List { 0 }; + ValidInstallExitCodes = new List { 0 }; + ValidUninstallExitCodes = new List { 0 }; } public override InstallerType InstallerType diff --git a/src/chocolatey/infrastructure.app/domain/installers/GhostInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/GhostInstaller.cs index 07ad9cd1d8..c6f7a00379 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/GhostInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/GhostInstaller.cs @@ -39,14 +39,8 @@ public GhostInstaller() UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); SilentUninstall = "-u -s"; OtherUninstallOptions = ""; - ValidInstallExitCodes = new List - { - 0 - }; - ValidUninstallExitCodes = new List - { - 0 - }; + ValidInstallExitCodes = new List { 0 }; + ValidUninstallExitCodes = new List { 0 }; } public override InstallerType InstallerType { get { return InstallerType.Ghost; } } diff --git a/src/chocolatey/infrastructure.app/domain/installers/IInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/IInstaller.cs index 34b5a517c2..5144dc0bad 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/IInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/IInstaller.cs @@ -30,8 +30,8 @@ public interface IInstaller string UninstallExecutable { get; } string SilentUninstall { get; } string OtherUninstallOptions { get; } - IEnumerable ValidInstallExitCodes { get; } - IEnumerable ValidUninstallExitCodes { get; } + IEnumerable ValidInstallExitCodes { get; } + IEnumerable ValidUninstallExitCodes { get; } string build_install_command_arguments(bool logFile, bool customInstallLocation, bool languageRequested); string build_uninstall_command_arguments(); diff --git a/src/chocolatey/infrastructure.app/domain/installers/InnoSetupInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/InnoSetupInstaller.cs index 8ceb0e5b66..05007a4e5f 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/InnoSetupInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/InnoSetupInstaller.cs @@ -38,8 +38,8 @@ public InnoSetupInstaller() SilentUninstall = "/VERYSILENT"; OtherUninstallOptions = "/SUPPRESSMSGBOXES"; // http://www.jrsoftware.org/ishelp/index.php?topic=setupexitcodes - ValidInstallExitCodes = new List { 0, 3010 }; - ValidUninstallExitCodes = new List { 0 }; + ValidInstallExitCodes = new List { 0, 3010 }; + ValidUninstallExitCodes = new List { 0 }; } public override InstallerType InstallerType diff --git a/src/chocolatey/infrastructure.app/domain/installers/InstallForJInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/InstallForJInstaller.cs index dd76e850e7..270af22411 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/InstallForJInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/InstallForJInstaller.cs @@ -39,11 +39,11 @@ public InstallForJInstaller() UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); SilentUninstall = "-q"; OtherUninstallOptions = ""; - ValidInstallExitCodes = new List + ValidInstallExitCodes = new List { 0 }; - ValidUninstallExitCodes = new List + ValidUninstallExitCodes = new List { 0 }; diff --git a/src/chocolatey/infrastructure.app/domain/installers/InstallShieldInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/InstallShieldInstaller.cs index 4ce5fc4444..f8d07b7962 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/InstallShieldInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/InstallShieldInstaller.cs @@ -38,8 +38,8 @@ public InstallShieldInstaller() SilentUninstall = "/uninst /s"; OtherUninstallOptions = "/sms"; // http://helpnet.installshield.com/installshield18helplib/IHelpSetup_EXEErrors.htm - ValidInstallExitCodes = new List {0, 1641, 3010}; - ValidUninstallExitCodes = new List { 0, 1605, 1614, 1641, 3010 }; + ValidInstallExitCodes = new List { 0, 1641, 3010 }; + ValidUninstallExitCodes = new List { 0, 1605, 1614, 1641, 3010 }; } public override InstallerType InstallerType diff --git a/src/chocolatey/infrastructure.app/domain/installers/InstallerBase.cs b/src/chocolatey/infrastructure.app/domain/installers/InstallerBase.cs index fc471233ae..bdb1cec453 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/InstallerBase.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/InstallerBase.cs @@ -32,8 +32,8 @@ public abstract class InstallerBase : IInstaller public string UninstallExecutable { get; protected set; } public string SilentUninstall { get; protected set; } public string OtherUninstallOptions { get; protected set; } - public IEnumerable ValidInstallExitCodes { get; protected set; } - public IEnumerable ValidUninstallExitCodes { get; protected set; } + public IEnumerable ValidInstallExitCodes { get; protected set; } + public IEnumerable ValidUninstallExitCodes { get; protected set; } public virtual string build_install_command_arguments(bool logFile, bool customInstallLocation, bool languageRequested) { diff --git a/src/chocolatey/infrastructure.app/domain/installers/IzPackInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/IzPackInstaller.cs index 9746aae255..6bcf6e5ebe 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/IzPackInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/IzPackInstaller.cs @@ -39,11 +39,11 @@ public IzPackInstaller() UninstallExecutable = "java"; //currently untested SilentUninstall = "-jar \"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); OtherUninstallOptions = ""; - ValidInstallExitCodes = new List + ValidInstallExitCodes = new List { 0 }; - ValidUninstallExitCodes = new List + ValidUninstallExitCodes = new List { 0 }; diff --git a/src/chocolatey/infrastructure.app/domain/installers/MsiInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/MsiInstaller.cs index 17b047fa8b..d1594d977e 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/MsiInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/MsiInstaller.cs @@ -51,10 +51,10 @@ public MsiInstaller() OtherUninstallOptions = ""; // https://msdn.microsoft.com/en-us/library/aa376931.aspx // https://support.microsoft.com/en-us/kb/290158 - ValidInstallExitCodes = new List {0, 1641, 3010}; + ValidInstallExitCodes = new List { 0, 1641, 3010 }; // we allow unknown 1605/1614 b/c it may have already been uninstalled // and that's okay - ValidUninstallExitCodes = new List {0, 1605, 1614, 1641, 3010}; + ValidUninstallExitCodes = new List { 0, 1605, 1614, 1641, 3010 }; } public override InstallerType InstallerType diff --git a/src/chocolatey/infrastructure.app/domain/installers/MsiPatchInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/MsiPatchInstaller.cs new file mode 100644 index 0000000000..7f4ba60d3b --- /dev/null +++ b/src/chocolatey/infrastructure.app/domain/installers/MsiPatchInstaller.cs @@ -0,0 +1,65 @@ +// 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. + +namespace chocolatey.infrastructure.app.domain.installers +{ + using System.Collections.Generic; + + public class MsiPatchInstaller : InstallerBase + { + public MsiPatchInstaller() + { + //todo: fully qualify msiexec + InstallExecutable = "msiexec.exe"; + SilentInstall = "/p \"{0}\" /qn".format_with(InstallTokens.INSTALLER_LOCATION); + // http://msdn.microsoft.com/en-us/library/aa371101.aspx + NoReboot = "/norestart"; + LogFile = "/l*v \"{0}\\MSP.Install.log\"".format_with(InstallTokens.PACKAGE_LOCATION); + // https://msdn.microsoft.com/en-us/library/aa372064.aspx + // http://apprepack.blogspot.com/2012/08/installdir-vs-targetdir.html + CustomInstallLocation = ""; + // http://msdn.microsoft.com/en-us/library/aa370856.aspx + Language = ""; + // http://msdn.microsoft.com/en-us/library/aa367559.aspx + OtherInstallOptions = "REINSTALLMODE=sumo REINSTALL=ALL"; + UninstallExecutable = "msiexec.exe"; + SilentUninstall = "/package {0} /qn".format_with(InstallTokens.UNINSTALLER_LOCATION); + OtherUninstallOptions = "MSIPATCHREMOVE={PATCH_GUID_HERE}"; + // https://msdn.microsoft.com/en-us/library/aa376931.aspx + // https://support.microsoft.com/en-us/kb/290158 + ValidInstallExitCodes = new List + { + 0, + 1641, + 3010 + }; + // we allow unknown 1605/1614 b/c it may have already been uninstalled + // and that's okay + ValidUninstallExitCodes = new List + { + 0, + 1605, + 1614, + 1641, + 3010 + }; + } + + public override InstallerType InstallerType + { + get { return InstallerType.MsiPatch; } + } + } +} diff --git a/src/chocolatey/infrastructure.app/domain/installers/NsisInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/NsisInstaller.cs index 419be1480e..080e112032 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/NsisInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/NsisInstaller.cs @@ -40,8 +40,8 @@ public NsisInstaller() UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); SilentUninstall = "/S"; OtherUninstallOptions = ""; - ValidInstallExitCodes = new List { 0 }; - ValidUninstallExitCodes = new List { 0 }; + ValidInstallExitCodes = new List { 0 }; + ValidUninstallExitCodes = new List { 0 }; } public override InstallerType InstallerType diff --git a/src/chocolatey/infrastructure.app/domain/installers/PackageForTheWebInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/PackageForTheWebInstaller.cs index 40ad7bfe17..b77074ccf1 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/PackageForTheWebInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/PackageForTheWebInstaller.cs @@ -36,11 +36,11 @@ public PackageForTheWebInstaller() UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); SilentUninstall = "/s"; OtherUninstallOptions = ""; - ValidInstallExitCodes = new List + ValidInstallExitCodes = new List { 0 }; - ValidUninstallExitCodes = new List + ValidUninstallExitCodes = new List { 0 }; diff --git a/src/chocolatey/infrastructure.app/domain/installers/QtInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/QtInstaller.cs index faa496b40b..2682f494ec 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/QtInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/QtInstaller.cs @@ -40,11 +40,11 @@ public QtInstaller() UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); SilentUninstall = ""; OtherUninstallOptions = ""; - ValidInstallExitCodes = new List + ValidInstallExitCodes = new List { 0 }; - ValidUninstallExitCodes = new List + ValidUninstallExitCodes = new List { 0 }; diff --git a/src/chocolatey/infrastructure.app/domain/installers/SetupFactoryInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/SetupFactoryInstaller.cs index 4f1b4eec2a..bdb0211fc1 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/SetupFactoryInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/SetupFactoryInstaller.cs @@ -45,11 +45,11 @@ public SetupFactoryInstaller() UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); SilentUninstall = "/S"; OtherUninstallOptions = ""; - ValidInstallExitCodes = new List + ValidInstallExitCodes = new List { 0 }; - ValidUninstallExitCodes = new List + ValidUninstallExitCodes = new List { 0 }; diff --git a/src/chocolatey/infrastructure.app/domain/installers/SquirrelInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/SquirrelInstaller.cs index b360425f8e..043846b142 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/SquirrelInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/SquirrelInstaller.cs @@ -37,11 +37,11 @@ public SquirrelInstaller() UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); SilentUninstall = "-s"; OtherUninstallOptions = ""; - ValidInstallExitCodes = new List + ValidInstallExitCodes = new List { 0 }; - ValidUninstallExitCodes = new List + ValidUninstallExitCodes = new List { 0 }; diff --git a/src/chocolatey/infrastructure.app/domain/installers/WindowsUpdateInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/WindowsUpdateInstaller.cs new file mode 100644 index 0000000000..ee3feb127d --- /dev/null +++ b/src/chocolatey/infrastructure.app/domain/installers/WindowsUpdateInstaller.cs @@ -0,0 +1,73 @@ +// 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. + +namespace chocolatey.infrastructure.app.domain.installers +{ + using System.Collections.Generic; + + /// + /// Windows Update Installer (msu) + /// + /// + /// https://support.microsoft.com/en-us/kb/934307 + /// + public class WindowsUpdateInstaller : InstallerBase + { + public WindowsUpdateInstaller() + { + //todo: fully qualify wusa + InstallExecutable = "wusa.exe"; + SilentInstall = "\"{0}\" /quiet".format_with(InstallTokens.INSTALLER_LOCATION); + NoReboot = "/norestart"; + LogFile = "/log:\"{0}\\MSP_install_log.evtx\"".format_with(InstallTokens.PACKAGE_LOCATION); + CustomInstallLocation = ""; + Language = ""; + OtherInstallOptions = ""; + UninstallExecutable = "wusa.exe"; + SilentUninstall = "\"{0}\" /quiet".format_with(InstallTokens.UNINSTALLER_LOCATION); + OtherUninstallOptions = ""; + // https://msdn.microsoft.com/en-us/library/aa376931.aspx + // https://support.microsoft.com/en-us/kb/290158 + // https://msdn.microsoft.com/en-us/library/windows/desktop/hh968413%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 + ValidInstallExitCodes = new List + { + 0, + 1641, + 3010, + 2359301, + 2359302, + 2149842956 + }; + // we allow unknown 1605/1614 b/c it may have already been uninstalled + // and that's okay + ValidUninstallExitCodes = new List + { + 0, + 1605, + 1614, + 1641, + 3010, + 2359301, + 2359303, + 2149842956 + }; + } + + public override InstallerType InstallerType + { + get { return InstallerType.HotfixOrSecurityUpdate; } + } + } +} diff --git a/src/chocolatey/infrastructure.app/domain/installers/WiseInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/WiseInstaller.cs index 1aca1953dd..0504a8234b 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/WiseInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/WiseInstaller.cs @@ -43,11 +43,11 @@ public WiseInstaller() SilentUninstall = "/s"; // http://www.symantec.com/connect/blogs/wisescript-command-line-options OtherUninstallOptions = "\"{0}\\Uninstall.Log\"".format_with(InstallTokens.TEMP_LOCATION); - ValidInstallExitCodes = new List + ValidInstallExitCodes = new List { 0 }; - ValidUninstallExitCodes = new List + ValidUninstallExitCodes = new List { 0 }; diff --git a/src/chocolatey/infrastructure.app/runners/ConsoleApplication.cs b/src/chocolatey/infrastructure.app/runners/ConsoleApplication.cs index 3066d5a5f0..5f4b7dd47a 100644 --- a/src/chocolatey/infrastructure.app/runners/ConsoleApplication.cs +++ b/src/chocolatey/infrastructure.app/runners/ConsoleApplication.cs @@ -28,9 +28,29 @@ public sealed class ConsoleApplication { public void run(string[] args, ChocolateyConfiguration config, Container container) { - this.Log().Debug(() => "Command line: {0}".format_with(Environment.CommandLine)); - this.Log().Debug(() => "Received arguments: {0}".format_with(string.Join(" ", args))); - + var commandLine = Environment.CommandLine; + if (commandLine.contains("-install-arguments-sensitive") + || commandLine.contains("-package-parameters-sensitive") + || commandLine.contains("apikey ") + || commandLine.contains("config ") + || commandLine.contains("push ") // push can be passed w/out parameters, it's fine to log it then + || commandLine.contains("-p ") || commandLine.contains("-p=") + || commandLine.contains("-password") + || commandLine.contains("-cp ") || commandLine.contains("-cp=") + || commandLine.contains("-certpassword") + || commandLine.contains("-k ") || commandLine.contains("-k=") + || commandLine.contains("-key ") || commandLine.contains("-key=") + || commandLine.contains("-apikey") || commandLine.contains("-api-key") + || commandLine.contains("-apikey") || commandLine.contains("-api-key") + ) { + this.Log().Debug(() => "Command line not shown - sensitive arguments may have been passed."); + } + else + { + this.Log().Debug(() => "Command line: {0}".format_with(commandLine)); + this.Log().Debug(() => "Received arguments: {0}".format_with(string.Join(" ", args))); + } + IList commandArgs = new List(); //shift the first arg off int count = 0; diff --git a/src/chocolatey/infrastructure.app/runners/GenericRunner.cs b/src/chocolatey/infrastructure.app/runners/GenericRunner.cs index 20c22c1f4e..453a648370 100644 --- a/src/chocolatey/infrastructure.app/runners/GenericRunner.cs +++ b/src/chocolatey/infrastructure.app/runners/GenericRunner.cs @@ -13,7 +13,6 @@ // See the License for the specific language governing permissions and // limitations under the License. - namespace chocolatey.infrastructure.app.runners { using System; diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 0a78813ec6..323d82cb63 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -398,6 +398,8 @@ private string capture_arguments(ChocolateyConfiguration config, PackageResult p if (!string.IsNullOrWhiteSpace(config.InstallArguments)) arguments.Append(" --install-arguments=\"'{0}'\"".format_with(config.InstallArguments)); if (config.OverrideArguments) arguments.Append(" --override-arguments"); if (!string.IsNullOrWhiteSpace(config.PackageParameters)) arguments.Append(" --package-parameters=\"'{0}'\"".format_with(config.PackageParameters)); + if (config.ApplyPackageParametersToDependencies) arguments.Append(" --apply-package-parameters-to-dependencies"); + if (config.ApplyInstallArgumentsToDependencies) arguments.Append(" --apply-install-arguments-to-dependencies"); if (config.AllowDowngrade) arguments.Append(" --allow-downgrade"); if (config.AllowMultipleVersions) arguments.Append(" --allow-multiple-versions"); if (config.IgnoreDependencies) arguments.Append(" --ignore-dependencies"); @@ -573,6 +575,8 @@ private IEnumerable get_packages_from_config(string pac if (pkgSettings.ForceX86) packageConfig.ForceX86 = true; if (pkgSettings.AllowMultipleVersions) packageConfig.AllowMultipleVersions = true; if (pkgSettings.IgnoreDependencies) packageConfig.IgnoreDependencies = true; + if (pkgSettings.ApplyInstallArgumentsToDependencies) packageConfig.ApplyInstallArgumentsToDependencies = true; + if (pkgSettings.ApplyPackageParametersToDependencies) packageConfig.ApplyPackageParametersToDependencies = true; this.Log().Info(ChocolateyLoggers.Important, @"{0}".format_with(packageConfig.PackageNames)); packageConfigs.Add(packageConfig); diff --git a/src/chocolatey/infrastructure.app/services/PowershellService.cs b/src/chocolatey/infrastructure.app/services/PowershellService.cs index ede41552f4..d42d8c357c 100644 --- a/src/chocolatey/infrastructure.app/services/PowershellService.cs +++ b/src/chocolatey/infrastructure.app/services/PowershellService.cs @@ -31,6 +31,7 @@ namespace chocolatey.infrastructure.app.services using cryptography; using domain; using infrastructure.commands; + using infrastructure.registration; using logging; using NuGet; using powershell; @@ -403,15 +404,13 @@ public void prepare_powershell_environment(IPackage package, ChocolateyConfigura // we only want to pass the following args to packages that would apply. // like choco install git -params '' should pass those params to git.install, - // but not another package - if (!package_is_a_dependency_not_a_virtual(configuration, package.Id)) + // but not another package unless the switch apply-install-arguments-to-dependencies is used + if (!package_is_a_dependency_not_a_virtual(configuration, package.Id) || configuration.ApplyInstallArgumentsToDependencies) { - this.Log().Debug(ChocolateyLoggers.Verbose, "Setting installer args and package parameters for {0}".format_with(package.Id)); + this.Log().Debug(ChocolateyLoggers.Verbose, "Setting installer args for {0}".format_with(package.Id)); Environment.SetEnvironmentVariable("installArguments", configuration.InstallArguments); Environment.SetEnvironmentVariable("installerArguments", configuration.InstallArguments); Environment.SetEnvironmentVariable("chocolateyInstallArguments", configuration.InstallArguments); - Environment.SetEnvironmentVariable("packageParameters", configuration.PackageParameters); - Environment.SetEnvironmentVariable("chocolateyPackageParameters", configuration.PackageParameters); if (configuration.OverrideArguments) { @@ -419,6 +418,15 @@ public void prepare_powershell_environment(IPackage package, ChocolateyConfigura } } + // we only want to pass package parameters to packages that would apply. + // but not another package unless the switch apply-package-parameters-to-dependencies is used + if (!package_is_a_dependency_not_a_virtual(configuration, package.Id) || configuration.ApplyPackageParametersToDependencies) + { + this.Log().Debug(ChocolateyLoggers.Verbose, "Setting package parameters for {0}".format_with(package.Id)); + Environment.SetEnvironmentVariable("packageParameters", configuration.PackageParameters); + Environment.SetEnvironmentVariable("chocolateyPackageParameters", configuration.PackageParameters); + } + if (!string.IsNullOrWhiteSpace(configuration.DownloadChecksum)) { Environment.SetEnvironmentVariable("chocolateyChecksum32", configuration.DownloadChecksum); @@ -468,6 +476,8 @@ public void prepare_powershell_environment(IPackage package, ChocolateyConfigura Environment.SetEnvironmentVariable("CacheChecksumType_{0}".format_with(urlKey), "sha512"); } } + + SecurityProtocol.set_protocol(); } private ResolveEventHandler _handler = null; diff --git a/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs b/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs index 6913313301..bdc059edd0 100644 --- a/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs +++ b/src/chocolatey/infrastructure/filesystem/DotNetFileSystem.cs @@ -66,7 +66,13 @@ private static IEnvironment Environment public string combine_paths(string leftItem, params string[] rightItems) { - if (leftItem == null) throw new ApplicationException("Path to combine cannot be empty."); + if (leftItem == null) + { + var methodName = string.Empty; + var stackFrame = new System.Diagnostics.StackFrame(1); + if (stackFrame != null) methodName = stackFrame.GetMethod().Name; + throw new ApplicationException("Path to combine cannot be empty. Tried to combine null with '{0}'.{1}".format_with(string.Join(",", rightItems),string.IsNullOrWhiteSpace(methodName) ? string.Empty : " Method called from '{0}'".format_with(methodName))); + } var combinedPath = Platform.get_platform() == PlatformType.Windows ? leftItem : leftItem.Replace('\\', '/'); foreach (var rightItem in rightItems) @@ -169,6 +175,11 @@ public string get_current_assembly_path() public IEnumerable get_files(string directoryPath, string pattern = "*.*", SearchOption option = SearchOption.TopDirectoryOnly) { if (string.IsNullOrWhiteSpace(directoryPath)) return new List(); + if (!directory_exists(directoryPath)) + { + this.Log().Warn("Directory '{0}' does not exist.".format_with(directoryPath)); + return new List(); + } return Directory.EnumerateFiles(directoryPath, pattern, option); } diff --git a/src/chocolatey/infrastructure/registration/SecurityProtocol.cs b/src/chocolatey/infrastructure/registration/SecurityProtocol.cs index af10ec1e92..b568f31859 100644 --- a/src/chocolatey/infrastructure/registration/SecurityProtocol.cs +++ b/src/chocolatey/infrastructure/registration/SecurityProtocol.cs @@ -50,6 +50,20 @@ Chaining. Upgrade to at least .NET 4.5 at your earliest convenience. For more information you should visit https://www.howsmyssl.com/"); } + + try + { + if (ServicePointManager.ServerCertificateValidationCallback != null) + { + "chocolatey".Log().Warn("ServerCertificateValidationCallback was set to '{0}' Removing.".format_with(System.Net.ServicePointManager.ServerCertificateValidationCallback)); + ServicePointManager.ServerCertificateValidationCallback = null; + } + } + catch (Exception ex) + { + "chocolatey".Log().Warn("Error resetting ServerCertificateValidationCallback: {0}".format_with(ex.Message)); + } + } } }