diff options
-rw-r--r-- | CHANGELOG | 2 | ||||
-rw-r--r-- | lib/puppet/provider/package/urpmi.rb | 51 |
2 files changed, 53 insertions, 0 deletions
@@ -1,3 +1,5 @@ + Added urpmi support (#592). + Finishing up the type => provider interface work. Basically, package providers now return lists of provider instances. In the proces, I rewrote the interface between package types and providers, and also diff --git a/lib/puppet/provider/package/urpmi.rb b/lib/puppet/provider/package/urpmi.rb new file mode 100644 index 000000000..4a7de233c --- /dev/null +++ b/lib/puppet/provider/package/urpmi.rb @@ -0,0 +1,51 @@ +Puppet::Type.type(:package).provide :urpmi, :parent => :rpm, :source => :rpm do + desc "Support via ``urpmi``." + commands :urpmi => "urpmi", :rpm => "rpm" + + defaultfor :operatingsystem => [:mandriva, :mandrake] + + has_feature :versionable + + def install + should = @resource.should(:ensure) + self.debug "Ensuring => #{should}" + wanted = @resource[:name] + + # XXX: We don't actually deal with epochs here. + case should + when true, false, Symbol + # pass + else + # Add the package version + wanted += "-%s" % should + end + + output = urpmi "--auto", wanted + + unless self.query + raise Puppet::Error.new( + "Could not find package %s" % self.name + ) + end + end + + # What's the latest package version available? + def latest + output = urpmi "-S", :available, @resource[:name] + + if output =~ /^#{@resource[:name]}\S+\s+(\S+)\s/ + return $1 + else + # urpmi didn't find updates, pretend the current + # version is the latest + return @resource[:ensure] + end + end + + def update + # Install in urpmi can be used for update, too + self.install + end +end + +# $Id$ |