diff options
author | Adam Jacob <adam@opscode.com> | 2010-02-26 15:52:22 -0800 |
---|---|---|
committer | Adam Jacob <adam@opscode.com> | 2010-02-26 15:52:22 -0800 |
commit | b6f1b78c6e40c67d6a46f4edd691ab1a83996c0e (patch) | |
tree | ff63240839e6c11a39e2f54a32be9bf14c2591dd | |
parent | 9f9b147d2cd1922c66f55e85ac19d00254c3c424 (diff) | |
parent | 90f156ba97205280344df9ea32e87ad50d14ad81 (diff) | |
download | chef-b6f1b78c6e40c67d6a46f4edd691ab1a83996c0e.tar.gz |
Merge branch 'CHEF-986' of git://github.com/thommay/chef into thommay/CHEF-986
-rw-r--r-- | chef/lib/chef/provider/package/rpm.rb | 18 | ||||
-rw-r--r-- | chef/spec/unit/provider/package/rpm_spec.rb | 9 |
2 files changed, 19 insertions, 8 deletions
diff --git a/chef/lib/chef/provider/package/rpm.rb b/chef/lib/chef/provider/package/rpm.rb index 2257b14592..0aebe5fbc0 100644 --- a/chef/lib/chef/provider/package/rpm.rb +++ b/chef/lib/chef/provider/package/rpm.rb @@ -69,16 +69,18 @@ class Chef end def install_package(name, version) - run_command_with_systems_locale( - :command => "rpm -i #{@new_resource.source}" - ) + unless @current_resource.version + run_command_with_systems_locale( + :command => "rpm -i #{@new_resource.source}" + ) + else + run_command_with_systems_locale( + :command => "rpm -U #{@new_resource.source}" + ) + end end - def upgrade_package(name, version) - run_command_with_systems_locale( - :command => "rpm -U #{@new_resource.source}" - ) - end + alias_method :upgrade_package, :install_package def remove_package(name, version) if version diff --git a/chef/spec/unit/provider/package/rpm_spec.rb b/chef/spec/unit/provider/package/rpm_spec.rb index fea096033a..43b1bcc187 100644 --- a/chef/spec/unit/provider/package/rpm_spec.rb +++ b/chef/spec/unit/provider/package/rpm_spec.rb @@ -110,7 +110,15 @@ describe Chef::Provider::Package::Rpm, "install and upgrade" do :updated => nil, :source => "/tmp/emacs-21.4-20.el5.i386.rpm" ) + @current_resource = mock("Chef::Resource::Package", + :null_object => true, + :name => "emacs", + :version => nil, + :package_name => nil, + :updated => nil + ) @provider = Chef::Provider::Package::Rpm.new(@node, @new_resource) + @provider.current_resource = @current_resource end it "should run rpm -i with the package source to install" do @@ -121,6 +129,7 @@ describe Chef::Provider::Package::Rpm, "install and upgrade" do end it "should run rpm -U with the package source to upgrade" do + @current_resource.stub!(:version).and_return("21.4-19.el5") @provider.should_receive(:run_command_with_systems_locale).with({ :command => "rpm -U /tmp/emacs-21.4-20.el5.i386.rpm" }) |