diff options
author | Bryan McLellan <btm@loftninjas.org> | 2016-10-27 11:40:13 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-27 11:40:13 -0400 |
commit | 49e533cb6dd5b289bcb4322c9dd5ea216ec72e4c (patch) | |
tree | 82e57aa19ab2cb7b916576d61a848cf919a061bf | |
parent | 95dd383a6059d896e5c587b6a6eb65195e144a28 (diff) | |
parent | 3f02906527c164b6119635237ebea9230eaa5581 (diff) | |
download | chef-49e533cb6dd5b289bcb4322c9dd5ea216ec72e4c.tar.gz |
Merge pull request #5394 from MsysTechnologiesllc/ali/package_resource_uninstall_fix
Newly creating uninstall string using the product code value retrieved from the uninstall_string of the Windows registry to avoid using invalid uninstall_string.
-rw-r--r-- | lib/chef/provider/package/windows/msi.rb | 5 | ||||
-rw-r--r-- | spec/unit/provider/package/windows/msi_spec.rb | 17 |
2 files changed, 16 insertions, 6 deletions
diff --git a/lib/chef/provider/package/windows/msi.rb b/lib/chef/provider/package/windows/msi.rb index 96c6728ef4..ee3b2f7e8e 100644 --- a/lib/chef/provider/package/windows/msi.rb +++ b/lib/chef/provider/package/windows/msi.rb @@ -79,9 +79,10 @@ class Chef uninstall_version = new_resource.version || installed_version uninstall_entries.select { |entry| [uninstall_version].flatten.include?(entry.display_version) } .map { |version| version.uninstall_string }.uniq.each do |uninstall_string| - Chef::Log.debug("#{new_resource} removing MSI package version using '#{uninstall_string}'") + uninstall_string = "msiexec /x #{uninstall_string.match(/{.*}/)}" uninstall_string += expand_options(new_resource.options) - uninstall_string += " /Q" unless uninstall_string =~ / \/Q\b/ + uninstall_string += " /q" unless uninstall_string.downcase =~ / \/q/ + Chef::Log.debug("#{new_resource} removing MSI package version using '#{uninstall_string}'") shell_out!(uninstall_string, { :timeout => new_resource.timeout, :returns => new_resource.returns }) end end diff --git a/spec/unit/provider/package/windows/msi_spec.rb b/spec/unit/provider/package/windows/msi_spec.rb index e29508ca7b..c8099c38d0 100644 --- a/spec/unit/provider/package/windows/msi_spec.rb +++ b/spec/unit/provider/package/windows/msi_spec.rb @@ -121,7 +121,7 @@ describe Chef::Provider::Package::Windows::MSI do end it "removes installed package" do - expect(provider).to receive(:shell_out!).with(/MsiExec.exe \/X{guid} \/Q/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid} \/q/, kind_of(Hash)) provider.remove_package end @@ -140,8 +140,8 @@ describe Chef::Provider::Package::Windows::MSI do end it "removes both installed package" do - expect(provider).to receive(:shell_out!).with(/MsiExec.exe \/X{guid} \/Q/, kind_of(Hash)) - expect(provider).to receive(:shell_out!).with(/MsiExec.exe \/X{guid2} \/Q/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid} \/q/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid2} \/q/, kind_of(Hash)) provider.remove_package end end @@ -150,7 +150,16 @@ describe Chef::Provider::Package::Windows::MSI do before { new_resource.options("/Q") } it "does not duplicate quiet switch" do - expect(provider).to receive(:shell_out!).with(/MsiExec.exe \/X{guid} \/Q/, kind_of(Hash)) + expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid} \/Q/, kind_of(Hash)) + provider.remove_package + end + end + + context "custom options includes /qn" do + before { new_resource.options("/qn") } + + it "does not duplicate quiet switch" do + expect(provider).to receive(:shell_out!).with(/msiexec \/x {guid} \/qn/, kind_of(Hash)) provider.remove_package end end |