diff options
author | Adam Jacob <adam@opscode.com> | 2010-02-26 15:57:38 -0800 |
---|---|---|
committer | Adam Jacob <adam@opscode.com> | 2010-02-26 15:57:38 -0800 |
commit | ee65c8eccbad3e14c37276b0ba30b1a49f3a05e3 (patch) | |
tree | e68368524d218213893a202aa0f72e66f8cb6713 | |
parent | 02cae6853b7b0fd8fc50871371f4ec947631827f (diff) | |
parent | f3196a615e4c12e809a9e572549efebdbb24c289 (diff) | |
download | chef-ee65c8eccbad3e14c37276b0ba30b1a49f3a05e3.tar.gz |
Merge branch 'CHEF-987' of git://github.com/thommay/chef into thommay/CHEF-987
-rw-r--r-- | chef/lib/chef/provider/package/yum.rb | 29 | ||||
-rw-r--r-- | chef/spec/unit/provider/package/yum_spec.rb | 24 |
2 files changed, 45 insertions, 8 deletions
diff --git a/chef/lib/chef/provider/package/yum.rb b/chef/lib/chef/provider/package/yum.rb index df238204e5..c1cbb6f5d1 100644 --- a/chef/lib/chef/provider/package/yum.rb +++ b/chef/lib/chef/provider/package/yum.rb @@ -115,6 +115,23 @@ class Chef @current_resource = Chef::Resource::Package.new(@new_resource.name) @current_resource.package_name(@new_resource.package_name) + if @new_resource.source + unless ::File.exists?(@new_resource.source) + raise Chef::Exceptions::Package, "Package #{@new_resource.name} not found: #{@new_resource.source}" + end + + Chef::Log.debug("Checking rpm status for #{@new_resource.package_name}") + status = popen4("rpm -qp --queryformat '%{NAME} %{VERSION}-%{RELEASE}\n' #{@new_resource.source}") do |pid, stdin, stdout, stderr| + stdout.each do |line| + case line + when /([\w\d_.-]+)\s([\w\d_.-]+)/ + @current_resource.package_name($1) + @new_resource.version($2) + end + end + end + end + Chef::Log.debug("Checking yum info for #{@new_resource.package_name}") @yum.refresh @@ -133,9 +150,15 @@ class Chef end def install_package(name, version) - run_command_with_systems_locale( - :command => "yum -d0 -e0 -y install #{name}-#{version}" - ) + if @new_resource.source + run_command_with_systems_locale( + :command => "yum -d0 -e0 -y localinstall #{@new_resource.source}" + ) + else + run_command_with_systems_locale( + :command => "yum -d0 -e0 -y install #{name}-#{version}" + ) + end @yum.flush end diff --git a/chef/spec/unit/provider/package/yum_spec.rb b/chef/spec/unit/provider/package/yum_spec.rb index fab5d3baa1..2b8cc7ea94 100644 --- a/chef/spec/unit/provider/package/yum_spec.rb +++ b/chef/spec/unit/provider/package/yum_spec.rb @@ -26,7 +26,8 @@ describe Chef::Provider::Package::Yum, "load_current_resource" do :name => "cups", :version => nil, :package_name => "cups", - :updated => nil + :updated => nil, + :source => nil ) @current_resource = mock("Chef::Resource::Package", :null_object => true, @@ -90,7 +91,8 @@ describe Chef::Provider::Package::Yum, "install_package" do :name => "emacs", :version => nil, :package_name => "emacs", - :updated => nil + :updated => nil, + :source => nil ) @yum_cache = mock( 'Chef::Provider::Yum::YumCache', @@ -109,6 +111,15 @@ describe Chef::Provider::Package::Yum, "install_package" do }) @provider.install_package("emacs", "1.0") end + + it "should run yum localinstall if given a path to an rpm" do + @new_resource.stub!(:source).and_return("/tmp/emacs-21.4-20.el5.i386.rpm") + @provider.should_receive(:run_command_with_systems_locale).with({ + :command => "yum -d0 -e0 -y localinstall /tmp/emacs-21.4-20.el5.i386.rpm" + }) + @provider.install_package("emacs", "21.4-20.el5") + end + end describe Chef::Provider::Package::Yum, "upgrade_package" do @@ -120,7 +131,8 @@ describe Chef::Provider::Package::Yum, "upgrade_package" do :name => "emacs", :version => nil, :package_name => "emacs", - :updated => nil + :updated => nil, + :source => nil ) @yum_cache = mock( 'Chef::Provider::Yum::YumCache', @@ -173,7 +185,8 @@ describe Chef::Provider::Package::Yum, "remove_package" do :name => "emacs", :version => nil, :package_name => "emacs", - :updated => nil + :updated => nil, + :source => nil ) @yum_cache = mock( 'Chef::Provider::Yum::YumCache', @@ -202,7 +215,8 @@ describe Chef::Provider::Package::Yum, "purge_package" do :name => "emacs", :version => "10", :package_name => "emacs", - :updated => nil + :updated => nil, + :source => nil ) @yum_cache = mock( 'Chef::Provider::Yum::YumCache', |