diff --git a/COMMITTERS.md b/COMMITTERS.md index 721d001ae5..ed8cad8fb0 100644 --- a/COMMITTERS.md +++ b/COMMITTERS.md @@ -75,6 +75,7 @@ Because we ask contributors to target master, sometimes a fix/enhancement may ne * `build.bat` - build and test * Any additional changes or testing here. * `git checkout stable` + * `git fetch upstream` - if this pulls anything, make sure to also run `git rebase upstream/stable` prior to merging or you will lose the merge commit. * `git merge pr --log --no-ff` * `git branch -d pr` * `git checkout master` diff --git a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs index 59a9e3ec3b..daff600795 100644 --- a/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs +++ b/src/chocolatey/infrastructure.app/builders/ConfigurationBuilder.cs @@ -512,7 +512,12 @@ shortcut commands like `cinst` or `cup`. `choco source list`, where `source` is the command and `list` is the subcommand. * Typically the subject comes next. If installing packages, the - subject would be the package names. e.g. `choco install pkg1 pkg2`. + subject would be the package names, e.g. `choco install pkg1 pkg2`. + * Never use 'nupkg' or point directly to a nupkg file UNLESS using + 'choco push'. Use the source folder instead, e.g. `choco install + --source=""'c:\folder\with\package'""` instead of + `choco install DoNotDoThis.1.0.nupkg` or `choco install DoNotDoThis + --source=""'c:\folder\with\package\DoNotDoThis.1.0.nupkg'""`. * Switches and parameters are called simply options. Options come after the subject. e.g. `choco install pkg1 --debug --verbose`. * Never use the force option (`--force`/`-f`) in scripts (or really @@ -529,15 +534,15 @@ online or through `choco -?` /`choco [Command Name] -?`. temporarily stop for input - the key here is temporarily. They will continue without requiring any action after the temporary timeout (typically 30 seconds). - * Full option names are prepended with two dashes. e.g. `--` or + * Full option names are prepended with two dashes, e.g. `--` or `--debug --verbose --ignore-proxy`. * When setting a value to an option, always put an equals (`=`) between the name and the setting, e.g. `--source=""'local'""`. * When setting a value to an option, always surround the value - properly with double quotes bookending apostrophes. e.g. + properly with double quotes bookending apostrophes, e.g. `--source=""'internal_server'""`. * If you are building PowerShell scripts, you can most likely just - simply use apostrophes surrounding option values e.g. + simply use apostrophes surrounding option values, e.g. `--source='internal_server'`. * Prefer upgrade to install in scripts. You can't `install` to a newer version of something, but you can `choco upgrade` which will do both diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs index 14fb95ee4b..9e1cd0e733 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyConfigSettingsService.cs @@ -75,7 +75,7 @@ public virtual IEnumerable source_list(ChocolateyConfiguration else { this.Log().Info(() => "{0}|{1}|{2}|{3}|{4}|{5}|{6}|{7}|{8}".format_with( - source.Id, + source.Id.quote_if_pipe_found(), source.Value, source.Disabled.to_string(), source.UserName.quote_if_pipe_found(), diff --git a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs index 3ef31c147a..3ba579f767 100644 --- a/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs +++ b/src/chocolatey/infrastructure.app/services/ChocolateyPackageService.cs @@ -633,29 +633,34 @@ Output is package name | current version | available version | pinned? var output = config.RegularOutput; config.RegularOutput = false; - var oudatedPackages = _nugetService.get_outdated(config); + var outdatedPackages = _nugetService.get_outdated(config); config.RegularOutput = output; if (config.RegularOutput) { - var upgradeWarnings = oudatedPackages.Count(p => p.Value.Warning); + var upgradeWarnings = outdatedPackages.Count(p => p.Value.Warning); this.Log().Warn(() => @"{0}{1} has determined {2} package(s) are outdated. {3}".format_with( Environment.NewLine, ApplicationParameters.Name, - oudatedPackages.Count(p => p.Value.Success && !p.Value.Inconclusive), + outdatedPackages.Count(p => p.Value.Success && !p.Value.Inconclusive), upgradeWarnings == 0 ? string.Empty : "{0} {1} package(s) had warnings.".format_with(Environment.NewLine, upgradeWarnings) )); if (upgradeWarnings != 0) { this.Log().Warn(ChocolateyLoggers.Important, "Warnings:"); - foreach (var warning in oudatedPackages.Where(p => p.Value.Warning).or_empty_list_if_null()) + foreach (var warning in outdatedPackages.Where(p => p.Value.Warning).or_empty_list_if_null()) { this.Log().Warn(ChocolateyLoggers.Important, " - {0}".format_with(warning.Value.Name)); } } } + if (outdatedPackages.Count != 0 && Environment.ExitCode == 0) + { + Environment.ExitCode = 2; + } + randomly_notify_about_pro_business(config); } diff --git a/src/chocolatey/infrastructure.app/services/NugetService.cs b/src/chocolatey/infrastructure.app/services/NugetService.cs index 63159fd59d..ae4d49a47e 100644 --- a/src/chocolatey/infrastructure.app/services/NugetService.cs +++ b/src/chocolatey/infrastructure.app/services/NugetService.cs @@ -899,7 +899,7 @@ public virtual ConcurrentDictionary get_outdated(Chocolat var pkgInfo = _packageInfoService.get_package_information(installedPackage); bool isPinned = pkgInfo.IsPinned; - // if the package is pinned and we are skipping pinned, + // if the package is pinned and we are skipping pinned, // move on quickly if (isPinned && config.OutdatedCommand.IgnorePinned) { @@ -918,7 +918,7 @@ public virtual ConcurrentDictionary get_outdated(Chocolat } var latestPackage = find_package(packageName, null, config, repository); - + if (latestPackage == null) { if (config.Features.IgnoreUnfoundPackagesOnUpgradeOutdated) continue; @@ -933,7 +933,7 @@ public virtual ConcurrentDictionary get_outdated(Chocolat } if (latestPackage.Version <= installedPackage.Version) continue; - + var packageResult = outdatedPackages.GetOrAdd(packageName, new PackageResult(latestPackage, _fileSystem.combine_paths(ApplicationParameters.PackagesLocation, latestPackage.Id))); string logMessage = "You have {0} v{1} installed. Version {2} is available based on your source(s).{3} Source(s): \"{4}\"".format_with(installedPackage.Id, installedPackage.Version, latestPackage.Version, Environment.NewLine, config.Sources); @@ -1146,6 +1146,8 @@ public virtual void backup_existing_version(ChocolateyConfiguration config, IPac try { _fileSystem.copy_directory(backupLocation, pkgInstallPath, overwriteExisting: true); + + remove_packaging_files_prior_to_upgrade(pkgInstallPath, config.CommandName); } catch (Exception ex) { @@ -1167,6 +1169,29 @@ process locking the folder or files. Please make sure nothing is } } + public virtual void remove_packaging_files_prior_to_upgrade(string directoryPath, string commandName) + { + if (commandName.to_lower() == "upgrade") + { + // Due to the way that Package Reducer works, there is a potential that a Chocolatey Packaging + // script could be incorrectly left in place during an upgrade operation. To guard against this, + // remove any Chocolatey Packaging scripts, which will then be restored by the new package, if + // they are still required + var filesToDelete = new List {"chocolateyinstall", "chocolateyuninstall", "chocolateybeforemodify"}; + var packagingScripts = _fileSystem.get_files(directoryPath, "*.ps1", SearchOption.AllDirectories) + .Where(p => filesToDelete.Contains(_fileSystem.get_file_name_without_extension(p).to_lower())); + + foreach (var packagingScript in packagingScripts) + { + if (_fileSystem.file_exists(packagingScript)) + { + this.Log().Debug("Deleting file {0}".format_with(packagingScript)); + _fileSystem.delete_file(packagingScript); + } + } + } + } + public virtual void backup_changed_files(string packageInstallPath, ChocolateyConfiguration config, ChocolateyPackageInformation packageInfo) { if (packageInfo == null || packageInfo.Package == null) return;