Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (GH-885) Determine Installer by Overridable Method
  (maint) formatting
  (doc) update messaging on runtime virus check
  (GH-870) Update deprecated links
  (GH-883) Wait Up to 15 Seconds for Process Exit
  • Loading branch information
ferventcoder committed Aug 1, 2016
2 parents ab78454 + c181fd2 commit a980261
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 28 deletions.
2 changes: 1 addition & 1 deletion COMMITTERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Please be VERY familiar with [CONTRIBUTING](https://github.com/chocolatey/choco/
* Did the user create a branch with these changes? If it is on their master, please ask them to review [CONTRIBUTING](https://github.com/chocolatey/choco/blob/master/CONTRIBUTING.md).
* Did the user reformat files and they should not have? Was is just white-space? You can try adding [?w=1](https://github.com/blog/967-github-secrets) to the URL on GitHub.
* Are there tests? We really want any new contributions to contain tests so unless the committer believes this code really needs to be in the code base and is willing to write the tests, then we need to ask the contributor to make a good faith effort in adding test cases. Ask them to review the [contributing document](https://github.com/chocolatey/choco/blob/master/CONTRIBUTING.md) and provide tests. **Note:** Some commits may be refactoring which wouldn't necessarily add additional test sets.
* Is the code documented properly? Does this additional set of changes require changes to the [wiki](https://github.com/chocolatey/chocolatey/wiki)?
* Is the code documented properly? Does this additional set of changes require changes to the [wiki](https://github.com/chocolatey/choco/wiki)?
* Was this code warranted? Did the contributor follow the process of gaining approval for big change sets? If not please have them review the [contributing document](https://github.com/chocolatey/choco/blob/master/CONTRIBUTING.md) and ask that they follow up with a case for putting the code into the code base on the mailing list.

#### Review the Code
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,16 @@ param(
Unregister-Event -SourceIdentifier "LogErrors_ChocolateyZipProc"

# sometimes the process hasn't fully exited yet.
Start-Sleep 1
for ($loopCount=1; $loopCount -le 15; $loopCount++) {
if ($process.HasExited) { break; }
Write-Debug "Waiting for 7z.exe process to exit - $loopCount/15 seconds";
Start-Sleep 1;
}

$exitCode = $process.ExitCode
Set-PowerShellExitCode $exitCode
$process.Dispose()

Set-PowerShellExitCode $exitCode
Write-Debug "Command ['$7zip' $params] exited with `'$exitCode`'."

if ($zipExtractLogFullPath) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ param(
[parameter(Mandatory=$false, Position=1)][string] $file = '',
[parameter(ValueFromRemainingArguments = $true)][Object[]] $ignoredArguments
)
Write-Debug "No virus checking built into FOSS Chocolatey. Check out Pro or Business if you need this. https://chocolatey.org/compare"
Write-Debug "No runtime virus checking built into FOSS Chocolatey. Check out Pro/Business - https://chocolatey.org/compare"
}
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ Elevating Permissions and running [`"$exeToRun`" $wrappedStatements]. This may t
Unregister-Event -SourceIdentifier "LogErrors_ChocolateyProc"

# sometimes the process hasn't fully exited yet.
Start-Sleep 1
for ($loopCount=1; $loopCount -le 15; $loopCount++) {
if ($process.HasExited) { break; }
Write-Debug "Waiting for process to exit - $loopCount/15 seconds";
Start-Sleep 1;
}

$exitCode = $process.ExitCode
$process.Dispose()
Expand All @@ -218,7 +222,7 @@ Elevating Permissions and running [`"$exeToRun`" $wrappedStatements]. This may t
} else {
$chocoSuccessCodes = @(0, 1605, 1614, 1641, 3010)
if ($chocoSuccessCodes -notcontains $exitCode) {
Write-Warning "Exit code '$exitCode' was considered valid, but not as a choco success code. Returning 0"
Write-Warning "Exit code '$exitCode' was considered valid by script, but not as a Chocolatey success code. Returning '0'."
$exitCode = 0
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,7 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config)
uninstallExe = uninstallExe.remove_surrounding_quotes();
this.Log().Debug(() => " Uninstaller path is '{0}'".format_with(uninstallExe));


IInstaller installer = new CustomInstaller();

switch (key.InstallerType)
{
case InstallerType.Msi:
installer = new MsiInstaller();
break;
case InstallerType.InnoSetup:
installer = new InnoSetupInstaller();
break;
case InstallerType.Nsis:
installer = new NsisInstaller();
break;
case InstallerType.InstallShield:
installer = new InstallShieldInstaller();
break;
}

IInstaller installer = get_installer_type(key, uninstallExe, uninstallArgs);
this.Log().Debug(() => " Installer type is '{0}'".format_with(installer.GetType().Name));

if (key.InstallerType == InstallerType.Msi)
Expand All @@ -124,7 +106,7 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config)
uninstallArgs = uninstallArgs.Replace("/I ", "/X ");
uninstallArgs = uninstallArgs.Replace("/i ", "/X ");
}

if (!key.HasQuietUninstall)
{
//todo: ultimately we should merge keys
Expand All @@ -139,7 +121,7 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config)

this.Log().Debug(() => " Args are '{0}'".format_with(uninstallArgs.escape_curly_braces()));

if (!key.HasQuietUninstall && installer.GetType() == typeof(CustomInstaller))
if (!key.HasQuietUninstall && installer.GetType() == typeof(CustomInstaller))
{
var skipUninstaller = true;

Expand Down Expand Up @@ -194,5 +176,28 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config)
}
}
}

public virtual IInstaller get_installer_type(RegistryApplicationKey key, string uninstallExe, string uninstallArgs)
{
IInstaller installer = new CustomInstaller();

switch (key.InstallerType)
{
case InstallerType.Msi:
installer = new MsiInstaller();
break;
case InstallerType.InnoSetup:
installer = new InnoSetupInstaller();
break;
case InstallerType.Nsis:
installer = new NsisInstaller();
break;
case InstallerType.InstallShield:
installer = new InstallShieldInstaller();
break;
}

return installer;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class NuspecTemplate
{
public static string Template =
@"<?xml version=""1.0"" encoding=""utf-8""?>
<!-- Read this before creating packages: https://github.com/chocolatey/chocolatey/wiki/CreatePackages -->
<!-- Read this before creating packages: https://chocolatey.org/docs/create-packages -->
<!-- It is especially important to read the above link to understand additional requirements when publishing packages to the community feed aka dot org (https://chocolatey.org/packages). -->
<!-- Test your packages in a test environment: https://github.com/chocolatey/chocolatey-test-environment -->
Expand Down

0 comments on commit a980261

Please sign in to comment.