aboutsummaryrefslogtreecommitdiffstats
path: root/sysutils/puppet
diff options
context:
space:
mode:
authorswills <swills@FreeBSD.org>2011-04-11 00:11:49 +0800
committerswills <swills@FreeBSD.org>2011-04-11 00:11:49 +0800
commit4ba20296257e718607fb126f249fe24047a3c63b (patch)
tree2fd28f41ca2afdceff41094c0ee5df1cf35bc3bb /sysutils/puppet
parent20159dd279f8334e5b3d001657659dcbe61b5859 (diff)
downloadfreebsd-ports-gnome-4ba20296257e718607fb126f249fe24047a3c63b.tar.gz
freebsd-ports-gnome-4ba20296257e718607fb126f249fe24047a3c63b.tar.zst
freebsd-ports-gnome-4ba20296257e718607fb126f249fe24047a3c63b.zip
- Update to 2.6.7
- Updates optional patch to use improved package provider - Adds patch to fix user/password provider hash usage PR: ports/156239 Submitted by: Russell Jackson <raj at csub.edu> (maintainer)
Diffstat (limited to 'sysutils/puppet')
-rw-r--r--sysutils/puppet/Makefile3
-rw-r--r--sysutils/puppet/distinfo4
-rw-r--r--sysutils/puppet/files/optpatch-package_origin205
-rw-r--r--sysutils/puppet/files/patch-fix_password_provider42
4 files changed, 193 insertions, 61 deletions
diff --git a/sysutils/puppet/Makefile b/sysutils/puppet/Makefile
index 7311bbbb3d74..70fcd6164ae2 100644
--- a/sysutils/puppet/Makefile
+++ b/sysutils/puppet/Makefile
@@ -6,7 +6,7 @@
#
PORTNAME= puppet
-PORTVERSION= 2.6.6
+PORTVERSION= 2.6.7
CATEGORIES= sysutils
MASTER_SITES= http://www.puppetlabs.com/downloads/puppet/
@@ -50,6 +50,7 @@ RUN_DEPENDS+= rubygem-mongrel>=0:${PORTSDIR}/www/rubygem-mongrel
.if defined(WITH_PACKAGE_ORIGIN)
EXTRA_PATCHES+= ${FILESDIR}/optpatch-package_origin
+RUN_DEPENDS+= ${RUBY_SITEARCHLIBDIR}/bz2.so:${PORTSDIR}/archivers/ruby-bz2
.endif
.include <bsd.port.pre.mk>
diff --git a/sysutils/puppet/distinfo b/sysutils/puppet/distinfo
index ed0859f7c100..17dcc99b92e7 100644
--- a/sysutils/puppet/distinfo
+++ b/sysutils/puppet/distinfo
@@ -1,2 +1,2 @@
-SHA256 (puppet-2.6.6.tar.gz) = bc613c2764345947268a080ca0595aa6d4dbb0b9eab65d1476ff6542caf1647a
-SIZE (puppet-2.6.6.tar.gz) = 1514638
+SHA256 (puppet-2.6.7.tar.gz) = 90c0741f66d15716cfd76f0b8cd15f5b867056f0180ba160ce868350c6dd4ddc
+SIZE (puppet-2.6.7.tar.gz) = 1530756
diff --git a/sysutils/puppet/files/optpatch-package_origin b/sysutils/puppet/files/optpatch-package_origin
index f47dc9425d39..e1cef54cfb52 100644
--- a/sysutils/puppet/files/optpatch-package_origin
+++ b/sysutils/puppet/files/optpatch-package_origin
@@ -1,19 +1,24 @@
-diff --git a/lib/puppet/provider/package/freebsd.rb b/lib/puppet/provider/package/freebsd.rb
-index e10a20b..fbda52d 100755
+diff --git lib/puppet/provider/package/freebsd.rb lib/puppet/provider/package/freebsd.rb
+index e10a20b..f36e29e 100755
--- lib/puppet/provider/package/freebsd.rb
+++ lib/puppet/provider/package/freebsd.rb
-@@ -1,36 +1,79 @@
- Puppet::Type.type(:package).provide :freebsd, :parent => :openbsd do
+@@ -1,37 +1,165 @@
+-Puppet::Type.type(:package).provide :freebsd, :parent => :openbsd do
- desc "The specific form of package management on FreeBSD. This is an
- extremely quirky packaging system, in that it freely mixes between
- ports and packages. Apparently all of the tools are written in Ruby,
- so there are plans to rewrite this support to directly use those
- libraries."
-+ include Puppet::Util::Execution
++require 'open-uri'
++require 'net/ftp'
++require 'bz2'
- commands :pkginfo => "/usr/sbin/pkg_info",
- :pkgadd => "/usr/sbin/pkg_add",
- :pkgdelete => "/usr/sbin/pkg_delete"
++Puppet::Type.type(:package).provide :freebsd, :parent => Puppet::Provider::Package do
++ include Puppet::Util::Execution
++
+ desc "The specific form of package management on FreeBSD. Resource names must be
+ specified as the port origin: <port_category>/<port_name>."
+
@@ -24,84 +29,168 @@ index e10a20b..fbda52d 100755
confine :operatingsystem => :freebsd
+ defaultfor :operatingsystem => :freebsd
+
-+ def self.instances
-+ packages = []
-+
-+ output = pkginfo "-aoQ"
-+ output.split("\n").each do |data|
-+ lhs, pkg_origin = data.split(":")
-+ pkg_name = lhs.split("-").slice(0..-2).join("-")
-+ pkg_version = lhs.split("-")[-1]
-+
-+ packages << new({
-+ :provider => self.name,
-+ :name => pkg_origin,
-+ :ensure => pkg_version,
-+ })
-+ end
++ @@lock = Mutex.new
++ @@ports_index = nil
- def self.listcmd
- command(:pkginfo)
-+ packages
++ # fix bug in URI::FTP merge method that tries to set typecode
++ # even when other is a string.
++ class URI::FTP
++ def merge(other)
++ tmp = super(other)
++ if self != tmp
++ tmp.set_typecode(other.typecode) rescue NoMethodError
++ end
++ return tmp
++ end
end
- def install
- should = @resource.should(:ensure)
+- def install
+- should = @resource.should(:ensure)
++ def self.parse_pkg_string(pkg_string)
++ {
++ :pkg_name => pkg_string.split("-").slice(0..-2).join("-"),
++ :pkg_version => pkg_string.split("-")[-1],
++ }
++ end
++
++ def self.unparse_pkg_info(pkg_info)
++ [:pkg_name, :pkg_version].map { |key| pkg_info[key] }.join("-")
++ end
+
-+ origin = {}
-+ [:category, :name].zip(@resource[:name].split("/")).each { |a,b| origin[a] = b }
-+ Puppet.debug "origin => #{origin.inspect}"
-+ if origin[:name] == nil
-+ raise Puppet::Error.new "package name must be in origin format: <category>/<name>"
++ def self.parse_origin(origin_path)
++ begin
++ origin = {
++ :port_category => origin_path.split("/").fetch(-2),
++ :port_name => origin_path.split("/").fetch(-1),
++ }
++ rescue IndexError
++ raise Puppet::Error.new "#{origin_path}: not in required origin format: .*/<port_category>/<port_name>"
+ end
-+
-+ # source parameter is set
-+ if @resource[:source]
-+ source = URI.parse(@resource[:source])
-+ Puppet.debug "source => #{source.inspect}"
++ origin
++ end
- if @resource[:source] =~ /\/$/
- if @resource[:source] =~ /^(ftp|https?):/
- Puppet::Util::Execution::withenv :PACKAGESITE => @resource[:source] do
- pkgadd "-r", @resource[:name]
-+ # URI is for local file path.
-+ if (source.scheme == "file" || source.scheme == nil) && source.path
-+ # Pass pkg_add only the URI path.
-+ pkgadd source.path
++ def self.instances
++ packages = []
++ output = pkginfo "-aoQ"
++ output.split("\n").each do |data|
++ pkg_string, pkg_origin = data.split(":")
++ pkg_info = self.parse_pkg_string(pkg_string)
++
++ packages << new({
++ :provider => self.name,
++ :name => pkg_origin,
++ :ensure => pkg_info[:pkg_version],
++ })
++ end
++ packages
++ end
+
-+ # URI scheme is something other than 'file'.
-+ elsif source.scheme && source.host && source.path
-+ if source.path.end_with?(".tbz") # URI references a package.
-+ # Pass pkg_add the entire URI.
-+ pkgadd source.to_s
-+ else # Assume URI references a directory.
-+ # Set PACKAGESITE in execution environment to source URI.
-+ # Pass pkg_add the origin name.
-+ withenv :PACKAGESITE => source.path.end_with?("/") ? source.to_s : source.to_s << "/" do
-+ Puppet.debug "ENV['PACKAGESITE'] => #{ENV['PACKAGESITE']}"
-+ pkgadd "-rf", origin[:name]
++ def ports_index
++ @@lock.synchronize do
++ if @@ports_index.nil?
++ @@ports_index = {}
++ uri = source.merge "INDEX.bz2"
++ Puppet.debug "Fetching INDEX: #{uri.inspect}"
++ begin
++ open(uri, "r") do |f|
++ BZ2::Reader.open(f.path) do |f|
++ while (line = f.gets)
++ fields = line.split("|")
++ pkg_info = self.class.parse_pkg_string(fields[0])
++ origin = self.class.parse_origin(fields[1])
++ @@ports_index[origin] = pkg_info
++ end
++ end
+ end
++ rescue IOError, OpenURI::HTTPError, Net::FTPError
++ @@ports_index = nil
++ raise Puppet::Error.new "Could not fetch ports INDEX: #{$!}"
end
-+
-+ # URI is not usable by pkg_add
- else
+- else
- Puppet::Util::Execution::withenv :PKG_PATH => @resource[:source] do
- pkgadd @resource[:name]
-- end
-+ raise Puppet::Error.new "source URI is inappropriate: #{source.inspect}"
++ end
++ end
++ @@ports_index
++ end
++
++ def uri_path
++ Facter.loadfacts
++ File.join(
++ "/", "pub", "FreeBSD", "ports",
++ Facter.value(:hardwareisa),
++ [
++ "packages",
++ Facter.value(:kernelmajversion).split(".")[0],
++ "stable",
++ ].join("-")
++ ) << "/"
++ end
++
++ def source
++ if !defined? @source
++ if @resource[:source]
++ @source = URI.parse(@resource[:source])
++ if @source.path.empty?
++ @source.merge! uri_path
+ end
++ else # source parameter not set; build default source URI
++ @source = URI::FTP.build({
++ :host => "ftp.freebsd.org",
++ :path => uri_path,
++ })
end
++ Puppet.debug "Package: #{@resource[:name]}: source => #{@source.inspect}"
++ end
++ @source
++ end
++
++ def origin
++ if !defined? @origin
++ @origin = self.class.parse_origin(@resource[:name])
++ Puppet.debug "Package: #{@resource[:name]}: origin => #{@origin.inspect}"
++ end
++ @origin
++ end
++
++ def package_uri
++ begin
++ pkg_name = self.class.unparse_pkg_info(ports_index.fetch(origin))
++ rescue IndexError
++ raise Puppet::Error.new "package not found in INDEX"
++ end
++ uri = source.merge File.join("All", pkg_name + ".tbz")
++ Puppet.debug "Package: #{@resource[:name]}: package_uri => #{uri.inspect}"
++ uri
++ end
++
++ def install
++ should = @resource.should(:ensure)
++ origin # call origin so we check the package name for correctness early
+
-+ # source parameter is not set.
++ # Source URI is for local file path.
++ if !source.absolute? or source.scheme == "file"
++ pkgadd source.path
++ # Source URI is to specific package file
++ elsif source.absolute? && source.path.end_with?(".tbz")
++ pkgadd source.to_s
++ # Source URI is to a package repository
else
- Puppet.warning "source is defined but does not have trailing slash, ignoring #{@resource[:source]}" if @resource[:source]
- pkgadd "-r", @resource[:name]
-+ # fetch package using default PACKAGESITE directory logic.
-+ # Pass pkg_add the origin name.
-+ pkgadd "-rf", origin[:name]
++ pkgadd "-f", package_uri.to_s
end
++ nil
end
-@@ -44,7 +87,7 @@ Puppet::Type.type(:package).provide :freebsd, :parent => :openbsd do
+ def query
+@@ -44,7 +172,7 @@ Puppet::Type.type(:package).provide :freebsd, :parent => :openbsd do
end
def uninstall
diff --git a/sysutils/puppet/files/patch-fix_password_provider b/sysutils/puppet/files/patch-fix_password_provider
new file mode 100644
index 000000000000..8fd0e20fac78
--- /dev/null
+++ b/sysutils/puppet/files/patch-fix_password_provider
@@ -0,0 +1,42 @@
+diff --git lib/puppet/provider/user/pw.rb lib/puppet/provider/user/pw.rb
+index a5988ca..c2fff37 100644
+--- lib/puppet/provider/user/pw.rb
++++ lib/puppet/provider/user/pw.rb
+@@ -1,10 +1,11 @@
+ require 'puppet/provider/nameservice/pw'
++require 'open3'
+
+ Puppet::Type.type(:user).provide :pw, :parent => Puppet::Provider::NameService::PW do
+ desc "User management via `pw` on FreeBSD."
+
+ commands :pw => "pw"
+- has_features :manages_homedir, :allows_duplicates
++ has_features :manages_homedir, :allows_duplicates, :manages_passwords
+
+ defaultfor :operatingsystem => :freebsd
+
+@@ -37,5 +38,24 @@ Puppet::Type.type(:user).provide :pw, :parent => Puppet::Provider::NameService::
+
+ cmd
+ end
++
++ # use pw to update password hash
++ def password=(cryptopw)
++ Puppet.debug "change password for user '#{@resource[:name]}' method called with hash '#{cryptopw}'"
++ stdin, stdout, stderr = Open3.popen3("pw user mod #{@resource[:name]} -H 0")
++ stdin.puts(cryptopw)
++ stdin.close
++ Puppet.debug "finished password for user '#{@resource[:name]}' method called with hash '#{cryptopw}'"
++ end
++
++ # get password from /etc/master.passwd
++ def password
++ Puppet.debug "checking password for user '#{@resource[:name]}' method called"
++ current_passline = `getent passwd #{@resource[:name]}`
++ current_password = current_passline.chomp.split(':')[1] if current_passline
++ Puppet.debug "finished password for user '#{@resource[:name]}' method called : '#{current_password}'"
++ current_password
++ end
++
+ end
+