Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (chocolateyGH-113) Add SHA-2 support for checksum

# Conflicts:
#	src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1
  • Loading branch information
ferventcoder committed Sep 29, 2015
2 parents bffd853 + 2509f78 commit f5d5ae5
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,11 @@ param(

if (!([System.IO.File]::Exists($file))) { throw "Unable to checksum a file that doesn't exist - Could not find file `'$file`'" }

if ($checksumType -ne 'sha1') { $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 isn't specified correctly.'
$checksumType = 'md5'
}
$checksumExe = Join-Path "$helpersPath" '..\tools\checksum.exe'
if (!([System.IO.File]::Exists($checksumExe))) {
Update-SessionEnvironment
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# 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
# Copyright 2011 - Present RealDimensions Software, LLC & original authors/contributors from https://github.com/chocolatey/chocolatey
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

function Get-ChocolateyWebFile {
Expand Down Expand Up @@ -41,28 +41,28 @@ OPTIONAL (Right now) - This allows a checksum to be validated for files that are
OPTIONAL (Right now) - This allows a checksum to be validated for files that are not local
.PARAMETER ChecksumType
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to 'md5'
OPTIONAL (Right now) - 'md5', 'sha1', 'sha256' or 'sha512' - defaults to 'md5'
.PARAMETER ChecksumType64
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to ChecksumType
.PARAMETER options
OPTIONAL - Specify custom headers
Example:
--------
$options =
@{
Headers = @{
Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
'Accept-Charset' = 'ISO-8859-1,utf-8;q=0.7,*;q=0.3';
'Accept-Language' = 'en-GB,en-US;q=0.8,en;q=0.6';
Cookie = 'products.download.email=ewilde@gmail.com';
Referer = 'http://submain.com/download/ghostdoc/';
}
}
Get-ChocolateyWebFile 'ghostdoc' 'http://submain.com/download/GhostDoc_v4.0.zip' -options $options
OPTIONAL (Right now) - 'md5', 'sha1', 'sha256' or 'sha512' - defaults to ChecksumType
.PARAMETER options
OPTIONAL - Specify custom headers
Example:
--------
$options =
@{
Headers = @{
Accept = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8';
'Accept-Charset' = 'ISO-8859-1,utf-8;q=0.7,*;q=0.3';
'Accept-Language' = 'en-GB,en-US;q=0.8,en;q=0.6';
Cookie = 'products.download.email=ewilde@gmail.com';
Referer = 'http://submain.com/download/ghostdoc/';
}
}
Get-ChocolateyWebFile 'ghostdoc' 'http://submain.com/download/GhostDoc_v4.0.zip' -options $options
.EXAMPLE
Get-ChocolateyWebFile '__NAME__' 'C:\somepath\somename.exe' 'URL' '64BIT_URL_DELETE_IF_NO_64BIT'
Expand All @@ -82,7 +82,7 @@ param(
[string] $checksum = '',
[string] $checksumType = '',
[string] $checksum64 = '',
[string] $checksumType64 = $checksumType,
[string] $checksumType64 = $checksumType,
[hashtable] $options = @{Headers=@{}}
)
Write-Debug "Running 'Get-ChocolateyWebFile' for $packageName with url:`'$url`', fileFullPath:`'$fileFullPath`', url64bit:`'$url64bit`', checksum: `'$checksum`', checksumType: `'$checksumType`', checksum64: `'$checksum64`', checksumType64: `'$checksumType64`'";
Expand Down Expand Up @@ -111,9 +111,9 @@ param(
}

try {
$fileDirectory = $([System.IO.Path]::GetDirectoryName($fileFullPath))
if (!(Test-Path($fileDirectory))) {
[System.IO.Directory]::CreateDirectory($fileDirectory) | Out-Null
$fileDirectory = $([System.IO.Path]::GetDirectoryName($fileFullPath))
if (!(Test-Path($fileDirectory))) {
[System.IO.Directory]::CreateDirectory($fileDirectory) | Out-Null
}
} catch {
Write-Host "Attempt to create directory failed for '$fileFullPath'."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ OPTIONAL (Right now) - This allows a checksum to be validated for files that are
OPTIONAL (Right now) - This allows a checksum to be validated for files that are not local
.PARAMETER ChecksumType
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to 'md5'
OPTIONAL (Right now) - 'md5', 'sha1', 'sha256' or 'sha512' - defaults to 'md5'
.PARAMETER ChecksumType64
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to ChecksumType
OPTIONAL (Right now) - 'md5', 'sha1', 'sha256' or 'sha512' - defaults to ChecksumType
.PARAMETER options
OPTIONAL - Specify custom headers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ will be targetted.
OPTIONAL (Right now) - This allows a checksum to be validated for files that are not local
.PARAMETER ChecksumType
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to 'md5'
OPTIONAL (Right now) - 'md5', 'sha1', 'sha256' or 'sha512' - defaults to 'md5'
.EXAMPLE
Install-ChocolateyVsixPackage "MyPackage" http://visualstudiogallery.msdn.microsoft.com/ea3a37c9-1c76-4628-803e-b10a109e7943/file/73131/1/AutoWrockTestable.vsix
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ OPTIONAL (Right now) - This allows a checksum to be validated for files that are
OPTIONAL (Right now) - This allows a checksum to be validated for files that are not local
.PARAMETER ChecksumType
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to 'md5'
OPTIONAL (Right now) - 'md5', 'sha1', 'sha256' or 'sha512' - defaults to 'md5'
.PARAMETER ChecksumType64
OPTIONAL (Right now) - 'md5' or 'sha1' - defaults to ChecksumType
OPTIONAL (Right now) - 'md5', 'sha1', 'sha256' or 'sha512' - defaults to ChecksumType
.PARAMETER options
OPTIONAL - Specify custom headers
Expand Down
Binary file modified src/chocolatey.resources/tools/checksum.exe
Binary file not shown.

0 comments on commit f5d5ae5

Please sign in to comment.