66: def info2hash(device = nil)
67: names = {
68: "PKGINST" => :name,
69: "NAME" => nil,
70: "CATEGORY" => :category,
71: "ARCH" => :platform,
72: "VERSION" => :ensure,
73: "BASEDIR" => :root,
74: "HOTLINE" => nil,
75: "EMAIL" => nil,
76: "VSTOCK" => nil,
77: "VENDOR" => :vendor,
78: "DESC" => :description,
79: "PSTAMP" => nil,
80: "INSTDATE" => nil,
81: "STATUS" => nil,
82: "FILES" => nil
83: }
84:
85: hash = {}
86: cmd = "#{command(:pkginfo)} -l"
87: if device
88: cmd += " -d #{device}"
89: end
90: cmd += " #{@resource[:name]}"
91:
92: begin
93:
94: execpipe(cmd) { |process|
95:
96:
97: process.each { |line|
98: case line
99: when /^$/
100: when /\s*([A-Z]+):\s+(.+)/
101: name = $1
102: value = $2
103: if names.include?(name)
104: unless names[name].nil?
105: hash[names[name]] = value
106: end
107: end
108: when /\s+\d+.+/
109:
110: end
111: }
112: }
113: return hash
114: rescue Puppet::ExecutionFailure
115: return nil
116: end
117: end