diff options
author | David Lutterkort <dlutter@redhat.com> | 2007-12-17 17:59:12 -0800 |
---|---|---|
committer | David Lutterkort <dlutter@redhat.com> | 2007-12-17 17:59:12 -0800 |
commit | c22a584cbc80f502af7ddcd493114cb9c01f9cb8 (patch) | |
tree | 7966dbfddd08c8013a13e22ac896442986461239 /lib | |
parent | 4de2e2c67f606c4c115171cbbe0e68d7e9cd4d52 (diff) | |
download | puppet-c22a584cbc80f502af7ddcd493114cb9c01f9cb8.tar.gz puppet-c22a584cbc80f502af7ddcd493114cb9c01f9cb8.tar.xz puppet-c22a584cbc80f502af7ddcd493114cb9c01f9cb8.zip |
Uninstalling packages through 'ensure => absent' works again for the rpm and yum providers.
Before, 'rpm -e' was called without a package name. The code now makes sure
that 'rpm -e' gets exactly one package to uninstall on each invocation,
since rpm gets grumpy otherwise (besides passing the correct package NVR,
of course).
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/puppet/provider/package/rpm.rb | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/lib/puppet/provider/package/rpm.rb b/lib/puppet/provider/package/rpm.rb index 4af299283..98ca1efa6 100755 --- a/lib/puppet/provider/package/rpm.rb +++ b/lib/puppet/provider/package/rpm.rb @@ -92,6 +92,19 @@ Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Pr end def uninstall + query unless get(:arch) + nvr = "#{get(:name)}-#{get(:version)}-#{get(:release)}" + arch = ".#{get(:arch)}" + # If they specified an arch in the manifest, erase that Otherwise, + # erase the arch we got back from the query. If multiple arches are + # installed and only the package name is specified (without the + # arch), this will uninstall all of them on successive runs of the + # client, one after the other + if @resource[:name][-arch.size, arch.size] == arch + nvr += arch + else + nvr += ".#{get(:arch)}" + end rpm "-e", nvr end @@ -99,11 +112,6 @@ Puppet::Type.type(:package).provide :rpm, :source => :rpm, :parent => Puppet::Pr self.install end - def nvr - query unless @nvr - @nvr - end - def self.nevra_to_hash(line) line.chomp! hash = {} |