Ticket #913: up2date.patch
| File up2date.patch, 2.6 kB (added by jdreese, 1 year ago) |
|---|
-
a/lib/puppet/provider/package/up2date.rb
old new 2 2 desc "Support for Red Hat's proprietary ``up2date`` package update 3 3 mechanism." 4 4 5 commands :up2date => "/usr/sbin/up2date-nox" 5 commands :up2date => "/usr/sbin/up2date-nox", :python => "python" 6 6 defaultfor :operatingsystem => :redhat, 7 7 :lsbdistrelease => ["2.1", "3", "4"] 8 8 confine :operatingsystem => :redhat 9 9 10 UP2DATEHELPER = File::join(File::dirname(__FILE__), "up2datehelper.py") 11 12 class << self 13 attr_reader :updates 14 end 15 10 16 # Install a package using 'up2date'. 11 17 def install 12 18 up2date "-u", @resource[:name] … … 20 26 21 27 # What's the latest package version available? 22 28 def latest 23 #up2date can only get a list of *all* available packages? 24 output = up2date "--showall" 25 26 if output =~ /^#{@resource[:name]}-(\d+.*)\.\w+/ 27 return $1 29 upd = self.class.updates[@resource[:name]] 30 unless upd.nil? 31 # FIXME: there could be more than one update for a package 32 # because of multiarch 33 upd = upd[0] 34 return "#{upd[:version]}-#{upd[:release]}" 28 35 else 29 36 # up2date didn't find updates, pretend the current 30 37 # version is the latest 31 return @property_hash[:ensure] 38 if properties[:ensure] == :absent 39 raise Puppet::DevError, "Tried to get latest on a missing package" 40 end 41 return properties[:ensure] 32 42 end 33 43 end 34 44 45 35 46 def update 36 47 # Install in up2date can be used for update, too 37 48 self.install 38 49 end 50 51 def self.prefetch(packages) 52 @updates = {} 53 if Process.euid != 0 54 raise Puppet::Error, "The up2date provider can only be used as root" 55 end 56 super 57 python(UP2DATEHELPER).each_line do |l| 58 l.chomp! 59 next if l.empty? 60 if l[0,4] == "_pkg" 61 hash = nevra_to_hash(l[5..-1]) 62 [hash[:name], "#{hash[:name]}.#{hash[:arch]}"].each do |n| 63 @updates[n] ||= [] 64 @updates[n] << hash 65 end 66 end 67 end 68 end 69 39 70 end 40 71