[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, upstream, updated. 0.25.5-639-g8f94f35
Markus Roberts
Markus at reality.com
Wed Jul 14 10:36:37 UTC 2010
The following commit has been merged in the upstream branch:
commit 6ac36eb42f0a505fd37d7e600bb0fd8837511b42
Author: Matt Robinson <matt at puppetlabs.com>
Date: Tue Jul 6 17:42:56 2010 -0700
[#2370] Allow OpenBSD to add packages with versions and flavors
This patch is from Joe McDonagh <joseph.e.mcdonagh at gmail.com>
diff --git a/lib/puppet/provider/package/openbsd.rb b/lib/puppet/provider/package/openbsd.rb
index af590eb..1c873fd 100755
--- a/lib/puppet/provider/package/openbsd.rb
+++ b/lib/puppet/provider/package/openbsd.rb
@@ -10,19 +10,21 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
defaultfor :operatingsystem => :openbsd
confine :operatingsystem => :openbsd
+ has_feature :versionable
+
def self.instances
packages = []
begin
execpipe(listcmd()) do |process|
# our regex for matching pkg_info output
- regex = %r{^(\S+)-([^-\s]+)\s+(.+)}
- fields = [:name, :ensure, :description]
+ regex = /^(.*)-(\d[^-]*)[-]?(\D*)(.*)$/
+ fields = [:name, :ensure, :flavor ]
hash = {}
# now turn each returned line into a package object
process.each { |line|
- if match = regex.match(line)
+ if match = regex.match(line.split()[0])
fields.zip(match.captures) { |field,value|
hash[field] = value
}
@@ -59,9 +61,15 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
"You must specify a package source for BSD packages"
end
+ old_ensure = @resource[:ensure]
+
if @resource[:source] =~ /\/$/
withenv :PKG_PATH => @resource[:source] do
- pkgadd @resource[:name]
+ if (@resource[:ensure] = get_version) == nil
+ @resource[:ensure] = old_ensure
+ end
+ full_name = [ @resource[:name], @resource[:ensure], @resource[:flavor] ]
+ pkgadd full_name.join('-').chomp('-')
end
else
pkgadd @resource[:source]
@@ -69,6 +77,32 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
end
+ def get_version
+ begin
+ execpipe([command(:pkginfo), " -I ", @resource[:name]]) do |process|
+ # our regex for matching pkg_info output
+ regex = /^(.*)-(\d[^-]*)[-]?(\D*)(.*)$/
+ fields = [ :name, :version, :flavor ]
+ master_version = 0
+
+ process.each do |line|
+ if match = regex.match(line.split()[0])
+ # now we return the first version, unless ensure is latest
+ version = match.captures[1]
+ return version unless @resource[:ensure] == "latest"
+
+ master_version = version unless master_version > version
+ end
+ end
+
+ return master_version unless master_version == 0
+ raise Puppet::Error, "#{version} is not available for this package"
+ end
+ rescue Puppet::ExecutionFailure
+ return nil
+ end
+ end
+
def query
hash = {}
info = pkginfo @resource[:name]
@@ -80,11 +114,6 @@ Puppet::Type.type(:package).provide :openbsd, :parent => Puppet::Provider::Packa
return nil
end
- # And the description
- if info =~ /Comment:\s*\n(.+)/
- hash[:description] = $1
- end
-
return hash
end
diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb
index 827fee1..237cefd 100644
--- a/lib/puppet/type/package.rb
+++ b/lib/puppet/type/package.rb
@@ -287,6 +287,11 @@ module Puppet
newvalues(:true, :false)
end
+ newparam(:flavor) do
+ desc "Newer versions of OpenBSD support 'flavors', which are
+ further specifications for which type of package you want."
+ end
+
autorequire(:file) do
autos = []
[:responsefile, :adminfile].each { |param|
--
Puppet packaging for Debian
More information about the Pkg-puppet-devel
mailing list