Skip to content

Commit

Permalink
(GH-981) Add option to use Get-FileHash for versions v4.x and above
Browse files Browse the repository at this point in the history
For compatibility reasons, Chocolatey suggests using `choco install
checksum` to verify checksums.

But, in Powershell v4 and beyond, users could choose to run
`Get-FileHash` as well.

This change adds a message in applicable powershell versions (v4.x and
later) to suggest this course of action.
  • Loading branch information
SeanKilleen committed Dec 16, 2018
1 parent c8512aa commit c2ec501
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ param(

Write-Warning "Missing package checksums are not allowed (by default for HTTP/FTP, `n HTTPS when feature 'allowEmptyChecksumsSecure' is disabled) for `n safety and security reasons. Although we strongly advise against it, `n if you need this functionality, please set the feature `n 'allowEmptyChecksums' ('choco feature enable -n `n allowEmptyChecksums') `n or pass in the option '--allow-empty-checksums'. You can also pass `n checksums at runtime (recommended). See `choco install -?` for details."
Write-Debug "If you are a maintainer attempting to determine the checksum for packaging purposes, please run `n 'choco install checksum' and run 'checksum -t sha256 -f $file' `n Ensure you do this for all remote resources."
if ($PSVersionTable.PSVersion.Major -ge 4){
Write-Debug "Because you are running Powershell with a major version of v4 or greater, you could also opt to run `n '(Get-FileHash -Path $file -Algorithm SHA256).Hash' `n rather than install a separate tool."
}

if ($env:ChocolateyPowerShellHost -eq 'true') {
$statement = "The integrity of the file '$([System.IO.Path]::GetFileName($file))'"
Expand Down

0 comments on commit c2ec501

Please sign in to comment.