Skip to content

Commit

Permalink
(GH-33) Allow Shutting off checksumming
Browse files Browse the repository at this point in the history
Allow a user to shut off checksumming either globally or as a
configuration value passed to choco.
  • Loading branch information
ferventcoder committed Sep 21, 2015
1 parent 43bf97a commit 204983c
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ param(
[string] $checksumType = 'md5'
)
Write-Debug "Running 'Get-ChecksumValid' with file:`'$file`', checksum: `'$checksum`', checksumType: `'$checksumType`'";
if ($env:chocolateyIgnoreChecksums -eq 'true') {
Write-Warning "Ignoring checksums due to feature checksumFiles = false or config ignoreChecksums = true."
return
}
if ($checksum -eq '' -or $checksum -eq $null) { return }

if (!([System.IO.File]::Exists($file))) { throw "Unable to checksum a file that doesn't exist - Could not find file `'$file`'" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,12 @@ public void configure_argument_parser(OptionSet optionSet, ChocolateyConfigurati
.Add("p=|password=",
"Password - the user's password to the source. Defaults to empty.",
option => configuration.SourceCommand.Password = option.remove_surrounding_quotes())
.Add("ignorechecksums|ignore-checksums",
"IgnoreChecksums - Ignore checksums provided by the package",
option =>
{
if (option != null) configuration.Features.CheckSumFiles = false;
})
;

//todo: Checksum / ChecksumType defaults to md5 / package name can be a url / installertype
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
.Add("p=|password=",
"Password - the user's password to the source. Defaults to empty.",
option => configuration.SourceCommand.Password = option.remove_surrounding_quotes())
.Add("ignorechecksums|ignore-checksums",
"IgnoreChecksums - Ignore checksums provided by the package",
option =>
{
if (option != null) configuration.Features.CheckSumFiles = false;
})
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ public bool run_action(ChocolateyConfiguration configuration, PackageResult pack
if (configuration.Verbose)
{
Environment.SetEnvironmentVariable("ChocolateyEnvironmentVerbose", "true");
}
if (!configuration.Features.CheckSumFiles)
{
Environment.SetEnvironmentVariable("ChocolateyIgnoreChecksums", "true");
}
//todo:if (configuration.NoOutput)
//{
Expand Down

0 comments on commit 204983c

Please sign in to comment.