Skip to content

Commit

Permalink
(chocolateyGH-1365) Added supported for arch in tools folder
Browse files Browse the repository at this point in the history
- This allows the creation of an x86 or x64 folder in tools
- Shims will be created, depending on identified arch
- No need for install/uninstall script
  • Loading branch information
gep13 committed Feb 27, 2018
1 parent a7c1ff8 commit 881a76d
Showing 1 changed file with 48 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,45 +55,45 @@ public class ChocolateyPackageService : IChocolateyPackageService

private readonly IList<string> _proBusinessMessages = new List<string> {
@"
Are you ready for the ultimate experience? Check out Pro / Business!
Are you ready for the ultimate experience? Check out Pro / Business!
https://chocolatey.org/compare"
,
@"
Enjoy using Chocolatey? Explore more amazing features to take your
Enjoy using Chocolatey? Explore more amazing features to take your
experience to the next level at
https://chocolatey.org/compare"
,
@"
Did you know the proceeds of Pro (and some proceeds from other
Did you know the proceeds of Pro (and some proceeds from other
licensed editions) go into bettering the community infrastructure?
Your support ensures an active community, keeps Chocolatey tip top,
plus it nets you some awesome features!
plus it nets you some awesome features!
https://chocolatey.org/compare",
@"
Did you know some organizations use Chocolatey completely internally
without using the community repository or downloads from the internet?
Wait until you see how Package Builder and Package Internalizer can
help you achieve more, quicker and easier! Get your trial started
help you achieve more, quicker and easier! Get your trial started
today at https://chocolatey.org/compare",
@"
An organization needed total software management life cycle automation.
They evaluated Chocolatey for Business. You won't believe what happens
next!
https://chocolatey.org/compare",
@"
Did you know that Package Synchronizer and AutoUninstaller enhancements
in licensed versions are up to 95% effective in removing system
Did you know that Package Synchronizer and AutoUninstaller enhancements
in licensed versions are up to 95% effective in removing system
installed software without an uninstall script? Find out more at
https://chocolatey.org/compare",
@"
Did you know Chocolatey goes to eleven? And it turns great developers /
system admins into something amazing! Singlehandedly solve your
system admins into something amazing! Singlehandedly solve your
organization's struggles with software management and save the day!
https://chocolatey.org/compare"
};
private const string PRO_BUSINESS_LIST_MESSAGE = @"
Did you know Pro / Business automatically syncs with Programs and
Features? Learn more about Package Synchronizer at
Features? Learn more about Package Synchronizer at
https://chocolatey.org/compare";

private readonly string _shutdownExe = Environment.ExpandEnvironmentVariables("%systemroot%\\System32\\shutdown.exe");
Expand Down Expand Up @@ -163,7 +163,7 @@ public IEnumerable<PackageResult> list_run(ChocolateyConfiguration config)
{
if (string.IsNullOrWhiteSpace(config.Sources))
{
this.Log().Error(ChocolateyLoggers.Important, @"Unable to search for packages when there are no sources enabled for
this.Log().Error(ChocolateyLoggers.Important, @"Unable to search for packages when there are no sources enabled for
packages and none were passed as arguments.");
Environment.ExitCode = 1;
yield break;
Expand Down Expand Up @@ -381,6 +381,9 @@ public void handle_package_result(PackageResult packageResult, ChocolateyConfigu
//review: is this a Windows only kind of thing?
pkgInfo.FilesSnapshot = _filesService.capture_package_files(packageResult, config);

var is32Bit = !config.Information.Is64BitProcess || config.ForceX86;
create_ignore_files_for_executables(packageResult.InstallLocation, !is32Bit);

if (packageResult.Success) _shimgenService.install(config, packageResult);
}
else
Expand Down Expand Up @@ -446,11 +449,31 @@ public void handle_package_result(PackageResult packageResult, ChocolateyConfigu
}
else
{
this.Log().Info(ChocolateyLoggers.Important, @" Software install location not explicitly set, could be in package or
this.Log().Info(ChocolateyLoggers.Important, @" Software install location not explicitly set, could be in package or
default install location if installer.");
}
}

private void create_ignore_files_for_executables(string installLocation, bool is64Bit)
{
// If we are using a 64 bit architecure, we want to ignore exe's targetting x86
// This is done by adding a .ignore file into the package folder for each exe to ignore
var exeFiles32Bit = _fileSystem.get_files(_fileSystem.combine_paths(installLocation, "tools\\x86"), pattern: "*.exe", option: SearchOption.AllDirectories).ToArray();
var exeFiles64Bit = _fileSystem.get_files(_fileSystem.combine_paths(installLocation, "tools\\x64"), pattern: "*.exe", option: SearchOption.AllDirectories).ToArray();

// If 64bit, and there are only 32bit files, we should shim the 32bit versions,
// therefore, don't ignore anything
if (is64Bit && !exeFiles64Bit.Any() && exeFiles32Bit.Any())
{
return;
}

foreach (var exeFile in is64Bit ? exeFiles32Bit.or_empty_list_if_null() : exeFiles64Bit.or_empty_list_if_null())
{
_fileSystem.create_file(exeFile + ".ignore");
}
}

protected virtual ChocolateyPackageInformation get_package_information(PackageResult packageResult, ChocolateyConfiguration config)
{
var pkgInfo = _packageInfoService.get_package_information(packageResult.Package);
Expand Down Expand Up @@ -527,7 +550,7 @@ public ConcurrentDictionary<string, PackageResult> install_run(ChocolateyConfigu

if (string.IsNullOrWhiteSpace(config.Sources))
{
this.Log().Error(ChocolateyLoggers.Important, @"Installation was NOT successful. There are no sources enabled for
this.Log().Error(ChocolateyLoggers.Important, @"Installation was NOT successful. There are no sources enabled for
packages and none were passed as arguments.");
Environment.ExitCode = 1;
return packageInstalls;
Expand Down Expand Up @@ -567,7 +590,7 @@ public ConcurrentDictionary<string, PackageResult> install_run(ChocolateyConfigu
public void outdated_noop(ChocolateyConfiguration config)
{
this.Log().Info(@"
Would have determined packages that are out of date based on what is
Would have determined packages that are out of date based on what is
installed and what versions are available for upgrade.");
}

Expand Down Expand Up @@ -704,7 +727,7 @@ public ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfigu

if (string.IsNullOrWhiteSpace(config.Sources))
{
this.Log().Error(ChocolateyLoggers.Important, @"Upgrading was NOT successful. There are no sources enabled for
this.Log().Error(ChocolateyLoggers.Important, @"Upgrading was NOT successful. There are no sources enabled for
packages and none were passed as arguments.");
Environment.ExitCode = 1;
return new ConcurrentDictionary<string, PackageResult>();
Expand Down Expand Up @@ -798,17 +821,17 @@ public ConcurrentDictionary<string, PackageResult> uninstall_run(ChocolateyConfi
{
this.Log().Warn(@"
If a package uninstall is failing and/or you've already uninstalled the
software outside of Chocolatey, you can attempt to run the command
software outside of Chocolatey, you can attempt to run the command
with `-n` to skip running a chocolateyUninstall script, additionally
adding `--skip-autouninstaller` to skip an attempt to automatically
remove system-installed software. This will only remove the packaging
adding `--skip-autouninstaller` to skip an attempt to automatically
remove system-installed software. This will only remove the packaging
files and not things like software installed to Programs and Features.
If a package is failing because it is a dependency of another package
or packages, then you may first need to consider if it needs removed
as it is typically installed as a dependency for a reason. If you
decide that you still want to remove it, head into
`$env:ChocolateyInstall\lib` and find the package folder you want
as it is typically installed as a dependency for a reason. If you
decide that you still want to remove it, head into
`$env:ChocolateyInstall\lib` and find the package folder you want
removed. Then delete the folder for the package. This option should
only be used as a last resort.
");
Expand Down Expand Up @@ -867,7 +890,7 @@ private int report_action_summary(ConcurrentDictionary<string, PackageResult> pa
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(ChocolateyLoggers.Important, @"
The recent package changes indicate a reboot is necessary.
The recent package changes indicate a reboot is necessary.
Please reboot at your earliest convenience.");
}

Expand Down Expand Up @@ -1121,11 +1144,11 @@ private void handle_unsuccessful_operation(ChocolateyConfiguration config, Packa
{
this.Log().Error(ChocolateyLoggers.Important, @"
Package location is not specific enough, cannot move bad package or
rollback previous version. Erroneous install location captured as
rollback previous version. Erroneous install location captured as
'{0}'
ATTENTION: You must take manual action to remove {1} from
{2}. It will show incorrectly as installed
ATTENTION: You must take manual action to remove {1} from
{2}. It will show incorrectly as installed
until you do. To remove you can simply delete the folder in question.
".format_with(packageResult.InstallLocation, packageResult.Name, ApplicationParameters.PackagesLocation));
}
Expand Down Expand Up @@ -1303,7 +1326,7 @@ private void get_log_environment_changes(ChocolateyConfiguration config, IEnumer

if (!config.Features.LogEnvironmentValues)
{
this.Log().Debug(@"Logging of values is not turned on by default because it
this.Log().Debug(@"Logging of values is not turned on by default because it
could potentially expose sensitive data. If you understand the risk,
please see `choco feature -h` for information to turn it on.");
}
Expand Down

0 comments on commit 881a76d

Please sign in to comment.