Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
* stable:
  (GH-1774) log on failing repo
  (GH-1770) Feature - usePackageRepositoryOptimizations
  (GH-1771) Download nupkg, extract nuspec
  (maint) formatting
  (maint) ensure config for removing nuget cache
  (doc) update copyright year
  • Loading branch information
ferventcoder committed Mar 22, 2019
2 parents 389236f + 1ff4ab2 commit 17f00eb
Show file tree
Hide file tree
Showing 12 changed files with 101 additions and 47 deletions.
2 changes: 1 addition & 1 deletion .uppercut
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<property name="version.nuget.prerelease" value="" overwrite="false" />
<property name="version.use.build_date" value="false" overwrite="false" />
<property name="assembly.description" value="${project.name} is a product of ${company.name} - All Rights Reserved." overwrite="false" />
<property name="assembly.copyright" value="Copyright © 2017 - 2018 ${company.name} Copyright © 2011 - 2017, RealDimensions Software, LLC - All Rights Reserved." overwrite="false" />
<property name="assembly.copyright" value="Copyright © 2017 - 2019 ${company.name} Copyright © 2011 - 2017, RealDimensions Software, LLC - All Rights Reserved." overwrite="false" />
<property name="sign.project_with_key" value="true" overwrite="false" />

<!-- Build Features Overrides -->
Expand Down
2 changes: 1 addition & 1 deletion nuget/chocolatey.lib/chocolatey.lib.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<iconUrl>https://raw.githubusercontent.com/chocolatey/choco/master/docs/logo/chocolateyicon.gif</iconUrl>
<licenseUrl>https://raw.githubusercontent.com/chocolatey/choco/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>2017 Chocolatey Software, Inc, 2011- 2017 RealDimensions Software, LLC</copyright>
<copyright>2017-2019 Chocolatey Software, Inc, 2011- 2017 RealDimensions Software, LLC</copyright>
<tags>apt-get machine repository chocolatey</tags>
<summary>Chocolatey is the package manager for Windows (like apt-get but for Windows)</summary>
<description>
Expand Down
2 changes: 1 addition & 1 deletion nuget/chocolatey/chocolatey.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<iconUrl>https://raw.githubusercontent.com/chocolatey/choco/master/docs/logo/chocolateyicon.gif</iconUrl>
<licenseUrl>https://raw.githubusercontent.com/chocolatey/choco/master/LICENSE</licenseUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<copyright>2017 Chocolatey Software, Inc, 2011- 2017 RealDimensions Software, LLC</copyright>
<copyright>2017-2019 Chocolatey Software, Inc, 2011- 2017 RealDimensions Software, LLC</copyright>
<!--<projectSourceUrl>https://github.com/chocolatey/choco</projectSourceUrl>
<docsUrl>https://chocolatey.org/docs</docsUrl>
<mailingListUrl>https://groups.google.com/forum/#!forum/chocolatey</mailingListUrl>
Expand Down
1 change: 1 addition & 0 deletions src/chocolatey/infrastructure.app/ApplicationParameters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public static class Features
public static readonly string LogWithoutColor = "logWithoutColor";
public static readonly string ExitOnRebootDetected = "exitOnRebootDetected";
public static readonly string LogValidationResultsOnWarnings = "logValidationResultsOnWarnings";
public static readonly string UsePackageRepositoryOptimizations = "usePackageRepositoryOptimizations";
}

