[csw-devel] SF.net SVN: gar:[13722] csw/mgar/pkg/puppet/trunk

phipsy at users.sourceforge.net phipsy at users.sourceforge.net
Thu Mar 10 12:34:19 CET 2011


Revision: 13722
          http://gar.svn.sourceforge.net/gar/?rev=13722&view=rev
Author:   phipsy
Date:     2011-03-10 11:34:18 +0000 (Thu, 10 Mar 2011)

Log Message:
-----------
Updated puppet to 2.6.6

Modified Paths:
--------------
    csw/mgar/pkg/puppet/trunk/Makefile
    csw/mgar/pkg/puppet/trunk/checksums

Added Paths:
-----------
    csw/mgar/pkg/puppet/trunk/files/pkgutil.rb

Modified: csw/mgar/pkg/puppet/trunk/Makefile
===================================================================
--- csw/mgar/pkg/puppet/trunk/Makefile	2011-03-10 03:22:38 UTC (rev 13721)
+++ csw/mgar/pkg/puppet/trunk/Makefile	2011-03-10 11:34:18 UTC (rev 13722)
@@ -7,7 +7,7 @@
 # [1] http://garylaw.net/packages/puppet-build.sh
 
 NAME = puppet
-VERSION = 2.6.4
+VERSION = 2.6.6
 CATEGORIES = apps
 
 define BLURB
@@ -26,6 +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
 SPKG_SOURCEURL = http://puppetlabs.com/
 
 INITSMF += $(sysconfdir)/init\.d/cswpuppetd
@@ -53,16 +56,18 @@
 
 ARCHALL = 1
 
-sysconfdir    = /etc$(prefix)
-localstatedir = /var$(prefix)
+sysconfdir     = /etc$(prefix)
+localstatedir  = /var$(prefix)
+rubysitelibdir = $(shell ruby -rrbconfig -e "puts Config::CONFIG['sitelibdir']")
 
 CONFIGURE_SCRIPTS =
 BUILD_SCRIPTS     =
 TEST_SCRIPTS      =
 INSTALL_SCRIPTS   = puppet
 
-PATCHFILES  = 0001-pkgutil-support.patch
-PATCHFILES += 0002-Using-the-single-option-of-pkgutil.patch
+# Not required. As soon as I've confirmed the downloaded version works well, I'll cut this fromt he Makefile.
+# PATCHFILES  = 0001-pkgutil-support.patch
+# PATCHFILES += 0002-Using-the-single-option-of-pkgutil.patch
 PATCHFILES += 0003-Use-opt-csw-share-puppet-modules-as-default.patch
 
 CHECKPKG_OVERRIDES_CSWpuppet       += surplus-dependency|CSWfacter
@@ -92,6 +97,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-03-10 03:22:38 UTC (rev 13721)
+++ csw/mgar/pkg/puppet/trunk/checksums	2011-03-10 11:34:18 UTC (rev 13722)
@@ -1,2 +1,3 @@
 c0b86f40c8000dae2f0f7f2f91579c2a  puppet-2.6.4.tar.gz
 645543a18050f1d991796d865c53f9a4  puppet-2.6.5.tar.gz
+58315e94ff00aedc4a19177877c3e865  puppet-2.6.6.tar.gz

Added: csw/mgar/pkg/puppet/trunk/files/pkgutil.rb
===================================================================
--- csw/mgar/pkg/puppet/trunk/files/pkgutil.rb	                        (rev 0)
+++ csw/mgar/pkg/puppet/trunk/files/pkgutil.rb	2011-03-10 11:34:18 UTC (rev 13722)
@@ -0,0 +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"
+  if FileTest.executable?("/opt/csw/bin/pkgutil")
+    pkguti = "/opt/csw/bin/pkgutil"
+  end
+
+  confine :operatingsystem => :solaris
+
+  commands :pkguti => pkguti
+
+  def self.extended(mod)
+    unless command(:pkguti) != "pkgutil"
+      raise Puppet::Error,
+        "The pkgutil command is missing; pkgutil packaging unavailable"
+    end
+
+    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
+  end
+
+  def self.instances(hash = {})
+    pkglist(hash).collect do |bhash|
+      bhash.delete(:avail)
+      new(bhash)
+    end
+  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"]
+
+    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]
+    end
+
+    output = pkguti command
+
+    list = output.split("\n").collect do |line|
+      next if 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
+
+      pkgsplit(line, hash[:justme])
+    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]
+    else
+      list.reject! { |h| h[:ensure] == :absent }
+      return list
+    end
+
+  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+(.*)/
+      hash = {}
+      hash[:name] = $1
+      hash[:ensure] = if $2 == "notinst"
+        :absent
+      else
+        $2
+      end
+      hash[:avail] = $3
+
+      if justme
+        hash[:name] = justme
+      end
+
+      if hash[:avail] =~ /^SAME\s*$/
+        hash[:avail] = hash[:ensure]
+      end
+
+      # Use the name method, so it works with subclasses.
+      hash[:provider] = self.name
+
+      return hash
+    else
+      Puppet.warning "Cannot match %s" % line
+      return nil
+    end
+  end
+
+  def install
+    pkguti "-y", "-i", @resource[:name]
+  end
+
+  # Retrieve the version from the current package file.
+  def latest
+    hash = self.class.pkglist(:justme => @resource[:name])
+    hash[:avail] if hash
+  end
+
+  def query
+    if hash = self.class.pkglist(:justme => @resource[:name])
+      hash
+    else
+      {:ensure => :absent}
+    end
+  end
+
+  def update
+    pkguti "-y", "-u", @resource[:name]
+  end
+
+  def uninstall
+    pkguti "-y", "-r", @resource[:name]
+  end
+end
+


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.


More information about the devel mailing list