diff options
| author | Luke Kanies <luke@madstop.com> | 2005-06-29 16:34:47 +0000 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2005-06-29 16:34:47 +0000 |
| commit | 00343e3ea7c5633c6580339b9bbe5ee1fa0bac59 (patch) | |
| tree | c9d3d7fd4ff5a2392c7824d31cfffe80c324e69a | |
| parent | 2b2975f06f86058589d5aeff1a4d7f0a72cf5b92 (diff) | |
| download | puppet-00343e3ea7c5633c6580339b9bbe5ee1fa0bac59.tar.gz puppet-00343e3ea7c5633c6580339b9bbe5ee1fa0bac59.tar.xz puppet-00343e3ea7c5633c6580339b9bbe5ee1fa0bac59.zip | |
basic rpm stuff now works
git-svn-id: https://reductivelabs.com/svn/puppet/library/trunk@317 980ebf18-57e1-0310-9a29-db15c13687c0
| -rw-r--r-- | lib/puppet/log.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/type/package.rb | 51 | ||||
| -rw-r--r-- | test/types/tc_package.rb | 7 |
3 files changed, 58 insertions, 2 deletions
diff --git a/lib/puppet/log.rb b/lib/puppet/log.rb index 5f77e623c..9cfcb3c1d 100644 --- a/lib/puppet/log.rb +++ b/lib/puppet/log.rb @@ -19,7 +19,7 @@ module Puppet @@messages = Array.new @@levels = [:debug,:info,:notice,:warning,:err,:alert,:emerg,:crit] - @@loglevel = :notice + @@loglevel = 2 @@logdest = :console @@colors = { diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index fe7768d6e..bb35f8370 100644 --- a/lib/puppet/type/package.rb +++ b/lib/puppet/type/package.rb @@ -260,6 +260,57 @@ module Puppet } } + PackagingType.new("rpm") { |type| + type.list = proc { + packages = [] + + # dpkg only prints as many columns as you have available + # which means we don't get all of the info + # stupid stupid + oldcol = ENV["COLUMNS"] + ENV["COLUMNS"] = "500" + + # list out all of the packages + open("| rpm -q -a --qf '%{NAME} %{VERSION}\n'") { |process| + # our regex for matching dpkg output + regex = %r{^(\S+)\s+(\S+)} + fields = [:name, :version] + hash = {} + + # now turn each returned line into a package object + process.each { |line| + if match = regex.match(line) + hash.clear + + fields.zip(match.captures) { |field,value| + hash[field] = value + } + packages.push Puppet::Type::Package.installedpkg(hash) + else + raise "failed to match rpm line %s" % line + end + } + } + ENV["COLUMNS"] = oldcol + + return packages + } + + # we need package retrieval mechanisms before we can have package + # installation mechanisms... + #type.install = proc { |pkg| + # raise "installation not implemented yet" + #} + + type.remove = proc { |pkg| + cmd = "rpm -e %s" % pkg.name + output = %x{#{cmd}} + if $? != 0 + raise output + end + } + } + PackagingType.new("sunpkg") { |type| type.list = proc { packages = [] diff --git a/test/types/tc_package.rb b/test/types/tc_package.rb index 38669e467..4d53ee1ef 100644 --- a/test/types/tc_package.rb +++ b/test/types/tc_package.rb @@ -18,7 +18,12 @@ class TestPackagingType < Test::Unit::TestCase when "SunOS" type = "sunpkg" when "Linux" - type = "dpkg" + case Facter["distro"].value + when "Debian": type = "dpkg" + when "RedHat": type = "rpm" + else + raise "No default type for " + Facter["distro"].to_s + end else type = :invalid end |
