Skip to content

Commit

Permalink
(chocolatey#2510) Don't run unsupported uninstall services on non-win…
Browse files Browse the repository at this point in the history
…dows

This put a check on the powershell uninstall script, shimgen uninstall,
autoUninstaller and shutdown /a calls during uninstall. They will now
only run on windows. None of these services work on non-windows, so
they should not be run
  • Loading branch information
TheCakeIsNaOH committed Jan 6, 2022
1 parent bf17466 commit 3050a56
Showing 1 changed file with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -986,21 +986,29 @@ public virtual void handle_package_uninstall(PackageResult packageResult, Chocol
packageResult.InstallLocation += ".{0}".format_with(packageResult.Package.Version.to_string());
}

_shimgenService.uninstall(config, packageResult);

if (!config.SkipPackageInstallProvider)
//These items only apply to windows systems.
if (config.Information.PlatformType == PlatformType.Windows)
{
_powershellService.uninstall(config, packageResult);
}
_shimgenService.uninstall(config, packageResult);

if (packageResult.Success)
if (!config.SkipPackageInstallProvider)
{
_powershellService.uninstall(config, packageResult);
}

if (packageResult.Success)
{
_autoUninstallerService.run(packageResult, config);
}

// we don't care about the exit code
CommandExecutor.execute_static(_shutdownExe, "/a", config.CommandExecutionTimeoutSeconds, _fileSystem.get_current_directory(), (s, e) => { }, (s, e) => { }, false, false);
}
else
{
_autoUninstallerService.run(packageResult, config);
this.Log().Info(ChocolateyLoggers.Important, () => " Skipping Powershell, shimgen, and autoUninstaller portions of the uninstall due to non-Windows.");
}

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

if (packageResult.Success)
{
//todo: v2 clean up package information store for things no longer installed (call it compact?)
Expand Down

0 comments on commit 3050a56

Please sign in to comment.