summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-04-19 19:54:37 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-04-19 19:54:37 +0000
commit775c72b74e603215c4db8b9f8aa2277bf2d05e79 (patch)
treecd55210e1850fac262ac2dab120ef5082f54b647 /lib
parentbe68411ac59bca3cd57463c7cf530b76093a6769 (diff)
downloadpuppet-775c72b74e603215c4db8b9f8aa2277bf2d05e79.tar.gz
puppet-775c72b74e603215c4db8b9f8aa2277bf2d05e79.tar.xz
puppet-775c72b74e603215c4db8b9f8aa2277bf2d05e79.zip
Adding support for aptrpm from #227 as added by Ian Burrell, the rest of the commit
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2398 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/provider/package/aptrpm.rb79
1 files changed, 79 insertions, 0 deletions
diff --git a/lib/puppet/provider/package/aptrpm.rb b/lib/puppet/provider/package/aptrpm.rb
new file mode 100644
index 000000000..919236365
--- /dev/null
+++ b/lib/puppet/provider/package/aptrpm.rb
@@ -0,0 +1,79 @@
+Puppet::Type.type(:package).provide :aptrpm, :parent => :rpm do
+ # Provide sorting functionality
+ include Puppet::Util::Package
+
+ desc "Package management via ``apt-get`` ported to ``rpm``."
+
+ commands :aptget => "/usr/bin/apt-get"
+ commands :aptcache => "/usr/bin/apt-cache"
+ commands :rpm => "/usr/bin/rpm"
+
+ # Install a package using 'apt-get'. This function needs to support
+ # installing a specific version.
+ def install
+ should = @model.should(:ensure)
+
+ str = @model[:name]
+ case should
+ when true, false, Symbol
+ # pass
+ else
+ # Add the package version
+ str += "=%s" % should
+ end
+ cmd = %w{-q -y}
+
+ cmd << 'install' << str
+
+ aptget(*cmd)
+ end
+
+ # What's the latest package version available?
+ def latest
+ output = aptcache :showpkg, @model[:name]
+
+ if output =~ /Versions:\s*\n((\n|.)+)^$/
+ versions = $1
+ available_versions = versions.split(/\n/).collect { |version|
+ if version =~ /^([^\(]+)\(/
+ $1
+ else
+ self.warning "Could not match version '%s'" % version
+ nil
+ end
+ }.reject { |vers| vers.nil? }.sort { |a,b|
+ versioncmp(a,b)
+ }
+
+ if available_versions.length == 0
+ self.debug "No latest version"
+ if Puppet[:debug]
+ print output
+ end
+ end
+
+ # Get the latest and greatest version number
+ return available_versions.pop
+ else
+ self.err "Could not match string"
+ end
+ end
+
+ def update
+ self.install
+ end
+
+ def uninstall
+ aptget "-y", "-q", 'remove', @model[:name]
+ end
+
+ def purge
+ aptget '-y', '-q', 'remove', '--purge', @model[:name]
+ end
+
+ def versionable?
+ true
+ end
+end
+
+# $Id$