# File lib/puppet/provider/package/portage.rb, line 15
15:   def self.instances
16:     result_format = /^(\S+)\s+(\S+)\s+\[(\S+)\]\s+\[(\S+)\]\s+(\S+)\s+(.*)$/
17:     result_fields = [:category, :name, :ensure, :version_available, :vendor, :description]
18: 
19:     version_format = "{last}<version>{}"
20:     search_format = "<category> <name> [<installedversions:LASTVERSION>] [<bestversion:LASTVERSION>] <homepage> <description>\n"
21: 
22:     begin
23:       update_eix if !FileUtils.uptodate?("/var/cache/eix", %w{/usr/bin/eix /usr/portage/metadata/timestamp})
24: 
25:       search_output = nil
26:       Puppet::Util::Execution.withenv :LASTVERSION => version_format do
27:         search_output = eix "--nocolor", "--pure-packages", "--stable", "--installed", "--format", search_format
28:       end
29: 
30:       packages = []
31:       search_output.each do |search_result|
32:         match = result_format.match(search_result)
33: 
34:         if match
35:           package = {}
36:           result_fields.zip(match.captures) do |field, value|
37:             package[field] = value unless !value or value.empty?
38:           end
39:           package[:provider] = :portage
40:           packages << new(package)
41:         end
42:       end
43: 
44:       return packages
45:     rescue Puppet::ExecutionFailure => detail
46:       raise Puppet::Error.new(detail)
47:     end
48:   end