Issue #11004 has been reported by Robert van Veelen.
----------------------------------------
Bug #11004: Solaris 11 GA & pkg
https://projects.puppetlabs.com/issues/11004
Author: Robert van Veelen
Status: Unreviewed
Priority: Normal
Assignee:
Category:
Target version:
Affected Puppet version:
Keywords:
Branch:
Oracle has changed the output format of pkg again for the final release of s11.
The "status" field is no longer present in the output of "pkg list -H". There
is now an IFO field that has the following status flags (from the man page):
The last column contains a set of flags that show the
status of the package:
o An i in the I column shows that the package is
installed.
o An f in the F column shows that the package is
frozen.
o An o in the O column shows that the package is
obsolete. An r in the O column shows that the
package has been renamed (a form of obsole-
tion).
Using the work done for Bug #7986 , I have tried the following with some
success (though this only uses the 'I' column):
--- pkg.rb Tue Nov 22 02:01:30 2011
+++ /tmp/pkg.rb Tue Nov 22 05:34:24 2011
@@ -7,27 +7,22 @@
confine :operatingsystem => :solaris
- #defaultfor [:operatingsystem => :solaris, :kernelrelease => "5.11"]
+ defaultfor [:operatingsystem => :solaris, :kernelrelease => "5.11"]
def self.instances
packages = []
- cmd = "#{command(:pkg)} list -H"
- execpipe(cmd) do |process|
- hash = {}
-
+ pkg(:list, '-H').each_line do |line|
# now turn each returned line into a package object
- process.each { |line|
- if hash = parse_line(line)
- packages << new(hash)
- end
- }
+ if hash = parse_line(line.chomp)
+ packages << new(hash)
+ end
end
packages
end
- self::REGEX = %r{^(\S+)\s+(\S+)\s+(\S+)\s+}
+ self::REGEX = /^(\S+)(?:\s+\(.*?\))?\s+(\S+)\s+(\S)\S+$/
self::FIELDS = [:name, :version, :status]
def self.parse_line(line)
@@ -39,15 +34,14 @@
}
hash[:provider] = self.name
- hash[:error] = "ok"
- if hash[:status] == "installed"
+ if hash[:status] == "i"
hash[:ensure] = :present
else
hash[:ensure] = :absent
end
else
- Puppet.warning "Failed to match 'pkg list' line #{line.inspect}"
+ warning "Failed to match 'pkg list' line #{line.inspect}"
return nil
end
@@ -58,12 +52,12 @@
# TODO deal with multiple publishers
def latest
version = nil
- pkg(:list, "-Ha", @resource[:name]).split("\n").each do |line|
- v = line.split[2]
+ pkg(:list, "-Ha", @resource[:name]).each_line do |line|
+ v = parse_line(line.chomp)[:status]
case v
- when "known"
+ when "-"
return v
- when "installed"
+ when "i"
version = v
else
Puppet.warn "unknown package state for #{@resource[:name]}: #{v}"
@@ -74,12 +68,12 @@
# install the package
def install
- pkg :install, @resource[:name]
+ pkg :install, '--deny-new-be', @resource[:name]
end
# uninstall the package
def uninstall
- pkg :uninstall, '-r', @resource[:name]
+ pkg :uninstall, '--deny-new-be', @resource[:name]
end
# update the package to the latest version available
@@ -93,15 +87,11 @@
output = pkg(:list, "-H", @resource[:name])
rescue Puppet::ExecutionFailure
# pkg returns 1 if the package is not found.
- return {:ensure => :absent, :status => 'missing',
- :name => @resource[:name], :error => 'ok'}
+ return {:ensure => :absent, :name => @resource[:name]}
end
- hash = self.class.parse_line(output) ||
- {:ensure => :absent, :status => 'missing', :name => @resource[:name],
:error => 'ok'}
-
- raise Puppet::Error.new( "Package #{hash[:name]}, version
#{hash[:version]} is in error state: #{hash[:error]}") if hash[:error] != "ok"
-
+ hash = self.class.parse_line(output.chomp) || {:ensure => :absent, :name
=> @resource[:name]}
hash
end
+
end
--
You have received this notification because you have either subscribed to it,
or are involved in it.
To change your notification preferences, please click here:
http://projects.puppetlabs.com/my/account
--
You received this message because you are subscribed to the Google Groups
"Puppet Bugs" 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-bugs?hl=en.