Skip to content

Commit

Permalink
(GH-689) Report install location
Browse files Browse the repository at this point in the history
When unpacking or installing software, determine the install location
of that software. If the install was was unable to be found, report
that as well but report that it was an installer if it was.
  • Loading branch information
ferventcoder committed May 30, 2016
1 parent 7242532 commit 80cf926
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -161,5 +161,6 @@ param(
default { throw "7-Zip signalled an unknown error (code $exitCode)" }
}

$env:ChocolateyPackageInstallLocation = $destination
return $destination
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ param(
Write-Warning "Unable to generate `'$ignoreFile`'"
}

$env:ChocolateyInstallerType = $fileType

$additionalInstallArgs = $env:chocolateyInstallArguments;
if ($additionalInstallArgs -eq $null) {
$additionalInstallArgs = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,9 @@ private static void set_environment_options(ChocolateyConfiguration config)

public static void set_environment_variables(ChocolateyConfiguration config)
{
Environment.SetEnvironmentVariable("ChocolateyPackageInstallLocation", null);
Environment.SetEnvironmentVariable("ChocolateyInstallerType", null);

Environment.SetEnvironmentVariable(ApplicationParameters.ChocolateyInstallEnvironmentVariableName, ApplicationParameters.InstallLocation);
Environment.SetEnvironmentVariable("CHOCOLATEY_VERSION", config.Information.ChocolateyVersion);
Environment.SetEnvironmentVariable("CHOCOLATEY_VERSION_PRODUCT", config.Information.ChocolateyProductVersion);
Expand Down Expand Up @@ -474,7 +477,7 @@ public static void set_environment_variables(ChocolateyConfiguration config)
Environment.SetEnvironmentVariable("https_proxy", "{0}{1}".format_with(proxyCreds, config.Proxy.Location));
Environment.SetEnvironmentVariable("chocolateyProxyLocation", config.Proxy.Location);
}

if (config.Features.UsePowerShellHost) Environment.SetEnvironmentVariable("ChocolateyPowerShellHost", "true");
if (config.Force) Environment.SetEnvironmentVariable("ChocolateyForce", "true");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,19 @@ public void handle_package_result(PackageResult packageResult, ChocolateyConfigu
handle_template_packages(config, packageResult);
}

var toolsLocation = _fileSystem.combine_paths(Environment.GetEnvironmentVariable("ChocolateyToolsLocation"), packageResult.Name);

This comment has been minimized.

Copy link
@ferventcoder

ferventcoder May 31, 2016

Author Member

this looks like a bug.

if (_fileSystem.directory_exists(toolsLocation))
{
Environment.SetEnvironmentVariable("ChocolateyPackageInstallLocation", toolsLocation, EnvironmentVariableTarget.Process);
}


if (pkgInfo.RegistrySnapshot != null && pkgInfo.RegistrySnapshot.RegistryKeys.Any(k => !string.IsNullOrWhiteSpace(k.InstallLocation)))
{
var key = pkgInfo.RegistrySnapshot.RegistryKeys.FirstOrDefault(k => !string.IsNullOrWhiteSpace(k.InstallLocation));
if (key != null) Environment.SetEnvironmentVariable("ChocolateyPackageInstallLocation", key.InstallLocation, EnvironmentVariableTarget.Process);
}

_packageInfoService.save_package_information(pkgInfo);
ensure_bad_package_path_is_clean(config, packageResult);
EventManager.publish(new HandlePackageResultCompletedMessage(packageResult, config, commandName));
Expand All @@ -346,6 +359,22 @@ public void handle_package_result(PackageResult packageResult, ChocolateyConfigu
if (packageResult.Success) remove_pending(packageResult, config);

this.Log().Info(ChocolateyLoggers.Important, " The {0} of {1} was successful.".format_with(commandName.to_string(), packageResult.Name));

var installLocation = Environment.GetEnvironmentVariable("ChocolateyPackageInstallLocation");
var installerDetected = Environment.GetEnvironmentVariable("ChocolateyInstallerType");
if (!string.IsNullOrWhiteSpace(installLocation))
{
this.Log().Info(ChocolateyLoggers.Important, " Software installed to '{0}'".format_with(installLocation));
}
else if (!string.IsNullOrWhiteSpace(installerDetected))
{
this.Log().Info(ChocolateyLoggers.Important, @" Software installed as '{0}', install location is likely default.".format_with(installerDetected));
}
else
{
this.Log().Info(ChocolateyLoggers.Important, @" Software install location not explicitly set, could be in package or
default install location if installer.");
}
}

public ConcurrentDictionary<string, PackageResult> install_run(ChocolateyConfiguration config)
Expand Down Expand Up @@ -851,6 +880,8 @@ private void handle_extension_packages(ChocolateyConfiguration config, PackageRe
string logMessage = " Installed/updated {0} extensions.".format_with(extensionsFolderName);
this.Log().Warn(logMessage);
packageResult.Messages.Add(new ResultMessage(ResultType.Note, logMessage));

Environment.SetEnvironmentVariable("ChocolateyPackageInstallLocation", packageExtensionsInstallDirectory, EnvironmentVariableTarget.Process);
}
else
{
Expand Down Expand Up @@ -935,6 +966,8 @@ private void handle_template_packages(ChocolateyConfiguration config, PackageRes
string logMessage = " Installed/updated {0} template.".format_with(templateFolderName);
this.Log().Warn(logMessage);
packageResult.Messages.Add(new ResultMessage(ResultType.Note, logMessage));

Environment.SetEnvironmentVariable("ChocolateyPackageInstallLocation", installTemplatePath, EnvironmentVariableTarget.Process);
}
else
{
Expand Down

0 comments on commit 80cf926

Please sign in to comment.