Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(#8062) Consider package epoch version when comparing yum package versions #224

Merged
merged 1 commit into from
Dec 13, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions lib/puppet/provider/package/yum.rb
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def install
wanted = @resource[:name]
operation = :install

# XXX: We don't actually deal with epochs here.
case should
when true, false, Symbol
# pass
Expand Down Expand Up @@ -87,7 +86,7 @@ def latest
unless upd.nil?
# FIXME: there could be more than one update for a package
# because of multiarch
return "#{upd[:version]}-#{upd[:release]}"
return "#{upd[:epoch]}:#{upd[:version]}-#{upd[:release]}"
else
# Yum didn't find updates, pretend the current
# version is the latest
Expand Down
46 changes: 45 additions & 1 deletion spec/unit/provider/package/yum_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@
@provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :install, 'mypackage')
@provider.install
end

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'
@provider.expects(:yum).with('-d', '0', '-e', '0', '-y', :install, 'mypackage-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')
Expand All @@ -53,6 +56,7 @@
@provider.expects(:yum).with('-y', :erase, 'mypackage')
@provider.purge
end

it 'should use rpm to uninstall' do
@provider.expects(:rpm).with('-e', 'mypackage-1-1.i386')
@provider.uninstall
Expand All @@ -62,5 +66,45 @@
it 'should be versionable' do
provider.should be_versionable
end
end

describe '#latest' do
describe 'when latest_info is nil' do
before :each do
@provider.stubs(:latest_info).returns(nil)
end

it 'raises if ensure is absent and latest_info is nil' do
@provider.stubs(:properties).returns({:ensure => :absent})

expect { @provider.latest }.to raise_error(
Puppet::DevError,
'Tried to get latest on a missing package'
)
end

it 'returns the ensure value if the package is not already installed' do
@provider.stubs(:properties).returns({:ensure => '3.4.5'})

@provider.latest.should == '3.4.5'
end
end

describe 'when latest_info is populated' do
before :each do
@provider.stubs(:latest_info).returns({
:name => 'mypackage',
:epoch => '1',
:version => '2.3.4',
:release => '5',
:arch => 'i686',
:provider => :yum,
:ensure => '2.3.4-5'
})
end

it 'includes the epoch in the version string' do
@provider.latest.should == '1:2.3.4-5'
end
end
end
end