summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuerg Walz <jwalz@pobox.com>2011-02-22 09:24:03 +0800
committerJuerg Walz <jwalz@pobox.com>2011-02-22 09:24:03 +0800
commit15a53f0ac79cb3f164750d53219d02ad6515f02c (patch)
tree7f08d850f9a939eaf1e81f528d04f02188dd9c06
parent15e225b5ef80a92f1d9ec25ca518601519f6ffe9 (diff)
downloadpuppet-15a53f0ac79cb3f164750d53219d02ad6515f02c.tar.gz
puppet-15a53f0ac79cb3f164750d53219d02ad6515f02c.tar.xz
puppet-15a53f0ac79cb3f164750d53219d02ad6515f02c.zip
(#4258) pkgutil provider: misc enhancements
Several enhancements and bug-fixes for the pkgutil package provider: - handle "Not in catalog" - fix "SAME" version detection - allow short package name (w/o CSW) to match (-> no need to specify a different package name for different operating systems, ex. "ruby") - use the "-u" command line switch for updates
-rwxr-xr-xlib/puppet/provider/package/pkgutil.rb15
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/puppet/provider/package/pkgutil.rb b/lib/puppet/provider/package/pkgutil.rb
index f0900dc22..0e2056b54 100755
--- a/lib/puppet/provider/package/pkgutil.rb
+++ b/lib/puppet/provider/package/pkgutil.rb
@@ -51,12 +51,12 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d
next if line =~ /^=+> / # catalog fetch
next if line =~ /\d+:\d+:\d+ URL:/ # wget without -q
- pkgsplit(line)
+ pkgsplit(line, hash[:justme])
end.reject { |h| h.nil? }
if hash[:justme]
# Ensure we picked up the package line, not any pkgutil noise.
- list.reject! { |h| h[:name] != hash[:justme] }
+ list.reject! { |h| h[:name] !~ /#{hash[:justme]}$/ }
return list[-1]
else
list.reject! { |h| h[:ensure] == :absent }
@@ -66,8 +66,11 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d
end
# Split the different lines into hashes.
- def self.pkgsplit(line)
- if line =~ /\s*(\S+)\s+(\S+)\s+(.*)/
+ def self.pkgsplit(line, justme)
+ if line == "Not in catalog"
+ Puppet.warning "Package not in pkgutil catalog: %s" % justme
+ return nil
+ elsif line =~ /\s*(\S+)\s+(\S+)\s+(.*)/
hash = {}
hash[:name] = $1
hash[:ensure] = if $2 == "notinst"
@@ -77,7 +80,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d
end
hash[:avail] = $3
- if hash[:avail] == "SAME"
+ if hash[:avail] =~ /^SAME\s*$/
hash[:avail] = hash[:ensure]
end
@@ -110,7 +113,7 @@ Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun d
end
def update
- pkguti "-y", "-i", @resource[:name]
+ pkguti "-y", "-u", @resource[:name]
end
def uninstall