Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (log) Explain how to install licensed extension
  (chocolateyGH-712) Report required reboots
  (chocolateyGH-641) Allow more exit codes for install shield
  (chocolateyGH-715) Report loaded extensions to the user
  (chocolateyGH-258) Remove unnecessary configuration
  (chocolateyGH-641) Add BitRock / QT / Squirrel Installers
  • Loading branch information
ferventcoder committed May 1, 2016
2 parents 4393785 + 6d4ec83 commit a0547d9
Show file tree
Hide file tree
Showing 11 changed files with 219 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/chocolatey.console/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ private static void Main(string[] args)
@"Error when attempting to load chocolatey licensed assembly. Ensure
that chocolatey.licensed.dll exists at
'{0}'.
Install with `choco install chocolatey.extension`.
The error message itself may be helpful as well:{1} {2}".format_with(
ApplicationParameters.LicensedAssemblyLocation,
Environment.NewLine,
Expand Down
3 changes: 2 additions & 1 deletion src/chocolatey.resources/helpers/chocolateyInstaller.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ if (Test-Path($extensionsPath)) {
Get-ChildItem $extensionsPath -recurse -filter "*.dll" | Select -ExpandProperty FullName | % {
$path = $_;
try {
Write-Debug "Importing '$path'";
Write-Debug "Importing '$path'";
Write-Host "Loading '$([System.IO.Path]::GetFileNameWithoutExtension($path))' extension.";
Import-Module $path;
} catch {
if ($env:ChocolateyPowerShellHost -eq 'true') {
Expand Down
3 changes: 3 additions & 0 deletions src/chocolatey/chocolatey.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,12 @@
<Compile Include="infrastructure.app\commands\ChocolateyInfoCommand.cs" />
<Compile Include="infrastructure.app\domain\GenericRegistryKey.cs" />
<Compile Include="infrastructure.app\domain\GenericRegistryValue.cs" />
<Compile Include="infrastructure.app\domain\installers\BitRockInstaller.cs" />
<Compile Include="infrastructure.app\domain\installers\GhostInstaller.cs" />
<Compile Include="infrastructure.app\domain\installers\InstallForJInstaller.cs" />
<Compile Include="infrastructure.app\domain\installers\IzPackInstaller.cs" />
<Compile Include="infrastructure.app\domain\installers\QtInstaller.cs" />
<Compile Include="infrastructure.app\domain\installers\SquirrelInstaller.cs" />
<Compile Include="infrastructure.app\domain\RegistryValueKindType.cs" />
<Compile Include="infrastructure.app\events\HandlePackageResultCompletedMessage.cs" />
<Compile Include="infrastructure.app\services\FileTypeDetectorService.cs" />
Expand Down
2 changes: 2 additions & 0 deletions src/chocolatey/infrastructure.app/domain/InstallerType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public enum InstallerType
Ghost,
InstallForJ,
IzPack,
BitRock,
Squirrel,
QtInstaller,
Zip,
SevenZip,
HotfixOrSecurityUpdate,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// Copyright © 2011 - Present RealDimensions Software, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace chocolatey.infrastructure.app.domain.installers
{
using System.Collections.Generic;

/// <summary>
/// BitRock Installer Options
/// </summary>
/// <remarks>
/// http://blog.bitrock.com/2009/10/unattended-mode.html
/// http://installbuilder.bitrock.com/docs/installbuilder-userguide.html#_unattended_mode
/// http://installbuilder.bitrock.com/docs/installbuilder-userguide/ar01s13.html
/// </remarks>
public class BitRockInstaller : InstallerBase
{
public BitRockInstaller()
{
InstallExecutable = "\"{0}\"".format_with(InstallTokens.INSTALLER_LOCATION);
SilentInstall = "--mode unattended";
// http://answers.bitrock.com/questions/215/how-can-i-restart-the-computer-after-installation-has-completed
NoReboot = "";
LogFile = "";
// http://installbuilder.bitrock.com/docs/installbuilder-userguide.html#_command_line_parameters
// http://answers.bitrock.com/questions/57/how-do-i-specify-a-different-default-installation-directory-for-unix-and-windows
CustomInstallLocation = "--installdir {0}".format_with(InstallTokens.CUSTOM_INSTALL_LOCATION);
Language = "";
OtherInstallOptions = "--unattendedmodeui none";
UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION);
SilentUninstall = "--mode unattended";
OtherUninstallOptions = "--unattendedmodeui none";
ValidInstallExitCodes = new List<int>
{
0
};
ValidUninstallExitCodes = new List<int>
{
0
};
}

public override InstallerType InstallerType { get { return InstallerType.BitRock; } }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public InstallShieldInstaller()
OtherUninstallOptions = "/sms";
// http://helpnet.installshield.com/installshield18helplib/IHelpSetup_EXEErrors.htm
ValidInstallExitCodes = new List<int> {0, 1641, 3010};
ValidUninstallExitCodes = new List<int> {0, 1641, 3010};
ValidUninstallExitCodes = new List<int> { 0, 1605, 1614, 1641, 3010 };
}

public override InstallerType InstallerType
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ public MsiInstaller()
// http://msdn.microsoft.com/en-us/library/aa371101.aspx
NoReboot = "/norestart"; //REBOOT=ReallySuppress
LogFile = "/l*v \"{0}\\MSI.Install.log\"".format_with(InstallTokens.PACKAGE_LOCATION);
// http://msdn.microsoft.com/en-us/library/aa372064.aspx
// https://msdn.microsoft.com/en-us/library/aa372064.aspx
// http://apprepack.blogspot.com/2012/08/installdir-vs-targetdir.html
CustomInstallLocation = "TARGETDIR=\"{0}\"".format_with(InstallTokens.CUSTOM_INSTALL_LOCATION);
// http://msdn.microsoft.com/en-us/library/aa370856.aspx
Language = "ProductLanguage={0}".format_with(InstallTokens.LANGUAGE);
Expand Down
55 changes: 55 additions & 0 deletions src/chocolatey/infrastructure.app/domain/installers/QtInstaller.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright © 2011 - Present RealDimensions Software, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace chocolatey.infrastructure.app.domain.installers
{
using System.Collections.Generic;

/// <summary>
/// QT Installer Options
/// </summary>
/// <remarks>
/// https://doc.qt.io/qtinstallerframework/index.html
/// http://doc.qt.io/qtinstallerframework/operations.html
/// </remarks>
public class QtInstaller : InstallerBase
{
public QtInstaller()
{
InstallExecutable = "\"{0}\"".format_with(InstallTokens.INSTALLER_LOCATION);
SilentInstall = "";
NoReboot = "";
LogFile = "";
//http://doc.qt.io/qtinstallerframework/ifw-globalconfig.html
//CustomInstallLocation = "targetdir={0}".format_with(InstallTokens.CUSTOM_INSTALL_LOCATION);
CustomInstallLocation = "";
Language = "";
OtherInstallOptions = "";
UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION);
SilentUninstall = "";
OtherUninstallOptions = "";
ValidInstallExitCodes = new List<int>
{
0
};
ValidUninstallExitCodes = new List<int>
{
0
};
}

public override InstallerType InstallerType { get { return InstallerType.QtInstaller; } }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright © 2011 - Present RealDimensions Software, LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
//
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

namespace chocolatey.infrastructure.app.domain.installers
{
using System.Collections.Generic;

/// <summary>
/// Squirrel Installer Options
/// </summary>
/// <remarks>
/// https://github.com/Squirrel/Squirrel.Windows/blob/92e7af66b1593f951527dd88289a4ed1bee4bcdd/src/Update/Program.cs#L109
/// </remarks>
public class SquirrelInstaller : InstallerBase
{
public SquirrelInstaller()
{
InstallExecutable = "\"{0}\"".format_with(InstallTokens.INSTALLER_LOCATION);
SilentInstall = "-s";
NoReboot = "";
LogFile = "";
CustomInstallLocation = "";
Language = "";
OtherInstallOptions = "";
UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION);
SilentUninstall = "-s";
OtherUninstallOptions = "";
ValidInstallExitCodes = new List<int>
{
0
};
ValidUninstallExitCodes = new List<int>
{
0
};
}

public override InstallerType InstallerType { get { return InstallerType.Squirrel; } }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,7 @@ public ConcurrentDictionary<string, PackageResult> install_run(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 ConcurrentDictionary<string, PackageResult> install_run(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 ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfigu

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 ConcurrentDictionary<string, PackageResult> upgrade_run(ChocolateyConfigu
}
}

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 ConcurrentDictionary<string, PackageResult> uninstall_run(ChocolateyConfi
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 ConcurrentDictionary<string, PackageResult> uninstall_run(ChocolateyConfi
_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
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ namespace chocolatey.infrastructure.app.services
public class FileTypeDetectorService : IFileTypeDetectorService
{
private readonly IFileSystem _fileSystem;
private readonly ChocolateyConfiguration _configuration;

private const int DIE_SHOWERRORS = 0x00000001;
private const int DIE_SHOWOPTIONS = 0x00000002;
Expand All @@ -36,10 +35,9 @@ public class FileTypeDetectorService : IFileTypeDetectorService
private const int DIE_SINGLELINEOUTPUT = 0x00000010;
private const int DIE_SHOWFILEFORMATONCE = 0x00000020;

public FileTypeDetectorService(IFileSystem fileSystem, ChocolateyConfiguration configuration)
public FileTypeDetectorService(IFileSystem fileSystem)
{
_fileSystem = fileSystem;
_configuration = configuration;
}

//// http://stackoverflow.com/a/8861895/18475
Expand Down

0 comments on commit a0547d9

Please sign in to comment.