| | 1 | Puppet.type(:package).provide :rug, :parent => :rpm do |
|---|
| | 2 | desc "Support for suse ``rug`` package manager." |
|---|
| | 3 | |
|---|
| | 4 | commands :rug => "/usr/bin/rug" |
|---|
| | 5 | defaultfor :operatingsystem => :suse |
|---|
| | 6 | confine :operatingsystem => :suse |
|---|
| | 7 | |
|---|
| | 8 | # Install a package using 'rug'. |
|---|
| | 9 | def install |
|---|
| | 10 | should = @model.should(:ensure) |
|---|
| | 11 | self.debug "Ensuring => #{should}" |
|---|
| | 12 | wanted = @model[:name] |
|---|
| | 13 | |
|---|
| | 14 | # XXX: We don't actually deal with epochs here. |
|---|
| | 15 | case should |
|---|
| | 16 | when true, false, Symbol |
|---|
| | 17 | # pass |
|---|
| | 18 | else |
|---|
| | 19 | # Add the package version |
|---|
| | 20 | wanted += "-%s" % should |
|---|
| | 21 | end |
|---|
| | 22 | output = rug "--quiet", :install, "-y", wanted |
|---|
| | 23 | |
|---|
| | 24 | unless self.query |
|---|
| | 25 | raise Puppet::ExecutionFailure.new( |
|---|
| | 26 | "Could not find package %s" % self.name |
|---|
| | 27 | ) |
|---|
| | 28 | end |
|---|
| | 29 | end |
|---|
| | 30 | |
|---|
| | 31 | # What's the latest package version available? |
|---|
| | 32 | def latest |
|---|
| | 33 | #rug can only get a list of *all* available packages? |
|---|
| | 34 | output = rug "list-updates" |
|---|
| | 35 | |
|---|
| | 36 | if output =~ /#{@model[:name]}\s*\|\s*([0-9\.\-]+)/ |
|---|
| | 37 | return $1 |
|---|
| | 38 | else |
|---|
| | 39 | # rug didn't find updates, pretend the current |
|---|
| | 40 | # version is the latest |
|---|
| | 41 | return @model.is(:ensure) |
|---|
| | 42 | end |
|---|
| | 43 | end |
|---|
| | 44 | |
|---|
| | 45 | def update |
|---|
| | 46 | # rug install can be used for update, too |
|---|
| | 47 | self.install |
|---|
| | 48 | end |
|---|
| | 49 | |
|---|
| | 50 | def versionable? |
|---|
| | 51 | true |
|---|
| | 52 | end |
|---|
| | 53 | end |