Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (chocolateyGH-315) Nuget stops when uninstall fails
  (chocolateyGH-316) Prevent reboots
  (chocolateyGH-305) Do not fail by default on auto uninstaller
  (chocolateyGH-304) Reduce sleep time to 2 seconds
  (chocolateyGH-305) Include exit code when there is an error
  (chocolateyGH-305) Log info instead of Debug
  (chocolateyGH-305) Don't attempt to log on uninstall

Conflicts:
	src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs
	src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs
  • Loading branch information
ferventcoder committed Jun 5, 2015
2 parents ad19d09 + cb4ad54 commit 4a25c56
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/chocolatey/infrastructure.app/ApplicationParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public static class Features
{
public static readonly string CheckSumFiles = "checksumFiles";
public static readonly string AutoUninstaller = "autoUninstaller";
public static readonly string FailOnAutoUninstaller = "failOnAutoUninstaller";
public static readonly string AllowGlobalConfirmation = "allowGlobalConfirmation";
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ private static void set_feature_flags(ChocolateyConfiguration config, ConfigFile
{
config.Features.CheckSumFiles = set_feature_flag(ApplicationParameters.Features.CheckSumFiles, configFileSettings, defaultEnabled: true);
config.Features.AutoUninstaller = set_feature_flag(ApplicationParameters.Features.AutoUninstaller, configFileSettings, defaultEnabled: true);
config.Features.FailOnAutoUninstaller = set_feature_flag(ApplicationParameters.Features.FailOnAutoUninstaller, configFileSettings, defaultEnabled: false);
config.PromptForConfirmation = !set_feature_flag(ApplicationParameters.Features.AllowGlobalConfirmation, configFileSettings, defaultEnabled: false);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,7 @@ public sealed class FeaturesConfiguration
{
public bool AutoUninstaller { get; set; }
public bool CheckSumFiles { get; set; }
public bool FailOnAutoUninstaller { get; set; }
}

//todo: retrofit other command configs this way
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,6 @@
<feature name="checksumFiles" enabled="true" />
<feature name="autoUninstaller" enabled="false" />
<feature name="allowGlobalConfirmation" enabled="false" />
<feature name="failOnAutoUninstaller" enabled="false" />
</features>
</chocolatey>
7 changes: 5 additions & 2 deletions src/chocolatey/infrastructure.app/domain/InstallerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ public abstract class InstallerBase : IInstaller
public virtual string build_install_command_arguments(bool customInstallLocation, bool languageRequested)
{
var args = new StringBuilder();
args.AppendFormat("{0} {1} {2}", SilentInstall, NoReboot, LogFile);
args.AppendFormat("{0} {1}", SilentInstall, NoReboot);
//MSI may have issues with 1622 - opening a log file location
args.AppendFormat(" {0}", LogFile);
if (languageRequested) args.AppendFormat(" {0}", Language);
args.AppendFormat(" {0}", OtherInstallOptions);

Expand All @@ -50,7 +52,8 @@ public virtual string build_install_command_arguments(bool customInstallLocation

public virtual string build_uninstall_command_arguments()
{
return "{0} {1} {2} {3}".format_with(SilentUninstall, NoReboot, LogFile, OtherUninstallOptions);
//MSI has issues with 1622 - opening a log file location
return "{0} {1} {2}".format_with(SilentUninstall, NoReboot, OtherUninstallOptions);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public class AutomaticUninstallerService : IAutomaticUninstallerService
private readonly IFileSystem _fileSystem;
private readonly IRegistryService _registryService;
private readonly ICommandExecutor _commandExecutor;
private const int SLEEP_TIME = 5;
private const int SLEEP_TIME = 2;

public AutomaticUninstallerService(IChocolateyPackageInformationService packageInfoService, IFileSystem fileSystem, IRegistryService registryService, ICommandExecutor commandExecutor)
{
Expand Down Expand Up @@ -159,7 +159,7 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config)
(s, e) =>
{
if (e == null || string.IsNullOrWhiteSpace(e.Data)) return;
this.Log().Debug(() => " [AutoUninstaller] {0}".format_with(e.Data));
this.Log().Info(() => " [AutoUninstaller] {0}".format_with(e.Data));
},
(s, e) =>
{
Expand All @@ -171,9 +171,9 @@ public void run(PackageResult packageResult, ChocolateyConfiguration config)
if (!installer.ValidUninstallExitCodes.Contains(exitCode))
{
Environment.ExitCode = exitCode;
string logMessage = " Auto uninstaller failed. Please remove machine installation manually.";
string logMessage = " Auto uninstaller failed. Please remove machine installation manually.{0} Exit code was {1}".format_with(Environment.NewLine, exitCode);
this.Log().Error(() => logMessage);
packageResult.Messages.Add(new ResultMessage(ResultType.Error, logMessage));
packageResult.Messages.Add(new ResultMessage(config.Features.FailOnAutoUninstaller ? ResultType.Error : ResultType.Warn, logMessage));
}
else
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ namespace chocolatey.infrastructure.app.services
using configuration;
using domain;
using filesystem;
using infrastructure.commands;
using infrastructure.services;
using logging;
using platforms;
Expand Down Expand Up @@ -223,7 +224,8 @@ public void handle_package_result(PackageResult packageResult, ChocolateyConfigu
var powerShellRan = _powershellService.install(config, packageResult);
if (powerShellRan)
{
//todo: prevent reboots
// we don't care about the exit code
if (config.Information.PlatformType == PlatformType.Windows) CommandExecutor.execute_static("shutdown", "/a", config.CommandExecutionTimeoutSeconds, _fileSystem.get_current_directory(), (s, e) => { }, (s, e) => { }, false);
}

var difference = _registryService.get_differences(before, _registryService.get_installer_keys());
Expand Down Expand Up @@ -595,6 +597,9 @@ public void handle_package_uninstall(PackageResult packageResult, ChocolateyConf
}

_autoUninstallerService.run(packageResult, config);

// we don't care about the exit code
if (config.Information.PlatformType == PlatformType.Windows) CommandExecutor.execute_static("shutdown", "/a", config.CommandExecutionTimeoutSeconds, _fileSystem.get_current_directory(), (s, e) => { }, (s, e) => { }, false);

if (packageResult.Success)
{
Expand All @@ -607,7 +612,11 @@ public void handle_package_uninstall(PackageResult packageResult, ChocolateyConf
handle_unsuccessful_operation(config, packageResult, movePackageToFailureLocation: false, attemptRollback: false);
}

//todo:prevent reboots
if (!packageResult.Success)
{
// throw an error so that NuGet Service doesn't attempt to continue with package removal
throw new ApplicationException("{0} {1} not successful.".format_with(packageResult.Name, "uninstall"));
}
}

private void uninstall_cleanup(ChocolateyConfiguration config, PackageResult packageResult)
Expand Down

0 comments on commit 4a25c56

Please sign in to comment.