summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-04-30 14:40:34 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-04-30 14:40:34 +0000
commit89ac6d7e7ad5259749ad06765ae537849bbd290c (patch)
treea22d5636e28b965167dedc704c72e49958831b69
parent4296e4e3e3b83cfdba20ba7ccde67c5454b28eaa (diff)
downloadpuppet-89ac6d7e7ad5259749ad06765ae537849bbd290c.tar.gz
puppet-89ac6d7e7ad5259749ad06765ae537849bbd290c.tar.xz
puppet-89ac6d7e7ad5259749ad06765ae537849bbd290c.zip
Adding "rug" package provider from #609
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2429 980ebf18-57e1-0310-9a29-db15c13687c0
-rw-r--r--lib/puppet/provider/package/rug.rb53
1 files changed, 53 insertions, 0 deletions
diff --git a/lib/puppet/provider/package/rug.rb b/lib/puppet/provider/package/rug.rb
new file mode 100644
index 000000000..e6a70ae2a
--- /dev/null
+++ b/lib/puppet/provider/package/rug.rb
@@ -0,0 +1,53 @@
+Puppet.type(:package).provide :rug, :parent => :rpm do
+ desc "Support for suse ``rug`` package manager."
+
+ commands :rug => "/usr/bin/rug"
+ defaultfor :operatingsystem => :suse
+ confine :operatingsystem => :suse
+
+ # Install a package using 'rug'.
+ def install
+ should = @model.should(:ensure)
+ self.debug "Ensuring => #{should}"
+ wanted = @model[: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 = rug "--quiet", :install, "-y", wanted
+
+ unless self.query
+ raise Puppet::ExecutionFailure.new(
+ "Could not find package %s" % self.name
+ )
+ end
+ end
+
+ # What's the latest package version available?
+ def latest
+ #rug can only get a list of *all* available packages?
+ output = rug "list-updates"
+
+ if output =~ /#{@model[:name]}\s*\|\s*([0-9\.\-]+)/
+ return $1
+ else
+ # rug didn't find updates, pretend the current
+ # version is the latest
+ return @model.is(:ensure)
+ end
+ end
+
+ def update
+ # rug install can be used for update, too
+ self.install
+ end
+
+ def versionable?
+ true
+ end
+end