diff options
author | Irving Popovetsky <irving@getchef.com> | 2015-09-29 10:28:41 -0700 |
---|---|---|
committer | Irving Popovetsky <irving@getchef.com> | 2015-09-29 10:28:41 -0700 |
commit | 2e75d4f6551fa7307931a78123712205738454b2 (patch) | |
tree | a638720c7f269837202f977d69ce8c7feeb780bb | |
parent | e43ddf5a0f6ec3e6df9d34195e7c0833c38dd05e (diff) | |
parent | 63fc5c29927cd94f98c350b678cfe931d116bcdd (diff) | |
download | chef-2e75d4f6551fa7307931a78123712205738454b2.tar.gz |
Merge pull request #3985 from chef/irving/issue3671
Simplify the regex which determines the rpm version to resolve issue #3671
-rw-r--r-- | CHANGELOG.md | 1 | ||||
-rw-r--r-- | lib/chef/provider/package/rpm.rb | 4 | ||||
-rw-r--r-- | spec/unit/provider/package/rpm_spec.rb | 19 |
3 files changed, 21 insertions, 3 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c83dbed88..251b68e50e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -39,6 +39,7 @@ of partial templates. * [**Joel Handwell**](https://github.com/joelhandwell): [pr#3821](https://github.com/chef/chef/pull/3821) Human friendly elapsed time in log +* [pr#3985](https://github.com/chef/chef/pull/3985) Simplify the regex which determines the rpm version to resolve issue #3671 * [pr#3928](https://github.com/chef/chef/pull/3928) Add named run list support when using policyfiles * [pr#3913](https://github.com/chef/chef/pull/3913) Add `policy_name`and `policy_group` fields to the node object * [pr#3875](https://github.com/chef/chef/pull/3875) Patch Win32::Registry#delete_key, #delete_value to use wide (W) APIs diff --git a/lib/chef/provider/package/rpm.rb b/lib/chef/provider/package/rpm.rb index c5d52a8384..6ce0dd689f 100644 --- a/lib/chef/provider/package/rpm.rb +++ b/lib/chef/provider/package/rpm.rb @@ -61,7 +61,7 @@ class Chef Chef::Log.debug("#{@new_resource} checking rpm status") shell_out_with_timeout!("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' #{@new_resource.source}").stdout.each_line do |line| case line - when /^([\w\d+_.-]+)\s([\w\d~_.-]+)$/ + when /^(\S+)\s(\S+)$/ @current_resource.package_name($1) @new_resource.version($2) @candidate_version = $2 @@ -78,7 +78,7 @@ class Chef @rpm_status = shell_out_with_timeout("rpm -q --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' #{@current_resource.package_name}") @rpm_status.stdout.each_line do |line| case line - when /^([\w\d+_.-]+)\s([\w\d~_.-]+)$/ + when /^(\S+)\s(\S+)$/ Chef::Log.debug("#{@new_resource} current version is #{$2}") @current_resource.version($2) end diff --git a/spec/unit/provider/package/rpm_spec.rb b/spec/unit/provider/package/rpm_spec.rb index e0e45d0b4f..ad9d694e34 100644 --- a/spec/unit/provider/package/rpm_spec.rb +++ b/spec/unit/provider/package/rpm_spec.rb @@ -256,6 +256,24 @@ describe Chef::Provider::Package::Rpm do end end + context "when the package name contains a plus symbol (chef#3671)" do + + let(:package_name) { "chef-server-core" } + + let(:package_source) { "/tmp/chef-server-core-12.2.0+20150713220422-1.el6.x86_64.rpm" } + + let(:rpm_qp_stdout) { "chef-server-core 12.2.0+20150713220422-1.el6" } + let(:rpm_q_stdout) { "chef-server-core 12.2.0+20150713220422-1.el6" } + + let(:rpm_qp_exitstatus) { 0 } + let(:rpm_q_exitstatus) { 0 } + + it "should correctly determine the candidate version and installed version" do + expect(provider.current_resource.package_name).to eq("chef-server-core") + expect(provider.new_resource.version).to eq("12.2.0+20150713220422-1.el6") + end + end + end context "when the source is given as an URI" do @@ -413,4 +431,3 @@ describe Chef::Provider::Package::Rpm do end - |