public static class Messages
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ private static void set_feature_flags(ChocolateyConfiguration config, ConfigFile
config.Features.RemovePackageInformationOnUninstall = set_feature_flag(ApplicationParameters.Features.RemovePackageInformationOnUninstall, configFileSettings, defaultEnabled: false, description: "Remove Stored Package Information On Uninstall - When a package is uninstalled, should the stored package information also be removed? Available in 0.10.9+.");
config.Features.LogWithoutColor = set_feature_flag(ApplicationParameters.Features.LogWithoutColor, configFileSettings, defaultEnabled: false, description: "Log without color - Do not show colorization in logging output. Available in 0.10.9+.");
config.Features.LogValidationResultsOnWarnings = set_feature_flag(ApplicationParameters.Features.LogValidationResultsOnWarnings, configFileSettings, defaultEnabled: true, description: "Log validation results on warnings - Should the validation results be logged if there are warnings? Available in 0.10.12+.");
config.Features.UsePackageRepositoryOptimizations = set_feature_flag(ApplicationParameters.Features.UsePackageRepositoryOptimizations, configFileSettings, defaultEnabled: true, description: "Use Package Repository Optimizations - Turn on optimizations for reducing bandwidth with repository queries during package install/upgrade/outdated operations. Should generally be left enabled, unless a repository needs to support older methods of query. When disabled, this makes queries similar to the way they were done in Chocolatey v0.10.11 and before. Available in 0.10.14+.");
config.Features.ScriptsCheckLastExitCode = set_feature_flag(ApplicationParameters.Features.ScriptsCheckLastExitCode, configFileSettings, defaultEnabled: false, description: "Scripts Check $LastExitCode (external commands) - Leave this off unless you absolutely need it while you fix your package scripts to use `throw 'error message'` or `Set-PowerShellExitCode #` instead of `exit #`. This behavior started in 0.9.10 and produced hard to find bugs. If the last external process exits successfully but with an exit code of not zero, this could cause hard to detect package failures. Available in 0.10.3+. Will be removed in 0.11.0.");
config.PromptForConfirmation = !set_feature_flag(ApplicationParameters.Features.AllowGlobalConfirmation, configFileSettings, defaultEnabled: false, description: "Prompt for confirmation in scripts or bypass.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,12 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
option => configuration.Features.StopOnFirstPackageFailure = option != null
)
.Add("exitwhenrebootdetected|exit-when-reboot-detected",
"Exit When Reboot Detected - Stop running install, upgrade, or uninstall when a reboot request is detected. Requires '{0}' feature to be turned on. Will exit with either {1} or {2}. Overrides the default feature '{3}' set to '{4}'. Available in 0.10.12+.".format_with
"Exit When Reboot Detected - Stop running install, upgrade, or uninstall when a reboot request is detected. Requires '{0}' feature to be turned on. Will exit with either {1} or {2}. Overrides the default feature '{3}' set to '{4}'. Available in 0.10.12+.".format_with
(ApplicationParameters.Features.UsePackageExitCodes, ApplicationParameters.ExitCodes.ErrorFailNoActionReboot, ApplicationParameters.ExitCodes.ErrorInstallSuspend, ApplicationParameters.Features.ExitOnRebootDetected, configuration.Features.ExitOnRebootDetected.to_string()),
option => configuration.Features.ExitOnRebootDetected = option != null
)
.Add("ignoredetectedreboot|ignore-detected-reboot",
"Ignore Detected Reboot - Ignore any detected reboots if found. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.12+.".format_with
"Ignore Detected Reboot - Ignore any detected reboots if found. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.12+.".format_with
(ApplicationParameters.Features.ExitOnRebootDetected, configuration.Features.ExitOnRebootDetected.to_string()),
option =>
{
Expand All @@ -170,6 +170,16 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
configuration.Features.ExitOnRebootDetected = false;
}
})
.Add("disable-repository-optimizations|disable-package-repository-optimizations",
"Disable Package Repository Optimizations - Do not use optimizations for reducing bandwidth with repository queries during package install/upgrade/outdated operations. Should not generally be used, unless a repository needs to support older methods of query. When used, this makes queries similar to the way they were done in Chocolatey v0.10.11 and before. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.14+.".format_with
(ApplicationParameters.Features.UsePackageRepositoryOptimizations, configuration.Features.UsePackageRepositoryOptimizations.to_string()),
option =>
{
if (option != null)
{
configuration.Features.UsePackageRepositoryOptimizations = false;
}
})
;

