From 2b27545ebaae828237fac967d58bcfe6b01b389d Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 5 Apr 2006 05:13:39 +0000 Subject: renaming; i hate bsd git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1074 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/type/package/bsd.rb | 82 -------------------------------------- lib/puppet/type/package/openbsd.rb | 82 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 82 deletions(-) delete mode 100755 lib/puppet/type/package/bsd.rb create mode 100755 lib/puppet/type/package/openbsd.rb diff --git a/lib/puppet/type/package/bsd.rb b/lib/puppet/type/package/bsd.rb deleted file mode 100755 index 376c5296a..000000000 --- a/lib/puppet/type/package/bsd.rb +++ /dev/null @@ -1,82 +0,0 @@ -module Puppet - Puppet.type(:package).newpkgtype(:bsd) do - def install - should = self.should(:ensure) - - unless self[:source] - raise Puppet::Error, - "You must specify a package source for BSD packages" - end - - cmd = "pkg_add #{self[:source]}" - - self.info "Executing %s" % cmd.inspect - output = %x{#{cmd} 2>&1} - - unless $? == 0 - raise Puppet::PackageError.new(output) - end - end - - def query - hash = {} - # list out our specific package - info = %x{pkg_info #{self[:name]} 2>/dev/null} - - # Search for the version info - if info =~ /Information for #{self[:name]}-(\S+)/ - hash[:version] = $1 - hash[:ensure] = :present - else - return nil - end - - # And the description - if info =~ /Comment:\s*\n(.+)/ - hash[:description] = $1 - end - - return hash - end - - def list - packages = [] - - # list out all of the packages - open("| pkg_info -a") { |process| - # our regex for matching dpkg output - regex = %r{^(\S+)-(\d\S+)\s+(.+)} - fields = [:name, :version, :description] - 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 Puppet::DevError, - "Failed to match dpkg line %s" % line - end - } - } - ENV["COLUMNS"] = oldcol - - return packages - end - - def uninstall - cmd = "pkg_delete %s" % self[:name] - output = %x{#{cmd} 2>&1} - if $? != 0 - raise Puppet::PackageError.new(output) - end - end - end -end - -# $Id$ diff --git a/lib/puppet/type/package/openbsd.rb b/lib/puppet/type/package/openbsd.rb new file mode 100755 index 000000000..376c5296a --- /dev/null +++ b/lib/puppet/type/package/openbsd.rb @@ -0,0 +1,82 @@ +module Puppet + Puppet.type(:package).newpkgtype(:bsd) do + def install + should = self.should(:ensure) + + unless self[:source] + raise Puppet::Error, + "You must specify a package source for BSD packages" + end + + cmd = "pkg_add #{self[:source]}" + + self.info "Executing %s" % cmd.inspect + output = %x{#{cmd} 2>&1} + + unless $? == 0 + raise Puppet::PackageError.new(output) + end + end + + def query + hash = {} + # list out our specific package + info = %x{pkg_info #{self[:name]} 2>/dev/null} + + # Search for the version info + if info =~ /Information for #{self[:name]}-(\S+)/ + hash[:version] = $1 + hash[:ensure] = :present + else + return nil + end + + # And the description + if info =~ /Comment:\s*\n(.+)/ + hash[:description] = $1 + end + + return hash + end + + def list + packages = [] + + # list out all of the packages + open("| pkg_info -a") { |process| + # our regex for matching dpkg output + regex = %r{^(\S+)-(\d\S+)\s+(.+)} + fields = [:name, :version, :description] + 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 Puppet::DevError, + "Failed to match dpkg line %s" % line + end + } + } + ENV["COLUMNS"] = oldcol + + return packages + end + + def uninstall + cmd = "pkg_delete %s" % self[:name] + output = %x{#{cmd} 2>&1} + if $? != 0 + raise Puppet::PackageError.new(output) + end + end + end +end + +# $Id$ -- cgit