On Tue, 23 Feb 2010 09:47:02 -0600, James Cammarata <[email protected]> wrote: > I started looking into finishing this patch > http://projects.reductivelabs.com/issues/2043, which apparently was never > completed or included. I got it working, with one caveat: it doesn't > install an RPM if one with the same name but different arch is installed.
> For example, I can install libacl.i386 specifically, but not if > libacl.x86_64 is installed. > > I think the issue is in provider/package.rb, in properties(). Earlier, in > self.prefetch() the information about all installed packages is grabbed, so > in properties() it passes the first if test because some package is > installed with that name. So it looks like for this to work properly, it'd > be a bit more of an invasive change, which would have to be done in rpm.rb > so that all RPM derivatives would pay attention to arch. I'm still new to > ruby and puppet, so maybe I'm missing an easier way to do this. > > Any thoughts and/or suggestions? I think I got it figured out, just quit trying to go down a bad path. I believe I've taken the original suggestion to put the arch values in an array even further: with my patch the compatible archs are pulled from the "rpm --showrc" command itself, so there's no hard-coding of values at all. I corrected one thing in rpm.rb, which I feel is an error. If an empty string is passed to the nevra_to_hash() function, the resulting hash returned had "-" set for the ensure field, which is incorrect. I added a quick check at the top of the function after the strip() to return the empty hash in this case (which causes package.rb to set the ensure field to absent, as it should). Comments/suggestions/criticisms always welcome. -- 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.
From c3a380d87842aa4d6409aedfcc693d09f20ead9c Mon Sep 17 00:00:00 2001 From: James Cammarata <[email protected]> Date: Tue, 23 Feb 2010 13:12:23 -0600 Subject: [PATCH] Changes to rpm/up2date providers to allow for specifying the arch as part of the name of the package to be installed. The changes to rpm.rb are just to correct an error condition where an empty line passed to nevra_to_hash resulted in an ensure of "-" --- 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 a9da43f..e545d37 100755 --- a/lib/puppet/provider/package/rpm.rb +++ b/lib/puppet/provider/package/rpm.rb @@ -125,6 +125,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 284bbaf..e4e3b3a 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.1
