Skip to content

Commit

Permalink
(chocolateyGH-712) Report required reboots
Browse files Browse the repository at this point in the history
When installs exit in a way that indicates a reboot is necessary,
indicate so in the summary log. Include the package name and exit code.
  • Loading branch information
ferventcoder committed May 1, 2016
1 parent 650266b commit ff86587
Showing 1 changed file with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ public void handle_package_result(PackageResult packageResult, ChocolateyConfigu

var installFailures = packageInstalls.Count(p => !p.Value.Success);
var installWarnings = packageInstalls.Count(p => p.Value.Warning);
var rebootPackages = packageInstalls.Count(p => new []{ 1641, 3010 }.Contains(p.Value.ExitCode));
this.Log().Warn(() => @"{0}{1} installed {2}/{3} package(s). {4} package(s) failed.{5}{0} See the log for details ({6}).".format_with(
Environment.NewLine,
ApplicationParameters.Name,
Expand All @@ -376,6 +377,19 @@ public void handle_package_result(PackageResult packageResult, ChocolateyConfigu
}
}

if (rebootPackages != 0)
{
this.Log().Warn(ChocolateyLoggers.Important, "Packages needing reboot:");
foreach (var reboot in packageInstalls.Where(p => new[] { 1641, 3010 }.Contains(p.Value.ExitCode)).or_empty_list_if_null())
{
this.Log().Warn(" - {0}{1}".format_with(reboot.Value.Name, reboot.Value.ExitCode != 0 ? " (exit code {0})".format_with(reboot.Value.ExitCode) : string.Empty));
}
this.Log().Warn(@"
The recent package installs indicate a reboot is necessary.
Please reboot at your earliest convenience.
");
}

if (installFailures != 0)
{
this.Log().Error("Failures:");
Expand Down Expand Up @@ -559,6 +573,7 @@ public void upgrade_noop(ChocolateyConfiguration config)

var upgradeFailures = packageUpgrades.Count(p => !p.Value.Success);
var upgradeWarnings = packageUpgrades.Count(p => p.Value.Warning);
var rebootPackages = packageUpgrades.Count(p => new[] { 1641, 3010 }.Contains(p.Value.ExitCode));
this.Log().Warn(() => @"{0}{1} upgraded {2}/{3} package(s). {4} package(s) failed.{5}{0} See the log for details ({6}).".format_with(
Environment.NewLine,
ApplicationParameters.Name,
Expand All @@ -578,6 +593,19 @@ public void upgrade_noop(ChocolateyConfiguration config)
}
}

if (rebootPackages != 0)
{
this.Log().Warn(ChocolateyLoggers.Important, "Packages needing reboot:");
foreach (var reboot in packageUpgrades.Where(p => new[] { 1641, 3010 }.Contains(p.Value.ExitCode)).or_empty_list_if_null())
{
this.Log().Warn(" - {0}{1}".format_with(reboot.Value.Name, reboot.Value.ExitCode != 0 ? " (exit code {0})".format_with(reboot.Value.ExitCode) : string.Empty));
}
this.Log().Warn(@"
The recent package upgrades indicate a reboot is necessary.
Please reboot at your earliest convenience.
");
}

if (upgradeFailures != 0)
{
this.Log().Error("Failures:");
Expand Down Expand Up @@ -640,6 +668,7 @@ public void uninstall_noop(ChocolateyConfiguration config)
get_environment_after(config, environmentBefore, out environmentChanges, out environmentRemovals);

var uninstallFailures = packageUninstalls.Count(p => !p.Value.Success);
var rebootPackages = packageUninstalls.Count(p => new[] { 1641, 3010 }.Contains(p.Value.ExitCode));
this.Log().Warn(() => @"{0}{1} uninstalled {2}/{3} packages. {4} packages failed.{0} See the log for details ({5}).".format_with(
Environment.NewLine,
ApplicationParameters.Name,
Expand All @@ -649,6 +678,20 @@ public void uninstall_noop(ChocolateyConfiguration config)
_fileSystem.combine_paths(ApplicationParameters.LoggingLocation, ApplicationParameters.LoggingFile)
));


if (rebootPackages != 0)
{
this.Log().Warn(ChocolateyLoggers.Important, "Packages needing reboot:");
foreach (var reboot in packageUninstalls.Where(p => new[] { 1641, 3010 }.Contains(p.Value.ExitCode)).or_empty_list_if_null())
{
this.Log().Warn(" - {0}{1}".format_with(reboot.Value.Name, reboot.Value.ExitCode != 0 ? " (exit code {0})".format_with(reboot.Value.ExitCode) : string.Empty));
}
this.Log().Warn(@"
The recent package uninstalls indicate a reboot is necessary.
Please reboot at your earliest convenience.
");
}

if (uninstallFailures != 0)
{
this.Log().Error("Failures");
Expand Down

0 comments on commit ff86587

Please sign in to comment.