Resending per request by James Turnbull.
This patch adds support for specifying the arch for the up2date provider
that is consistent with that of yum, where you can specify package.arch.
In this case, the arch is split off the end if it matches one of the
supported archs on the system and is appended to the up2date command using
the --arch option.
In addition to this, I uncovered a rare bug whereby a blank line passed
into nevra_to_hash() in the rpm provider code caused odd problems, the
solution being to check for it and return an empty hash. Not sure if that
had ever been reported before, but it's fixed now.
Also available at my github: git://github.com/jimi1283/puppet.git
---
lib/puppet/provider/package/rpm.rb | 3 +++
lib/puppet/provider/package/up2date.rb | 24 +++++++++++++++++++++++-
2 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/lib/puppet/provider/package/rpm.rb
b/lib/puppet/provider/package/rpm.rb
index 72dc260..b12a648 100755
--- a/lib/puppet/provider/package/rpm.rb
+++ b/lib/puppet/provider/package/rpm.rb
@@ -123,6 +123,9 @@ Puppet::Type.type(:package).provide :rpm, :source =>
:rpm, :parent => Puppet::Pr
def self.nevra_to_hash(line)
line.chomp!
hash = {}
+ if line == ""
+ return hash
+ end
NEVRA_FIELDS.zip(line.split) { |f, v| hash[f] = v }
hash[:provider] = self.name
hash[:ensure] = "#{hash[:version]}-#{hash[:release]}"
diff --git a/lib/puppet/provider/package/up2date.rb
b/lib/puppet/provider/package/up2date.rb
index 243bc6c..556f459 100644
--- a/lib/puppet/provider/package/up2date.rb
+++ b/lib/puppet/provider/package/up2date.rb
@@ -11,7 +11,29 @@ Puppet::Type.type(:package).provide :up2date, :parent =>
:rpm, :source => :rpm d
# Install a package using 'up2date'.
def install
- up2date "-u", @resource[:name]
+ archs = []
+ begin
+ execpipe("#{command(:rpm)} --showrc | grep '^compatible arch'") {
|output|
+ # output is 'compatible arch : arch arch arch arch...'
+ # there should only be one line, but just in case we loop
+ output.each { |line|
+ # Split up the line after the : on spaces and append to the
archs list
+ items = line.split(":")[1].split()
+ items.each { |item|
+ archs << item
+ }
+ }
+ }
+ rescue Puppet::ExecutionFailure
+ raise Puppet::Error, "Failed to list compatible archs"
+ end
+
+ parts = @resource[:name].split(".")
+ if archs.index(parts[-1]) != nil
+ up2date "--arch", parts[-1], "-u", parts[0..-2].join(".")
+ else
+ up2date "-u", @resource[:name]
+ end
unless self.query
raise Puppet::ExecutionFailure.new(
--
1.5.5.6
--
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.