summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Smith <tsmith@chef.io>2018-03-19 09:57:06 -0700
committerTim Smith <tsmith@chef.io>2018-03-19 15:27:20 -0700
commit2955a93b0f35b1b89ec50b92be4e5127b1e9c12f (patch)
treed12a00189ac48b9617137c1ffb25a1ee6555bd5a
parent4e6c7972620e68753946abe109895762a6301efd (diff)
downloadchef-2955a93b0f35b1b89ec50b92be4e5127b1e9c12f.tar.gz
Detect new "automatically" installed string in Zypper
This resolves issue #6836 which explains the issue in great detail. TLDR: Packages that are installed as deps on another package have a different string when you get info on them now. This updates the regex to detect both. Based on the zypper changelog I believe this was introduced in 1.13.17. Signed-off-by: Tim Smith <tsmith@chef.io>
-rw-r--r--lib/chef/provider/package/zypper.rb2
-rw-r--r--spec/unit/provider/package/zypper_spec.rb8
2 files changed, 9 insertions, 1 deletions
diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb
index f12fa270ac..5cd2471f96 100644
--- a/lib/chef/provider/package/zypper.rb
+++ b/lib/chef/provider/package/zypper.rb
@@ -41,7 +41,7 @@ class Chef
when /^Version *: (.+) *$/
candidate_version = $1.strip
Chef::Log.debug("#{new_resource} version #{candidate_version}")
- when /^Installed *: Yes *$/
+ when /^Installed *: Yes *(\(automatically\))?$/ # http://rubular.com/r/qhPeO6vP9h
is_installed = true
Chef::Log.debug("#{new_resource} is installed")
when /^Status *: out-of-date \(version (.+) installed\) *$/
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index 598fedc9fa..3f172dc370 100644
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -88,6 +88,14 @@ describe Chef::Provider::Package::Zypper do
provider.load_current_resource
end
+ it "should set the installed version if zypper info has one (zypper version >= 1.13.17)" do
+ status = double(:stdout => "Version : 1.0\nInstalled : Yes (automatically)\n", :exitstatus => 0)
+
+ allow(provider).to receive(:shell_out!).and_return(status)
+ expect(current_resource).to receive(:version).with(["1.0"]).and_return(true)
+ provider.load_current_resource
+ end
+
it "should set the candidate version if zypper info has one (zypper version < 1.13.0)" do
status = double(:stdout => "Version: 1.0\nInstalled: No\nStatus: out-of-date (version 0.9 installed)", :exitstatus => 0)