From 4350be9c86b1d09255632a6c558fd2d7a29c21ee Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Sat, 20 Feb 2016 11:02:51 -0600 Subject: [PATCH 1/4] (maint) move installers to a section by themselves --- .../services/AutomaticUninstallerServiceSpecs.cs | 1 + src/chocolatey/chocolatey.csproj | 14 +++++++------- .../domain/{ => installers}/CustomInstaller.cs | 4 ++-- .../domain/{ => installers}/IInstaller.cs | 2 +- .../domain/{ => installers}/InnoSetupInstaller.cs | 9 ++++----- .../{ => installers}/InstallShieldInstaller.cs | 2 +- .../domain/{ => installers}/InstallerBase.cs | 2 +- .../domain/{ => installers}/MsiInstaller.cs | 4 ++-- .../domain/{ => installers}/NsisInstaller.cs | 8 ++++---- .../services/AutomaticUninstallerService.cs | 1 + 10 files changed, 24 insertions(+), 23 deletions(-) rename src/chocolatey/infrastructure.app/domain/{ => installers}/CustomInstaller.cs (91%) rename src/chocolatey/infrastructure.app/domain/{ => installers}/IInstaller.cs (93%) rename src/chocolatey/infrastructure.app/domain/{ => installers}/InnoSetupInstaller.cs (87%) rename src/chocolatey/infrastructure.app/domain/{ => installers}/InstallShieldInstaller.cs (95%) rename src/chocolatey/infrastructure.app/domain/{ => installers}/InstallerBase.cs (95%) rename src/chocolatey/infrastructure.app/domain/{ => installers}/MsiInstaller.cs (94%) rename src/chocolatey/infrastructure.app/domain/{ => installers}/NsisInstaller.cs (84%) diff --git a/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs b/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs index 1cebc0d7ef..78f329f416 100644 --- a/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs +++ b/src/chocolatey.tests/infrastructure.app/services/AutomaticUninstallerServiceSpecs.cs @@ -20,6 +20,7 @@ namespace chocolatey.tests.infrastructure.app.services using System.Collections.Generic; using System.Diagnostics; using System.Linq; + using chocolatey.infrastructure.app.domain.installers; using Moq; using NuGet; using chocolatey.infrastructure.adapters; diff --git a/src/chocolatey/chocolatey.csproj b/src/chocolatey/chocolatey.csproj index 764c16fda4..6684a347f8 100644 --- a/src/chocolatey/chocolatey.csproj +++ b/src/chocolatey/chocolatey.csproj @@ -108,7 +108,7 @@ - + @@ -140,14 +140,14 @@ - - - - + + + + - - + + diff --git a/src/chocolatey/infrastructure.app/domain/CustomInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/CustomInstaller.cs similarity index 91% rename from src/chocolatey/infrastructure.app/domain/CustomInstaller.cs rename to src/chocolatey/infrastructure.app/domain/installers/CustomInstaller.cs index fe991be4b1..a11058639d 100644 --- a/src/chocolatey/infrastructure.app/domain/CustomInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/CustomInstaller.cs @@ -1,4 +1,4 @@ -// Copyright © 2011 - Present RealDimensions Software, LLC +// 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. @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace chocolatey.infrastructure.app.domain +namespace chocolatey.infrastructure.app.domain.installers { using System.Collections.Generic; diff --git a/src/chocolatey/infrastructure.app/domain/IInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/IInstaller.cs similarity index 93% rename from src/chocolatey/infrastructure.app/domain/IInstaller.cs rename to src/chocolatey/infrastructure.app/domain/installers/IInstaller.cs index 84e3363cad..74d62db74d 100644 --- a/src/chocolatey/infrastructure.app/domain/IInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/IInstaller.cs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace chocolatey.infrastructure.app.domain +namespace chocolatey.infrastructure.app.domain.installers { using System.Collections.Generic; diff --git a/src/chocolatey/infrastructure.app/domain/InnoSetupInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/InnoSetupInstaller.cs similarity index 87% rename from src/chocolatey/infrastructure.app/domain/InnoSetupInstaller.cs rename to src/chocolatey/infrastructure.app/domain/installers/InnoSetupInstaller.cs index 7428c3debf..8ceb0e5b66 100644 --- a/src/chocolatey/infrastructure.app/domain/InnoSetupInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/InnoSetupInstaller.cs @@ -13,9 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace chocolatey.infrastructure.app.domain +namespace chocolatey.infrastructure.app.domain.installers { - using System; using System.Collections.Generic; /// @@ -30,16 +29,16 @@ public InnoSetupInstaller() { InstallExecutable = "\"{0}\" ".format_with(InstallTokens.INSTALLER_LOCATION); SilentInstall = "/VERYSILENT"; - NoReboot = "/NORESTART"; + NoReboot = "/NORESTART /RESTARTEXITCODE=3010"; LogFile = "/LOG=\"{0}\\InnoSetup.Install.log\"".format_with(InstallTokens.PACKAGE_LOCATION); CustomInstallLocation = "/DIR=\"{0}\"".format_with(InstallTokens.CUSTOM_INSTALL_LOCATION); Language = "/LANG={0}".format_with(InstallTokens.LANGUAGE); - OtherInstallOptions = "/SP- /SUPPRESSMSGBOXES /CLOSEAPPLICATIONS /RESTARTAPPLICATIONS /NOICONS"; + OtherInstallOptions = "/SP- /SUPPRESSMSGBOXES /CLOSEAPPLICATIONS /FORCECLOSEAPPLICATIONS /NOICONS"; UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); SilentUninstall = "/VERYSILENT"; OtherUninstallOptions = "/SUPPRESSMSGBOXES"; // http://www.jrsoftware.org/ishelp/index.php?topic=setupexitcodes - ValidInstallExitCodes = new List { 0 }; + ValidInstallExitCodes = new List { 0, 3010 }; ValidUninstallExitCodes = new List { 0 }; } diff --git a/src/chocolatey/infrastructure.app/domain/InstallShieldInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/InstallShieldInstaller.cs similarity index 95% rename from src/chocolatey/infrastructure.app/domain/InstallShieldInstaller.cs rename to src/chocolatey/infrastructure.app/domain/installers/InstallShieldInstaller.cs index 99eda0b30f..1b7a5ac8f7 100644 --- a/src/chocolatey/infrastructure.app/domain/InstallShieldInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/InstallShieldInstaller.cs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace chocolatey.infrastructure.app.domain +namespace chocolatey.infrastructure.app.domain.installers { using System.Collections.Generic; diff --git a/src/chocolatey/infrastructure.app/domain/InstallerBase.cs b/src/chocolatey/infrastructure.app/domain/installers/InstallerBase.cs similarity index 95% rename from src/chocolatey/infrastructure.app/domain/InstallerBase.cs rename to src/chocolatey/infrastructure.app/domain/installers/InstallerBase.cs index a66b402523..fa5b454d31 100644 --- a/src/chocolatey/infrastructure.app/domain/InstallerBase.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/InstallerBase.cs @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace chocolatey.infrastructure.app.domain +namespace chocolatey.infrastructure.app.domain.installers { using System.Collections.Generic; using System.Text; diff --git a/src/chocolatey/infrastructure.app/domain/MsiInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/MsiInstaller.cs similarity index 94% rename from src/chocolatey/infrastructure.app/domain/MsiInstaller.cs rename to src/chocolatey/infrastructure.app/domain/installers/MsiInstaller.cs index 2a974517e7..c7c73650e2 100644 --- a/src/chocolatey/infrastructure.app/domain/MsiInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/MsiInstaller.cs @@ -1,4 +1,4 @@ -// Copyright © 2011 - Present RealDimensions Software, LLC +// 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. @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace chocolatey.infrastructure.app.domain +namespace chocolatey.infrastructure.app.domain.installers { using System.Collections.Generic; diff --git a/src/chocolatey/infrastructure.app/domain/NsisInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/NsisInstaller.cs similarity index 84% rename from src/chocolatey/infrastructure.app/domain/NsisInstaller.cs rename to src/chocolatey/infrastructure.app/domain/installers/NsisInstaller.cs index 0d2e6e1a92..9747599f06 100644 --- a/src/chocolatey/infrastructure.app/domain/NsisInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/NsisInstaller.cs @@ -1,4 +1,4 @@ -// Copyright © 2011 - Present RealDimensions Software, LLC +// 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. @@ -13,7 +13,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -namespace chocolatey.infrastructure.app.domain +namespace chocolatey.infrastructure.app.domain.installers { using System.Collections.Generic; @@ -33,8 +33,8 @@ public NsisInstaller() SilentInstall = "/S"; NoReboot = ""; LogFile = ""; - // must come last and contain no quotes, even if there are spaces - CustomInstallLocation = "/D={0}".format_with(InstallTokens.CUSTOM_INSTALL_LOCATION); //must be last thing specified and no quotes + // must be last thing specified and contain no quotes, even if there are spaces + CustomInstallLocation = "/D={0}".format_with(InstallTokens.CUSTOM_INSTALL_LOCATION); Language = ""; OtherInstallOptions = ""; UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); diff --git a/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs b/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs index 568326a602..941d1559b3 100644 --- a/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs +++ b/src/chocolatey/infrastructure.app/services/AutomaticUninstallerService.cs @@ -22,6 +22,7 @@ namespace chocolatey.infrastructure.app.services using commandline; using configuration; using domain; + using domain.installers; using filesystem; using infrastructure.commands; using results; From d5cd67f8470a00ed32970b66caca515ed3d707bf Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Sat, 20 Feb 2016 11:50:41 -0600 Subject: [PATCH 2/4] (GH-641) Support for more installer types Added support for the following installer types - Ghost - InstallForJ - izPack --- src/chocolatey/chocolatey.csproj | 3 ++ .../domain/InstallerType.cs | 4 ++ .../domain/installers/GhostInstaller.cs | 54 +++++++++++++++++++ .../domain/installers/InstallForJInstaller.cs | 54 +++++++++++++++++++ .../domain/installers/IzPackInstaller.cs | 54 +++++++++++++++++++ .../domain/installers/NsisInstaller.cs | 2 +- 6 files changed, 170 insertions(+), 1 deletion(-) create mode 100644 src/chocolatey/infrastructure.app/domain/installers/GhostInstaller.cs create mode 100644 src/chocolatey/infrastructure.app/domain/installers/InstallForJInstaller.cs create mode 100644 src/chocolatey/infrastructure.app/domain/installers/IzPackInstaller.cs diff --git a/src/chocolatey/chocolatey.csproj b/src/chocolatey/chocolatey.csproj index 6684a347f8..a71a5f57f7 100644 --- a/src/chocolatey/chocolatey.csproj +++ b/src/chocolatey/chocolatey.csproj @@ -84,6 +84,9 @@ + + + diff --git a/src/chocolatey/infrastructure.app/domain/InstallerType.cs b/src/chocolatey/infrastructure.app/domain/InstallerType.cs index 725a960542..f5d72729ac 100644 --- a/src/chocolatey/infrastructure.app/domain/InstallerType.cs +++ b/src/chocolatey/infrastructure.app/domain/InstallerType.cs @@ -23,6 +23,10 @@ public enum InstallerType Nsis, InnoSetup, InstallShield, + Ghost, + InstallForJ, + IzPack, + Squirrel, Zip, SevenZip, HotfixOrSecurityUpdate, diff --git a/src/chocolatey/infrastructure.app/domain/installers/GhostInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/GhostInstaller.cs new file mode 100644 index 0000000000..07ad9cd1d8 --- /dev/null +++ b/src/chocolatey/infrastructure.app/domain/installers/GhostInstaller.cs @@ -0,0 +1,54 @@ +// 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; + + /// + /// Ghost Installer Options + /// + /// + /// http://www.ethalone.com/products.html / + /// https://web.archive.org/web/20070812133050/http://www.ethalone.com/cgi-bin/ib/ikonboard.cgi?act=ST;f=2;t=195 + /// Ghost has no logging or language options. The command line usage is very little. + /// + public class GhostInstaller : InstallerBase + { + public GhostInstaller() + { + InstallExecutable = "\"{0}\"".format_with(InstallTokens.INSTALLER_LOCATION); + SilentInstall = "-s"; + NoReboot = ""; + LogFile = ""; + CustomInstallLocation = ""; + Language = ""; + OtherInstallOptions = ""; + UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); + SilentUninstall = "-u -s"; + OtherUninstallOptions = ""; + ValidInstallExitCodes = new List + { + 0 + }; + ValidUninstallExitCodes = new List + { + 0 + }; + } + + public override InstallerType InstallerType { get { return InstallerType.Ghost; } } + } +} diff --git a/src/chocolatey/infrastructure.app/domain/installers/InstallForJInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/InstallForJInstaller.cs new file mode 100644 index 0000000000..dd76e850e7 --- /dev/null +++ b/src/chocolatey/infrastructure.app/domain/installers/InstallForJInstaller.cs @@ -0,0 +1,54 @@ +// 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; + + /// + /// InstallForJ Installer Options + /// + /// + /// https://www.ej-technologies.com/products/install4j/overview.html + /// http://resources.ej-technologies.com/install4j/help/doc/ + /// http://resources.ej-technologies.com/install4j/help/doc/helptopics/installers/options.html + /// + public class InstallForJInstaller : InstallerBase + { + public InstallForJInstaller() + { + InstallExecutable = "\"{0}\"".format_with(InstallTokens.INSTALLER_LOCATION); + SilentInstall = "-q"; + NoReboot = ""; + LogFile = ""; //logging is done automatically to i4j_nlog_* file in temp directory - http://resources.ej-technologies.com/install4j/help/doc/helptopics/installers/errors.html + CustomInstallLocation = "-dir \"{0}\"".format_with(InstallTokens.CUSTOM_INSTALL_LOCATION); + Language = ""; + OtherInstallOptions = "-overwrite"; // -wait 60 + UninstallExecutable = "\"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); + SilentUninstall = "-q"; + OtherUninstallOptions = ""; + ValidInstallExitCodes = new List + { + 0 + }; + ValidUninstallExitCodes = new List + { + 0 + }; + } + + public override InstallerType InstallerType { get { return InstallerType.InstallForJ; } } + } +} diff --git a/src/chocolatey/infrastructure.app/domain/installers/IzPackInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/IzPackInstaller.cs new file mode 100644 index 0000000000..9746aae255 --- /dev/null +++ b/src/chocolatey/infrastructure.app/domain/installers/IzPackInstaller.cs @@ -0,0 +1,54 @@ +// 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; + + /// + /// izPack Installer Options + /// + /// + /// http://izpack.org/ + /// https://izpack.atlassian.net/wiki/display/IZPACK/Installer+Runtime+Options + /// https://izpack.atlassian.net/wiki/display/IZPACK/Unattended+Installations + /// + public class IzPackInstaller : InstallerBase + { + public IzPackInstaller() + { + InstallExecutable = "java"; + SilentInstall = "-jar \"{0}\" -options-system".format_with(InstallTokens.INSTALLER_LOCATION); + NoReboot = ""; + LogFile = ""; + CustomInstallLocation = "-DINSTALL_PATH=\"{0}\"".format_with(InstallTokens.CUSTOM_INSTALL_LOCATION); + Language = ""; + OtherInstallOptions = ""; + UninstallExecutable = "java"; //currently untested + SilentUninstall = "-jar \"{0}\"".format_with(InstallTokens.UNINSTALLER_LOCATION); + OtherUninstallOptions = ""; + ValidInstallExitCodes = new List + { + 0 + }; + ValidUninstallExitCodes = new List + { + 0 + }; + } + + public override InstallerType InstallerType { get { return InstallerType.IzPack; } } + } +} diff --git a/src/chocolatey/infrastructure.app/domain/installers/NsisInstaller.cs b/src/chocolatey/infrastructure.app/domain/installers/NsisInstaller.cs index 9747599f06..419be1480e 100644 --- a/src/chocolatey/infrastructure.app/domain/installers/NsisInstaller.cs +++ b/src/chocolatey/infrastructure.app/domain/installers/NsisInstaller.cs @@ -1,4 +1,4 @@ -// Copyright © 2011 - Present RealDimensions Software, LLC +// 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. From 4a98050fd3f4942fdaa5e17f3d2db48a2c96e88b Mon Sep 17 00:00:00 2001 From: Rob Reynolds Date: Sat, 20 Feb 2016 18:01:01 -0600 Subject: [PATCH 3/4] (GH-642) Show bitness downloading msg when both 32/64 `Downloading packagename 32 bit` is confusing for some when they are on 64 bit Windows and want the 64 bit version. Many times there is only a 32 bit version available (which works fine), so the message shouldn't show unless there are both downloads available and the user has forced 32 bit or is on a 32 bit system. --- .../helpers/functions/Get-ChocolateyWebFile.ps1 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 b/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 index 011370d0e1..76201956a3 100644 --- a/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 +++ b/src/chocolatey.resources/helpers/functions/Get-ChocolateyWebFile.ps1 @@ -100,10 +100,12 @@ param( } Write-Debug "CPU is $bitWidth bit" - $bitPackage = 32 + $bitPackage = '' + if ($url32bit -ne $url64bit -and $url64bit -ne $null -and $url64bit -ne '') { $bitPackage = '32 bit' } + if ($bitWidth -eq 64 -and $url64bit -ne $null -and $url64bit -ne '') { Write-Debug "Setting url to '$url64bit' and bitPackage to $bitWidth" - $bitPackage = $bitWidth + $bitPackage = '64 bit' $url = $url64bit; # only set if urls are different if ($url32bit -ne $url64bit) { @@ -117,7 +119,7 @@ param( $forceX86 = $env:chocolateyForceX86; if ($forceX86) { Write-Debug "User specified -x86 so forcing 32 bit" - $bitPackage = 32 + if ($url32bit -ne $url64bit) { $bitPackage = '32 bit' } $url = $url32bit $checksum = $checksum32 $checksumType = $checksumType32 @@ -171,7 +173,7 @@ param( } if ($needsDownload) { - Write-Host "Downloading $packageName $bitPackage bit + Write-Host "Downloading $packageName $bitPackage from `'$url`'" Get-WebFile $url $fileFullPath -options $options } From 4c3c7c4bbdda2d2cdc2880d222aff1c098d6cab2 Mon Sep 17 00:00:00 2001 From: Tim Zenner Date: Thu, 25 Feb 2016 11:24:54 -0600 Subject: [PATCH 4/4] (GH-453) Adds exact filter option to choco list Previously there was no way to see only packages that match exactly what you searched for. --- src/chocolatey.tests.integration/Scenario.cs | 1 + .../chocolatey.tests.integration.csproj | 12 +++++ .../1.0.0/exactpackage.dontfind.nuspec | 18 +++++++ .../1.0.0/tools/purpose.txt | 1 + .../exactpackage/1.0.0/exactpackage.nuspec | 18 +++++++ .../exactpackage/1.0.0/tools/purpose.txt | 1 + .../scenarios/ListScenarios.cs | 48 +++++++++++++++++++ .../commands/ChocolateyListCommand.cs | 4 +- .../configuration/ChocolateyConfiguration.cs | 1 + .../infrastructure.app/nuget/NugetList.cs | 5 ++ 10 files changed, 108 insertions(+), 1 deletion(-) create mode 100644 src/chocolatey.tests.integration/context/exactpackage/exactpackage.dontfind/1.0.0/exactpackage.dontfind.nuspec create mode 100644 src/chocolatey.tests.integration/context/exactpackage/exactpackage.dontfind/1.0.0/tools/purpose.txt create mode 100644 src/chocolatey.tests.integration/context/exactpackage/exactpackage/1.0.0/exactpackage.nuspec create mode 100644 src/chocolatey.tests.integration/context/exactpackage/exactpackage/1.0.0/tools/purpose.txt diff --git a/src/chocolatey.tests.integration/Scenario.cs b/src/chocolatey.tests.integration/Scenario.cs index 3d43e5970a..a1b89ba823 100644 --- a/src/chocolatey.tests.integration/Scenario.cs +++ b/src/chocolatey.tests.integration/Scenario.cs @@ -128,6 +128,7 @@ private static ChocolateyConfiguration baseline_configuration() config.Verbose = false; config.Input = config.PackageNames = string.Empty; config.ListCommand.LocalOnly = false; + config.ListCommand.Exact = false; //config.Features.UsePowerShellHost = true; //config.Features.AutoUninstaller = true; //config.Features.CheckSumFiles = true; diff --git a/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj b/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj index 4decad22d0..b8a813b35a 100644 --- a/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj +++ b/src/chocolatey.tests.integration/chocolatey.tests.integration.csproj @@ -213,6 +213,12 @@ Always + + Always + + + Always + Always @@ -400,6 +406,12 @@ Always + + Always + + + Always + Always diff --git a/src/chocolatey.tests.integration/context/exactpackage/exactpackage.dontfind/1.0.0/exactpackage.dontfind.nuspec b/src/chocolatey.tests.integration/context/exactpackage/exactpackage.dontfind/1.0.0/exactpackage.dontfind.nuspec new file mode 100644 index 0000000000..3ad6903736 --- /dev/null +++ b/src/chocolatey.tests.integration/context/exactpackage/exactpackage.dontfind/1.0.0/exactpackage.dontfind.nuspec @@ -0,0 +1,18 @@ + + + + exactpackage.dontfind + 1.0.0 + exactpackage.dontfind + __REPLACE_AUTHORS_OF_SOFTWARE__ + __REPLACE_YOUR_NAME__ + false + __REPLACE__ + __REPLACE__ + + exactpackage.dontfind admin + + + + + \ No newline at end of file diff --git a/src/chocolatey.tests.integration/context/exactpackage/exactpackage.dontfind/1.0.0/tools/purpose.txt b/src/chocolatey.tests.integration/context/exactpackage/exactpackage.dontfind/1.0.0/tools/purpose.txt new file mode 100644 index 0000000000..ac790bf487 --- /dev/null +++ b/src/chocolatey.tests.integration/context/exactpackage/exactpackage.dontfind/1.0.0/tools/purpose.txt @@ -0,0 +1 @@ +when running choco list exactpackage -e, this package should not be returned. \ No newline at end of file diff --git a/src/chocolatey.tests.integration/context/exactpackage/exactpackage/1.0.0/exactpackage.nuspec b/src/chocolatey.tests.integration/context/exactpackage/exactpackage/1.0.0/exactpackage.nuspec new file mode 100644 index 0000000000..0b1212417c --- /dev/null +++ b/src/chocolatey.tests.integration/context/exactpackage/exactpackage/1.0.0/exactpackage.nuspec @@ -0,0 +1,18 @@ + + + + exactpackage + 1.0.0 + exactpackage + __REPLACE_AUTHORS_OF_SOFTWARE__ + __REPLACE_YOUR_NAME__ + false + __REPLACE__ + __REPLACE__ + + exactpackage admin + + + + + \ No newline at end of file diff --git a/src/chocolatey.tests.integration/context/exactpackage/exactpackage/1.0.0/tools/purpose.txt b/src/chocolatey.tests.integration/context/exactpackage/exactpackage/1.0.0/tools/purpose.txt new file mode 100644 index 0000000000..ee8c252de9 --- /dev/null +++ b/src/chocolatey.tests.integration/context/exactpackage/exactpackage/1.0.0/tools/purpose.txt @@ -0,0 +1 @@ +when running choco list exactpackage -e, this is the only package that should be returned. \ No newline at end of file diff --git a/src/chocolatey.tests.integration/scenarios/ListScenarios.cs b/src/chocolatey.tests.integration/scenarios/ListScenarios.cs index f6289eb948..4920694b5b 100644 --- a/src/chocolatey.tests.integration/scenarios/ListScenarios.cs +++ b/src/chocolatey.tests.integration/scenarios/ListScenarios.cs @@ -370,5 +370,53 @@ public void should_not_list_any_packages() } } + + [Concern(typeof(ChocolateyListCommand))] + public class when_searching_for_an_exact_package : ScenariosBase + { + public override void Context() + { + Configuration = Scenario.list(); + Scenario.reset(Configuration); + Scenario.add_packages_to_source_location(Configuration, "exactpackage*" + Constants.PackageExtension); + Service = NUnitSetup.Container.GetInstance(); + + Configuration.ListCommand.Exact = true; + Configuration.Input = Configuration.PackageNames = "exactpackage"; + } + + public override void Because() + { + MockLogger.reset(); + Results = Service.list_run(Configuration).ToList(); + } + + [Fact] + public void should_contain_packages_and_versions_with_a_space_between_them() + { + MockLogger.contains_message("exactpackage 1.0.0").ShouldBeTrue(); + } + + [Fact] + public void should_not_contain_packages_that_do_not_match() + { + MockLogger.contains_message("exactpackage.dontfind").ShouldBeFalse(); + } + + [Fact] + public void should_contain_a_summary() + { + MockLogger.contains_message("packages found").ShouldBeTrue(); + } + + [Fact] + public void should_contain_debugging_messages() + { + MockLogger.contains_message("Searching for package information", LogLevel.Debug).ShouldBeTrue(); + MockLogger.contains_message("Running list with the following filter", LogLevel.Debug).ShouldBeTrue(); + MockLogger.contains_message("Start of List", LogLevel.Debug).ShouldBeTrue(); + MockLogger.contains_message("End of List", LogLevel.Debug).ShouldBeTrue(); + } + } } } diff --git a/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs b/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs index c290930bd4..5487230860 100644 --- a/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs +++ b/src/chocolatey/infrastructure.app/commands/ChocolateyListCommand.cs @@ -78,8 +78,10 @@ public virtual void configure_argument_parser(OptionSet optionSet, ChocolateyCon .Add("page-size=", "Page Size - the amount of package results to return per page. Defaults to 25.", option => configuration.ListCommand.PageSize = int.Parse(option)) + .Add("e|exact", + "Exact - Only return packages with this exact name.", + option => configuration.ListCommand.Exact = option != null) ; - //todo exact name } public virtual void handle_additional_argument_parsing(IList unparsedArguments, ChocolateyConfiguration configuration) diff --git a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs index 43d25765d6..929eeaba2a 100644 --- a/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs +++ b/src/chocolatey/infrastructure.app/configuration/ChocolateyConfiguration.cs @@ -355,6 +355,7 @@ public ListCommandConfiguration() public bool IncludeRegistryPrograms { get; set; } public int? Page { get; set; } public int PageSize { get; set; } + public bool Exact { get; set; } } [Serializable] diff --git a/src/chocolatey/infrastructure.app/nuget/NugetList.cs b/src/chocolatey/infrastructure.app/nuget/NugetList.cs index b3125d0da3..8b740f915b 100644 --- a/src/chocolatey/infrastructure.app/nuget/NugetList.cs +++ b/src/chocolatey/infrastructure.app/nuget/NugetList.cs @@ -93,6 +93,11 @@ private static IQueryable execute_package_search(ChocolateyConfigurati results = results.Skip(configuration.ListCommand.PageSize * configuration.ListCommand.Page.Value).Take(configuration.ListCommand.PageSize); } + if (configuration.ListCommand.Exact) + { + results = results.Where(p => p.Id == configuration.Input); + } + return results.OrderBy(p => p.Id); }