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 | |
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
-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 | ||||
-rwxr-xr-x | test/other/loadedfile.rb (renamed from test/other/parsedfile.rb) | 8 | ||||
-rwxr-xr-x | test/other/puppet.rb | 1 | ||||
-rw-r--r-- | test/types/service.rb | 1 | ||||
-rwxr-xr-x | test/util/classgen.rb | 2 | ||||
-rwxr-xr-x | test/util/package.rb | 30 |
10 files changed, 64 insertions, 12 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$ diff --git a/test/other/parsedfile.rb b/test/other/loadedfile.rb index 2f87308ab..efb17a1e5 100755 --- a/test/other/parsedfile.rb +++ b/test/other/loadedfile.rb @@ -5,11 +5,11 @@ if __FILE__ == $0 end require 'puppet' -require 'puppet/parsedfile' +require 'puppet/loadedfile' require 'puppettest' require 'test/unit' -class TestParsedFile < Test::Unit::TestCase +class TestLoadedFile < Test::Unit::TestCase include TestPuppet def test_file Puppet[:filetimeout] = 0 @@ -17,7 +17,7 @@ class TestParsedFile < Test::Unit::TestCase path = tempfile() File.open(path, "w") { |f| f.puts "yayness" } assert_nothing_raised { - file = Puppet::ParsedFile.new(path) + file = Puppet::LoadedFile.new(path) } assert(!file.changed?, "File incorrectly returned changed") @@ -36,7 +36,7 @@ class TestParsedFile < Test::Unit::TestCase File.open(path, "w") { |f| f.puts "yay" } file = nil assert_nothing_raised { - file = Puppet::ParsedFile.new(path) + file = Puppet::LoadedFile.new(path) } assert_nothing_raised { file.changed? } diff --git a/test/other/puppet.rb b/test/other/puppet.rb index b9ddb07b0..18600f7a0 100755 --- a/test/other/puppet.rb +++ b/test/other/puppet.rb @@ -5,7 +5,6 @@ if __FILE__ == $0 end require 'puppet' -require 'puppet/parsedfile' require 'puppettest' require 'test/unit' diff --git a/test/types/service.rb b/test/types/service.rb index c6f530dc7..e936e8f84 100644 --- a/test/types/service.rb +++ b/test/types/service.rb @@ -16,7 +16,6 @@ end if $skipsvcs puts "Skipping service testing on %s" % Facter["operatingsystem"].value else - puts "wtf?" #class TestInitService < Test::Unit::TestCase class TestInitService include TestPuppet diff --git a/test/util/classgen.rb b/test/util/classgen.rb index 825a98f3c..7b1b4731c 100755 --- a/test/util/classgen.rb +++ b/test/util/classgen.rb @@ -58,7 +58,7 @@ class TestPuppetUtilClassGen < Test::Unit::TestCase klass = nil assert_nothing_raised { - klass = GenTest.genclass(:yayness, :parent => newclass) + klass = GenTest.genclass(:funtest, :parent => newclass) } assert(klass.preinited, "prehook did not get called") diff --git a/test/util/package.rb b/test/util/package.rb new file mode 100755 index 000000000..2d7f633de --- /dev/null +++ b/test/util/package.rb @@ -0,0 +1,30 @@ +if __FILE__ == $0 + $:.unshift '..' + $:.unshift '../../lib' + $puppetbase = ".." +end + +require 'puppet' +require 'puppet/util/package' +require 'puppettest' +require 'test/unit' + +class TestPuppetUtilPackage < Test::Unit::TestCase + include TestPuppet + include Puppet::Util::Package + + def test_versioncmp + ary = %w{ 1.1.6 2.3 1.1a 3.0 1.5 1 2.4 1.1-4 + 2.3.1 1.2 2.3.0 1.1-3 2.4b 2.4 2.40.2 2.3a.1 3.1 0002 1.1-5 1.1.a 1.06} + + newary = nil + assert_nothing_raised do + newary = ary.sort { |a, b| + versioncmp(a,b) + } + end + assert_equal(["0002", "1", "1.06", "1.1-3", "1.1-4", "1.1-5", "1.1.6", "1.1.a", "1.1a", "1.2", "1.5", "2.3", "2.3.0", "2.3.1", "2.3a.1", "2.4", "2.4", "2.4b", "2.40.2", "3.0", "3.1"], newary) + end +end + +# $Id$ |