//todo: package name can be a url / installertype
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,16 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
.Add("ignore-unfound",
"Ignore Unfound Packages - Ignore packages that are not found on the sources used (or the defaults). Overrides the default feature '{0}' set to '{1}'. Available in 0.10.9+.".format_with(ApplicationParameters.Features.IgnoreUnfoundPackagesOnUpgradeOutdated, configuration.Features.IgnoreUnfoundPackagesOnUpgradeOutdated.to_string()),
option => configuration.Features.IgnoreUnfoundPackagesOnUpgradeOutdated = option != null)
.Add("disable-repository-optimizations|disable-package-repository-optimizations",
"Disable Package Repository Optimizations - Do not use optimizations for reducing bandwidth with repository queries during package install/upgrade/outdated operations. Should not generally be used, unless a repository needs to support older methods of query. When disabled, this makes queries similar to the way they were done in Chocolatey v0.10.11 and before. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.14+.".format_with
(ApplicationParameters.Features.UsePackageRepositoryOptimizations, configuration.Features.UsePackageRepositoryOptimizations.to_string()),
option =>
{
if (option != null)
{
configuration.Features.UsePackageRepositoryOptimizations = false;
}
})
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,23 +185,23 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
)
.Add("userememberedargs|userememberedarguments|userememberedoptions|use-remembered-args|use-remembered-arguments|use-remembered-options",
"Use Remembered Options for Upgrade - use the arguments and options used during install for upgrade. Does not override arguments being passed at runtime. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.4+.".format_with(ApplicationParameters.Features.UseRememberedArgumentsForUpgrades, configuration.Features.UseRememberedArgumentsForUpgrades.to_string()),
option =>
{
if (option != null) configuration.Features.UseRememberedArgumentsForUpgrades = true;
})
option =>
{
if (option != null) configuration.Features.UseRememberedArgumentsForUpgrades = true;
})
.Add("ignorerememberedargs|ignorerememberedarguments|ignorerememberedoptions|ignore-remembered-args|ignore-remembered-arguments|ignore-remembered-options",
"Ignore Remembered Options for Upgrade - ignore the arguments and options used during install for upgrade. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.4+.".format_with(ApplicationParameters.Features.UseRememberedArgumentsForUpgrades, configuration.Features.UseRememberedArgumentsForUpgrades.to_string()),
option =>
{
if (option != null) configuration.Features.UseRememberedArgumentsForUpgrades = false;
})
option =>
{
if (option != null) configuration.Features.UseRememberedArgumentsForUpgrades = false;
})
.Add("exitwhenrebootdetected|exit-when-reboot-detected",
"Exit When Reboot Detected - Stop running install, upgrade, or uninstall when a reboot request is detected. Requires '{0}' feature to be turned on. Will exit with either {1} or {2}. Overrides the default feature '{3}' set to '{4}'. Available in 0.10.12+.".format_with
"Exit When Reboot Detected - Stop running install, upgrade, or uninstall when a reboot request is detected. Requires '{0}' feature to be turned on. Will exit with either {1} or {2}. Overrides the default feature '{3}' set to '{4}'. Available in 0.10.12+.".format_with
(ApplicationParameters.Features.UsePackageExitCodes, ApplicationParameters.ExitCodes.ErrorFailNoActionReboot, ApplicationParameters.ExitCodes.ErrorInstallSuspend, ApplicationParameters.Features.ExitOnRebootDetected, configuration.Features.ExitOnRebootDetected.to_string()),
option => configuration.Features.ExitOnRebootDetected = option != null
)
.Add("ignoredetectedreboot|ignore-detected-reboot",
"Ignore Detected Reboot - Ignore any detected reboots if found. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.12+.".format_with
"Ignore Detected Reboot - Ignore any detected reboots if found. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.12+.".format_with
(ApplicationParameters.Features.ExitOnRebootDetected, configuration.Features.ExitOnRebootDetected.to_string()),
option =>
{
Expand All @@ -210,6 +210,16 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon
configuration.Features.ExitOnRebootDetected = false;
}
})
.Add("disable-repository-optimizations|disable-package-repository-optimizations",
"Disable Package Repository Optimizations - Do not use optimizations for reducing bandwidth with repository queries during package install/upgrade/outdated operations. Should not generally be used, unless a repository needs to support older methods of query. When disabled, this makes queries similar to the way they were done in Chocolatey v0.10.11 and before. Overrides the default feature '{0}' set to '{1}'. Available in 0.10.14+.".format_with
(ApplicationParameters.Features.UsePackageRepositoryOptimizations, configuration.Features.UsePackageRepositoryOptimizations.to_string()),
option =>
{
if (option != null)
{
configuration.Features.UsePackageRepositoryOptimizations = false;
}
})
;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ public sealed class FeaturesConfiguration
public bool RemovePackageInformationOnUninstall { get; set; }
public bool ExitOnRebootDetected { get; set; }
public bool LogValidationResultsOnWarnings { get; set; }
public bool UsePackageRepositoryOptimizations { get; set; }

