[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, experimental, updated. debian/2.6.8-1-844-g7ec39d5
Matt Robinson
matt at puppetlabs.com
Tue May 10 08:02:22 UTC 2011
The following commit has been merged in the experimental branch:
commit 9ccd29f3aacdab03f2ea9a693b5bca928439683b
Author: Dan Bode <bodepd at gmail.com>
Date: Tue Sep 7 18:06:09 2010 -0400
(#2866) yum should support downgrade.
patch originally from Grzegorz Nosek with contributions on
the test from Oliver Hookins.
checks if the current version is greater than the should
version, if so, calls yum downgrade.
Reviewed-by: Matt Robinson
diff --git a/lib/puppet/provider/package/yum.rb b/lib/puppet/provider/package/yum.rb
index fcda5ba..6ed966f 100755
--- a/lib/puppet/provider/package/yum.rb
+++ b/lib/puppet/provider/package/yum.rb
@@ -1,3 +1,4 @@
+require 'puppet/util/package'
Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
desc "Support via `yum`."
@@ -52,6 +53,7 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
should = @resource.should(:ensure)
self.debug "Ensuring => #{should}"
wanted = @resource[:name]
+ operation = :install
# XXX: We don't actually deal with epochs here.
case should
@@ -61,9 +63,14 @@ Puppet::Type.type(:package).provide :yum, :parent => :rpm, :source => :rpm do
else
# Add the package version
wanted += "-#{should}"
+ is = self.query
+ if is && Puppet::Util::Package.versioncmp(should, is[:ensure]) < 0
+ self.debug "Downgrading package #{@resource[:name]} from version #{is[:ensure]} to #{should}"
+ operation = :downgrade
+ end
end
- output = yum "-d", "0", "-e", "0", "-y", :install, wanted
+ output = yum "-d", "0", "-e", "0", "-y", operation, wanted
is = self.query
raise Puppet::Error, "Could not find package #{self.name}" unless is
diff --git a/spec/unit/provider/package/yum_spec.rb b/spec/unit/provider/package/yum_spec.rb
index 09c81f7..f6a99aa 100644
--- a/spec/unit/provider/package/yum_spec.rb
+++ b/spec/unit/provider/package/yum_spec.rb
@@ -31,21 +31,27 @@ describe provider do
@provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :install, 'mypackage')
@provider.install
end
- it "should use :install to update" do
+ it 'should use :install to update' do
@provider.expects(:install)
@provider.update
end
- it "should be able to set version" do
- @resource.stubs(:should).with(:ensure).returns "1.2"
+ it 'should be able to set version' do
+ @resource.stubs(:should).with(:ensure).returns '1.2'
@provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :install, 'mypackage-1.2')
- @provider.stubs(:query).returns :ensure => '1.2'
+ @provider.stubs(:query).returns :ensure => '1.2'
+ @provider.install
+ end
+ it 'should be able to downgrade' do
+ @resource.stubs(:should).with(:ensure).returns '1.0'
+ @provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :downgrade, 'mypackage-1.0')
+ @provider.stubs(:query).returns(:ensure => '1.2').then.returns(:ensure => '1.0')
@provider.install
end
end
describe 'when uninstalling' do
- it "should use erase to purge" do
- @provider.expects(:yum).with("-y", :erase, 'mypackage')
+ it 'should use erase to purge' do
+ @provider.expects(:yum).with('-y', :erase, 'mypackage')
@provider.purge
end
it 'should use rpm to uninstall' do
@@ -54,7 +60,7 @@ describe provider do
end
end
- it "should be versionable" do
+ it 'should be versionable' do
provider.should be_versionable
end
end
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list