diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-06 00:49:14 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-09-06 00:49:14 +0000 |
| commit | c5ce953462f424138f0009ce978eb9620aff84a7 (patch) | |
| tree | 17b5651ee9b996f735c283b95ad74322a3e94a19 /lib | |
| parent | 2113eed0137630836b3de3e2a8bc17b6cb7198e8 (diff) | |
| download | puppet-c5ce953462f424138f0009ce978eb9620aff84a7.tar.gz puppet-c5ce953462f424138f0009ce978eb9620aff84a7.tar.xz puppet-c5ce953462f424138f0009ce978eb9620aff84a7.zip | |
Adding aptitude support, including a new util::package module that provides a method for package version sorting, and a couple of smaller bug fixes. This fixes #237.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1570 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
| -rwxr-xr-x | lib/puppet/provider/package/apt.rb | 15 | ||||
| -rwxr-xr-x | lib/puppet/provider/package/aptitude.rb | 14 | ||||
| -rw-r--r-- | lib/puppet/type.rb | 1 | ||||
| -rw-r--r-- | lib/puppet/type/pfile.rb | 3 | ||||
| -rw-r--r-- | lib/puppet/util.rb | 1 |
5 files changed, 29 insertions, 5 deletions
diff --git a/lib/puppet/provider/package/apt.rb b/lib/puppet/provider/package/apt.rb index c0fa0f3a5..a31fbda2b 100755 --- a/lib/puppet/provider/package/apt.rb +++ b/lib/puppet/provider/package/apt.rb @@ -1,4 +1,7 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg do + # Provide sorting functionality + include Puppet::Util::Package + desc "Package management via ``apt-get``." commands :aptget => "/usr/bin/apt-get" @@ -12,6 +15,10 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg do # Debian boxes, and the only thing that differs is that it can # install packages from remote sites. + def apt + command(:aptget) + end + def checkforcdrom unless defined? @@checkedforcdrom if FileTest.exists? "/etc/apt/sources.list" @@ -48,7 +55,7 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg do # Add the package version str += "=%s" % should end - cmd = "#{command(:aptget)} -q -y install %s" % str + cmd = "#{apt()} -q -y install %s" % str begin output = execute(cmd) @@ -75,7 +82,9 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg do self.warning "Could not match version '%s'" % version nil end - }.reject { |vers| vers.nil? }.sort[-1] + }.reject { |vers| vers.nil? }.sort { |a,b| + versioncmp(a,b) + } unless version self.debug "No latest version" @@ -95,7 +104,7 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg do end def uninstall - cmd = "#{command(:aptget)} -y -q remove %s" % @model[:name] + cmd = "#{apt()} -y -q remove %s" % @model[:name] begin output = execute(cmd) rescue Puppet::ExecutionFailure diff --git a/lib/puppet/provider/package/aptitude.rb b/lib/puppet/provider/package/aptitude.rb new file mode 100755 index 000000000..ca5acaf62 --- /dev/null +++ b/lib/puppet/provider/package/aptitude.rb @@ -0,0 +1,14 @@ +Puppet::Type.type(:package).provide :aptitude, :parent => :apt do + desc "Package management via ``aptitude``." + + commands :aptitude => "/usr/bin/aptitude" + commands :aptcache => "/usr/bin/apt-cache" + + ENV['DEBIAN_FRONTEND'] = "noninteractive" + + def apt + command(:aptitude) + end +end + +# $Id$ diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb index d87cbcbd3..07510faa7 100644 --- a/lib/puppet/type.rb +++ b/lib/puppet/type.rb @@ -791,7 +791,6 @@ class Type < Puppet::Element when @@metaparamhash.include?(attr): :meta when @paramhash.include?(attr): :param else - Puppet.err "raising a warning, yo: %s" % attr raise Puppet::DevError, "Invalid attribute '%s' for class '%s'" % [attr, self.name] diff --git a/lib/puppet/type/pfile.rb b/lib/puppet/type/pfile.rb index ec666497d..a8d5fbe33 100644 --- a/lib/puppet/type/pfile.rb +++ b/lib/puppet/type/pfile.rb @@ -691,7 +691,8 @@ module Puppet if child = self.newchild(file, true, options) # Mark any unmanaged files for removal if purge is set. - if self[:purge] == :true and child.implicit? + # Use the array rather than [] because tidy uses this method, too. + if @parameters.include?(:purge) and self[:purge] == :true and child.implicit? child[:ensure] = :absent end diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index f42eddef0..502a47abf 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -521,5 +521,6 @@ require 'puppet/util/metaid' require 'puppet/util/classgen' require 'puppet/util/docs' require 'puppet/util/execution' +require 'puppet/util/package' # $Id$ |
