Revision: 14863 http://gar.svn.sourceforge.net/gar/?rev=14863&view=rev Author: phipsy Date: 2011-06-23 14:52:05 +0000 (Thu, 23 Jun 2011)
Log Message: ----------- Puppet 2.6.9 Modified Paths: -------------- csw/mgar/pkg/puppet/trunk/Makefile csw/mgar/pkg/puppet/trunk/checksums csw/mgar/pkg/puppet/trunk/files/pkgutil.rb Modified: csw/mgar/pkg/puppet/trunk/Makefile =================================================================== --- csw/mgar/pkg/puppet/trunk/Makefile 2011-06-23 14:33:04 UTC (rev 14862) +++ csw/mgar/pkg/puppet/trunk/Makefile 2011-06-23 14:52:05 UTC (rev 14863) @@ -7,7 +7,7 @@ # [1] http://garylaw.net/packages/puppet-build.sh NAME = puppet -VERSION = 2.7.1 +VERSION = 2.6.9 CATEGORIES = apps define BLURB @@ -26,9 +26,9 @@ DISTFILES += cswpuppetmasterd DISTFILES += cswusergroup DISTFILES += CSWpuppet.postinstall -# pkgutil.rb is from https://github.com/gw42/puppet/blob/tickets%2Fmaster%2F4258-dev/lib/puppet/provider/package/pkgutil.rb -# Dom Cleal of RedHat has advised this is a good working version -# DISTFILES += pkgutil.rb +# pkgutil.rb is from https://raw.github.com/domcleal/puppet/tickets/master/8011/lib/puppet/provider/package/pkgutil.rb +# Should be headed into 2.7 code - supports -t REPO +DISTFILES += pkgutil.rb DISTFILES += README.CSW DISTFILES += puppet.conf.example-CSW SPKG_SOURCEURL = http://puppetlabs.com/ @@ -71,7 +71,10 @@ INSTALL_SCRIPTS = puppet PATCHFILES = 0003-Use-opt-csw-share-puppet-modules-as-default.patch +# https://projects.puppetlabs.com/issues/6324 +PATCHFILES += 0004-patch-to-smf-provider-6324.patch + CHECKPKG_OVERRIDES_CSWpuppetmaster = surplus-dependency|CSWruby18 CHECKPKG_OVERRIDES_CSWpuppet = surplus-dependency|CSWfacter CHECKPKG_OVERRIDES_CSWpuppet += surplus-dependency|CSWrubyaugeas @@ -103,6 +106,7 @@ --bindir=$(bindir) \ --sbindir=$(sbindir) \ --full + ginstall -m 755 $(FILEDIR)/pkgutil.rb $(DESTDIR)$(rubysitelibdir)/puppet/provider/package cd $(DESTDIR)$(mandir)/man8 && gunzip * (cd $(WORKSRC)/examples/etc/puppet && \ for f in *; do \ Modified: csw/mgar/pkg/puppet/trunk/checksums =================================================================== --- csw/mgar/pkg/puppet/trunk/checksums 2011-06-23 14:33:04 UTC (rev 14862) +++ csw/mgar/pkg/puppet/trunk/checksums 2011-06-23 14:52:05 UTC (rev 14863) @@ -2,4 +2,5 @@ 645543a18050f1d991796d865c53f9a4 puppet-2.6.5.tar.gz 58315e94ff00aedc4a19177877c3e865 puppet-2.6.6.tar.gz 588dc3343ea66983010e8c4eb58af6af puppet-2.6.8.tar.gz +b41bee893aea4624b441a3c29e760c31 puppet-2.6.9.tar.gz 7a0346758af0222dc5e2b2b1a99c44ec puppet-2.7.1.tar.gz Modified: csw/mgar/pkg/puppet/trunk/files/pkgutil.rb =================================================================== --- csw/mgar/pkg/puppet/trunk/files/pkgutil.rb 2011-06-23 14:33:04 UTC (rev 14862) +++ csw/mgar/pkg/puppet/trunk/files/pkgutil.rb 2011-06-23 14:52:05 UTC (rev 14863) @@ -1,76 +1,127 @@ # Packaging using Peter Bonivart's pkgutil program. Puppet::Type.type(:package).provide :pkgutil, :parent => :sun, :source => :sun do desc "Package management using Peter Bonivart's ``pkgutil`` command on Solaris." - pkguti = "pkgutil" + + pkgutil_bin = "pkgutil" if FileTest.executable?("/opt/csw/bin/pkgutil") - pkguti = "/opt/csw/bin/pkgutil" + pkgutil_bin = "/opt/csw/bin/pkgutil" end confine :operatingsystem => :solaris - commands :pkguti => pkguti + commands :pkguti => pkgutil_bin - def self.extended(mod) - unless command(:pkguti) != "pkgutil" - raise Puppet::Error, - "The pkgutil command is missing; pkgutil packaging unavailable" - end - + def self.healthcheck() unless FileTest.exists?("/var/opt/csw/pkgutil/admin") Puppet.notice "It is highly recommended you create '/var/opt/csw/pkgutil/admin'." Puppet.notice "See /var/opt/csw/pkgutil" end + + correct_wgetopts = false + [ "/opt/csw/etc/pkgutil.conf", "/etc/opt/csw/pkgutil.conf" ].each do |confpath| + File.open(confpath) do |conf| + conf.each {|line| correct_wgetopts = true if line =~ /^\s*wgetopts\s*=.*(-nv|-q|--no-verbose|--quiet)/ } + end + end + if ! correct_wgetopts + Puppet.notice "It is highly recommended that you set 'wgetopts=-nv' in your pkgutil.conf." + end end def self.instances(hash = {}) - pkglist(hash).collect do |bhash| - bhash.delete(:avail) - new(bhash) + healthcheck + + # Use the available pkg list (-a) to work out aliases + aliases = {} + availlist.each do |pkg| + aliases[pkg[:name]] = pkg[:alias] end + + # The -c pkglist lists installed packages + pkginsts = [] + output = pkguti(["-c"]) + parse_pkglist(output).each do |pkg| + pkg.delete(:avail) + pkginsts << new(pkg) + + # Create a second instance with the alias if it's different + pkgalias = aliases[pkg[:name]] + if pkgalias and pkg[:name] != pkgalias + apkg = pkg.dup + apkg[:name] = pkgalias + pkginsts << new(apkg) + end + end + + pkginsts end + # Turns a pkgutil -a listing into hashes with the common alias, full + # package name and available version + def self.availlist + output = pkguti ["-a"] + + list = output.split("\n").collect do |line| + next if line =~ /^common\s+package/ # header of package list + next if noise?(line) + + if line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ + { :alias => $1, :name => $2, :avail => $3 } + else + Puppet.warning "Cannot match %s" % line + end + end.reject { |h| h.nil? } + end + + # Turn our pkgutil -c listing into a hash for a single package. + def pkgsingle(resource) + # The --single option speeds up the execution, because it queries + # the package managament system for one package only. + command = ["-c", "--single", resource[:name]] + self.class.parse_pkglist(run_pkgutil(resource, command), { :justme => resource[:name] }) + end + # Turn our pkgutil -c listing into a bunch of hashes. - # Supports :justme => packagename, which uses the optimised --single arg - def self.pkglist(hash) - command = ["-c"] + def self.parse_pkglist(output, hash = {}) + output = output.split("\n") - if hash[:justme] - # The --single option speeds up the execution, because it queries - # the package managament system for one package only. - command << "--single" - command << hash[:justme] + if output[-1] == "Not in catalog" + Puppet.warning "Package not in pkgutil catalog: %s" % hash[:justme] + return nil end - output = pkguti command - - list = output.split("\n").collect do |line| - next if line =~ /^#/ + list = output.collect do |line| next if line =~ /installed\s+catalog/ # header of package list - next if line =~ /^Checking integrity / # use_gpg - next if line =~ /^gpg: / # gpg verification - next if line =~ /^=+> / # catalog fetch - next if line =~ /\d+:\d+:\d+ URL:/ # wget without -q + next if noise?(line) - pkgsplit(line, hash[:justme]) + pkgsplit(line) end.reject { |h| h.nil? } if hash[:justme] - # Ensure we picked up the package line, not any pkgutil noise. - list.reject! { |h| h[:name] != hash[:justme] } - return list[-1] + # Single queries may have been for an alias so return the name requested + if list.any? + list[-1][:name] = hash[:justme] + return list[-1] + end else list.reject! { |h| h[:ensure] == :absent } return list end + end + # Identify common types of pkgutil noise as it downloads catalogs etc + def self.noise?(line) + true if line =~ /^#/ + true if line =~ /^Checking integrity / # use_gpg + true if line =~ /^gpg: / # gpg verification + true if line =~ /^=+> / # catalog fetch + true if line =~ /\d+:\d+:\d+ URL:/ # wget without -q + false end # Split the different lines into hashes. - def self.pkgsplit(line, justme) - if line == "Not in catalog" - Puppet.warning "Package not in pkgutil catalog: %s" % justme - return nil - elsif line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ + def self.pkgsplit(line) + if line =~ /\s*(\S+)\s+(\S+)\s+(.*)/ hash = {} hash[:name] = $1 hash[:ensure] = if $2 == "notinst" @@ -80,10 +131,6 @@ end hash[:avail] = $3 - if justme - hash[:name] = justme - end - if hash[:avail] =~ /^SAME\s*$/ hash[:avail] = hash[:ensure] end @@ -98,18 +145,28 @@ end end + def run_pkgutil(resource, *args) + # Allow source to be one or more URLs pointing to a repository that all + # get passed to pkgutil via one or more -t options + if resource[:source] + pkguti *[resource[:source].map{|src| [ "-t", src ]}, *args].flatten + else + pkguti *args.flatten + end + end + def install - pkguti "-y", "-i", @resource[:name] + run_pkgutil @resource, "-y", "-i", @resource[:name] end # Retrieve the version from the current package file. def latest - hash = self.class.pkglist(:justme => @resource[:name]) + hash = pkgsingle(@resource) hash[:avail] if hash end def query - if hash = self.class.pkglist(:justme => @resource[:name]) + if hash = pkgsingle(@resource) hash else {:ensure => :absent} @@ -117,11 +174,11 @@ end def update - pkguti "-y", "-u", @resource[:name] + run_pkgutil @resource, "-y", "-u", @resource[:name] end def uninstall - pkguti "-y", "-r", @resource[:name] + run_pkgutil @resource, "-y", "-r", @resource[:name] end end This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ devel mailing list devel@lists.opencsw.org https://lists.opencsw.org/mailman/listinfo/devel