| | 52 | |
|---|
| | 53 | # Find the fully versioned package name and the version alone. Returns |
|---|
| | 54 | # a hash with entries :instance => fully versioned package name, and |
|---|
| | 55 | # :ensure => version-release |
|---|
| | 56 | def query |
|---|
| | 57 | output = yum "-d", "0", "-e", "0", :list, :installed, @model[:name] |
|---|
| | 58 | |
|---|
| | 59 | # if yum returns nothing it mean it is not installed. |
|---|
| | 60 | if output == "" |
|---|
| | 61 | return nil |
|---|
| | 62 | end |
|---|
| | 63 | |
|---|
| | 64 | regex = /^(#{@model[:name]}\S{0,})\s+(\S+)\s/ |
|---|
| | 65 | fields = [:instance, :ensure] |
|---|
| | 66 | hash = {} |
|---|
| | 67 | if match = regex.match(output) |
|---|
| | 68 | fields.zip(match.captures) { |field,value| |
|---|
| | 69 | hash[field] = value |
|---|
| | 70 | } |
|---|
| | 71 | else |
|---|
| | 72 | raise Puppet::DevError, |
|---|
| | 73 | "Failed to match yum output '%s'" % |
|---|
| | 74 | output |
|---|
| | 75 | end |
|---|
| | 76 | |
|---|
| | 77 | @nvr = hash[:instance] |
|---|
| | 78 | |
|---|
| | 79 | return hash |
|---|
| | 80 | end |
|---|