//todo remove in 0.11.0
public bool ScriptsCheckLastExitCode { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace chocolatey.infrastructure.app.nuget
using System.IO;
using System.Linq;
using System.Runtime.Versioning;
using System.Threading;
using NuGet;

// ReSharper disable InconsistentNaming
Expand Down Expand Up @@ -50,10 +51,15 @@ public ChocolateyLocalPackageRepository(IPackagePathResolver pathResolver, IFile
public override void AddPackage(IPackage package)
{
string packageFilePath = GetPackageFilePath(package);
FileSystem.AddFileWithCheck(packageFilePath, package.GetStream);
// allow the file to finish being written
Thread.Sleep(200);
if (PackageSaveMode.HasFlag(PackageSaveModes.Nuspec))
{
// don't trust the package metadata to be complete - extract from the downloaded nupkg
var zipPackage = new OptimizedZipPackage(FileSystem, packageFilePath);
string manifestFilePath = GetManifestFilePath(package.Id, package.Version);
Manifest manifest = Manifest.Create(package);
Manifest manifest = Manifest.Create(zipPackage);
manifest.Metadata.ReferenceSets = Enumerable.ToList<ManifestReferenceSet>(Enumerable.Select<IGrouping<FrameworkName, IPackageAssemblyReference>, ManifestReferenceSet>(Enumerable.GroupBy<IPackageAssemblyReference, FrameworkName>(package.AssemblyReferences, (Func<IPackageAssemblyReference, FrameworkName>)(f => f.TargetFramework)), (Func<IGrouping<FrameworkName, IPackageAssemblyReference>, ManifestReferenceSet>)(g => new ManifestReferenceSet()
{
TargetFramework = g.Key == (FrameworkName)null ? (string)null : VersionUtility.GetFrameworkString(g.Key),
Expand All @@ -64,8 +70,6 @@ public override void AddPackage(IPackage package)
})));
FileSystem.AddFileWithCheck(manifestFilePath, manifest.Save);
}

FileSystem.AddFileWithCheck(packageFilePath, package.GetStream);
}

private string GetManifestFilePath(string packageId, SemanticVersion version)
Expand Down
3 changes: 2 additions & 1 deletion src/chocolatey/infrastructure.app/runners/GenericRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ namespace chocolatey.infrastructure.app.runners
using configuration;
using domain;
using infrastructure.commands;
using infrastructure.configuration;
using logging;
using Console = System.Console;
using Environment = System.Environment;
Expand Down Expand Up @@ -182,7 +183,7 @@ public void run(ChocolateyConfiguration config, Container container, bool isCons
/// <param name="container">The container.</param>
private void remove_nuget_cache(Container container)
{
remove_nuget_cache(container, null);
remove_nuget_cache(container, Config.get_configuration_settings());
}

/// <summary>
Expand Down
Loading

0 comments on commit 17f00eb

Please sign in to comment.