From romain@blogreen.org  Wed Jul  6 07:23:34 2011
Return-Path: <romain@blogreen.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 776CD106566C
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  6 Jul 2011 07:23:34 +0000 (UTC)
	(envelope-from romain@blogreen.org)
Received: from marvin.blogreen.org (smortex-1-pt.tunnel.tserv11.ams1.ipv6.he.net [IPv6:2001:470:1f14:7c2::2])
	by mx1.freebsd.org (Postfix) with ESMTP id B884D8FC15
	for <FreeBSD-gnats-submit@freebsd.org>; Wed,  6 Jul 2011 07:23:33 +0000 (UTC)
Received: by marvin.blogreen.org (Postfix, from userid 1001)
	id 0E64D1475; Wed,  6 Jul 2011 09:23:31 +0200 (CEST)
Message-Id: <20110706072331.0E64D1475@marvin.blogreen.org>
Date: Wed,  6 Jul 2011 09:23:31 +0200 (CEST)
From: Romain Tartiere <romain@FreeBSD.org>
Reply-To: Romain Tartiere <romain@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: sysutils/puppet: Fix for optpatched 'freebsd' package provider
X-Send-Pr-Version: 3.113
X-GNATS-Notify: raj@csub.edu

>Number:         158681
>Category:       ports
>Synopsis:       sysutils/puppet: Fix for optpatched 'freebsd' package provider
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    romain
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Wed Jul 06 07:30:10 UTC 2011
>Closed-Date:    Thu Jul 07 17:26:39 UTC 2011
>Last-Modified:  Thu Jul  7 17:30:10 UTC 2011
>Originator:     Romain Tartiere
>Release:        FreeBSD 8.2-STABLE amd64
>Organization:
>Environment:
System: FreeBSD marvin.blogreen.org 8.2-STABLE FreeBSD 8.2-STABLE #7 r222417: Sat May 28 13:23:35 CEST 2011 root@marvin.blogreen.org:/usr/obj/usr/src/sys/MARVIN amd64


	
>Description:

The puppet port will patch the 'freebsd' packages provider if the
PACKAGE_ORIGIN is set (default).  The resulting provider will fail to start
with message:

  err: Could not retrieve catalog from remote server: Could not intern from pson: Could not autoload package: Could not autoload /usr/local/lib/ruby/site_ruby/1.8/puppet/provider/package/freebsd.rb: Could not find parent provider Puppet::Util::Package of freebsd

(and BTW, why is this option enabled by default, and could not the patch just
add a new provider with a different name?)

>How-To-Repeat:

1. Build puppet package with default options;
2. Install on a master and client machine;
3. Edit puppetmaster manifests to install software on clients;
4. Run the agent

>Fix:

Adding the following require line fix the error:

  require 'puppet/provider/package'

Please note that the modified implementation do not fit my environment and I
could not test beyond a 404 error when fetching '/Latest/INDEX.bz2'.

Here is a patch (git and patchtool do things slightly differently hence the
quite big patch whole not much change):

--- puppet.diff begins here ---
diff -Nur /var/cache/portshaker/ports/sysutils/puppet/files/optpatch-package_origin ./files/optpatch-package_origin
--- /var/cache/portshaker/ports/sysutils/puppet/files/optpatch-package_origin	2011-04-10 18:11:49.000000000 +0200
+++ ./files/optpatch-package_origin	2011-07-06 02:33:21.902540033 +0200
@@ -1,8 +1,9 @@
-diff --git lib/puppet/provider/package/freebsd.rb lib/puppet/provider/package/freebsd.rb
-index e10a20b..f36e29e 100755
---- lib/puppet/provider/package/freebsd.rb
+
+$FreeBSD$
+
+--- lib/puppet/provider/package/freebsd.rb.orig
 +++ lib/puppet/provider/package/freebsd.rb
-@@ -1,37 +1,165 @@
+@@ -1,37 +1,166 @@
 -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
@@ -12,6 +13,7 @@
 +require 'open-uri'
 +require 'net/ftp'
 +require 'bz2'
++require 'puppet/provider/package'
  
 -  commands :pkginfo => "/usr/sbin/pkg_info",
 -    :pkgadd => "/usr/sbin/pkg_add",
@@ -28,12 +30,12 @@
  
    confine :operatingsystem => :freebsd
 +  defaultfor :operatingsystem => :freebsd
-+
-+  @@lock = Mutex.new
-+  @@ports_index = nil
  
 -  def self.listcmd
 -    command(:pkginfo)
++  @@lock = Mutex.new
++  @@ports_index = nil
++
 +  # fix bug in URI::FTP merge method that tries to set typecode
 +  # even when other is a string.
 +  class URI::FTP
@@ -54,7 +56,11 @@
 +      :pkg_version => pkg_string.split("-")[-1],
 +    }
 +  end
-+
+ 
+-    if @resource[:source] =~ /\/$/
+-      if @resource[:source] =~ /^(ftp|https?):/
+-        Puppet::Util::Execution::withenv :PACKAGESITE => @resource[:source] do
+-          pkgadd "-r", @resource[:name]
 +  def self.unparse_pkg_info(pkg_info)
 +    [:pkg_name, :pkg_version].map { |key| pkg_info[key] }.join("-")
 +  end
@@ -70,11 +76,7 @@
 +    end
 +    origin
 +  end
- 
--    if @resource[:source] =~ /\/$/
--      if @resource[:source] =~ /^(ftp|https?):/
--        Puppet::Util::Execution::withenv :PACKAGESITE => @resource[:source] do
--          pkgadd "-r", @resource[:name]
++
 +  def self.instances
 +    packages = []
 +    output = pkginfo "-aoQ"
@@ -190,7 +192,7 @@
    end
  
    def query
-@@ -44,7 +172,7 @@ Puppet::Type.type(:package).provide :freebsd, :parent => :openbsd do
+@@ -44,7 +173,7 @@
    end
  
    def uninstall
--- puppet.diff ends here ---


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->romain 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Wed Jul 6 07:30:22 UTC 2011 
Responsible-Changed-Why:  
Submitter has GNATS access (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158681 
State-Changed-From-To: open->feedback 
State-Changed-By: edwin 
State-Changed-When: Wed Jul 6 07:30:32 UTC 2011 
State-Changed-Why:  
Awaiting maintainers feedback (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158681 

From: Edwin Groothuis <edwin@FreeBSD.org>
To: raj@csub.edu
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/158681: sysutils/puppet: Fix for optpatched 'freebsd' package provider
Date: Wed, 6 Jul 2011 07:30:28 UT

 Maintainer of sysutils/puppet,
 
 Please note that PR ports/158681 has just been submitted.
 
 If it contains a patch for an upgrade, an enhancement or a bug fix
 you agree on, reply to this email stating that you approve the patch
 and a committer will take care of it.
 
 The full text of the PR can be found at:
     http://www.freebsd.org/cgi/query-pr.cgi?pr=ports/158681
 
 -- 
 Edwin Groothuis via the GNATS Auto Assign Tool
 edwin@FreeBSD.org

From: Russell Jackson <raj@csub.edu>
To: bug-followup@FreeBSD.org, romain@FreeBSD.org
Cc:  
Subject: Re: ports/158681: sysutils/puppet: Fix for optpatched 'freebsd' package
 provider
Date: Wed, 06 Jul 2011 20:29:38 -0700

 > The puppet port will patch the 'freebsd' packages provider if the PACKAGE_ORIGIN is
 > set (default). The resulting provider will fail to start with message:
 >
 > err: Could not retrieve catalog from remote server: Could not intern from pson: Could
 > not autoload package: Could not autoload
 > /usr/local/lib/ruby/site_ruby/1.8/puppet/provider/package/freebsd.rb: Could not find
 > parent provider Puppet::Util::Package of freebsd
 
 I'm unable to reproduce this error on any of my boxes.
 
 > (and BTW, why is this option enabled by default,
 
 Because the original provider is inherently broken and to get wider testing. You're the 
 first person I've heard from regarding problems with this patch.
 
 Also see https://projects.puppetlabs.com/issues/4996.
 
 > and could not the patch just add a new provider with a different name?)
 
 Again see above. This patch is going in upstream and there's no sense leaving a broken 
 provider sitting in the tree.
 
 
 > Please note that the modified implementation do not fit my environment
 
 Could you be more specific? It should work identically to the old provider with the 
 exception that you specify the "package name" as the port origin. e.g. net/openldap24. If 
 it doesn't, that's a bug.
 
 > and I could not test beyond a 404 error when fetching '/Latest/INDEX.bz2'.
 
 Could you post the output from puppet agent --debug when you get this error?
 
 -- 
 Russell A. Jackson <raj@csub.edu>
 Network Analyst
 California State University, Bakersfield

From: Romain =?iso-8859-1?Q?Tarti=E8re?= <romain@FreeBSD.org>
To: Russell Jackson <raj@csub.edu>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/158681: sysutils/puppet: Fix for optpatched 'freebsd'
 package provider
Date: Thu, 7 Jul 2011 09:29:32 +0200

 --AqsLC8rIMeq19msA
 Content-Type: text/plain; charset=iso-8859-1
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 Hi Russel!
 
 On Wed, Jul 06, 2011 at 08:29:38PM -0700, Russell Jackson wrote:
 > > The puppet port will patch the 'freebsd' packages provider if the PACKA=
 GE_ORIGIN is
 > > set (default). The resulting provider will fail to start with message:
 > >
 > > err: Could not retrieve catalog from remote server: Could not intern fr=
 om pson: Could
 > > not autoload package: Could not autoload
 > > /usr/local/lib/ruby/site_ruby/1.8/puppet/provider/package/freebsd.rb: C=
 ould not find
 > > parent provider Puppet::Util::Package of freebsd
 >=20
 > I'm unable to reproduce this error on any of my boxes.
 D'oh.  I just gave it a try on the puppetmaster machine and it looks to
 work with the default patched provider.  The machine where it fails is
 currently down so I'll check again later and tell you.
 
 > > (and BTW, why is this option enabled by default,
 >=20
 > Because the original provider is inherently broken and to get wider testi=
 ng. You're the=20
 > first person I've heard from regarding problems with this patch.
 >=20
 > Also see https://projects.puppetlabs.com/issues/4996.
 I was not aware of this, good news!
 
 > > and could not the patch just add a new provider with a different name?)
 >=20
 > Again see above. This patch is going in upstream and there's no sense lea=
 ving a broken=20
 > provider sitting in the tree.
 Well, I have not used the original version, and though it was probably
 somewhat usable...  I figured-out I was wrong when I started to add
 rules to install the autotools in my manifests (LATEST_LINK tweaked name
 troubles the legacy 'freebsd' provider)
 
 > > Please note that the modified implementation do not fit my environment
 >=20
 > Could you be more specific? It should work identically to the old provide=
 r with the=20
 > exception that you specify the "package name" as the port origin. e.g. ne=
 t/openldap24. If=20
 > it doesn't, that's a bug.
 (indeed it works, see comment bellow)
 
 > > and I could not test beyond a 404 error when fetching '/Latest/INDEX.bz=
 2'.
 >=20
 > Could you post the output from puppet agent --debug when you get this err=
 or?
 Looks like the { source =3D> "..." } had a trailing 'Latest/', trivial to
 fix.
 
 I realized that the implementation would not allow me to keep packages
 up-to-date (ensure =3D> latest) because this require the 'upgradeable'
 feature.  The legacy provider does not have this feature neither.  I
 started a custom provider to achieve all this, using
 ports-mgmt/portmaster.  If your patch is still being worked-on upstream
 before integration, and this is a desired feature, I would be happy to
 help on that point (note that I started to work on this yesterday and
 the upgradeable feature is still only on the TODO list).
 
 To sum-up what happened:
   - I saw the error I am reporting (Could not find parent provider
     Puppet::Util::Package of freebsd);
   - I edited the file to fix it;
   - I saw the provider would not keep my packages up-to-date;
   - I fixed the provider;
   - I checked the provided could start;
   - I sent this PR;
   - I did not tried to use the provider.
 
 I'll try tonight to see what happens on the system where it failed
 yesterday, and reply to this PR.  I'll also work on the 'upgradeable'
 feature, if you are interested in this, just tell me.
 
 Thanks!
 Romain
 
 --=20
 Romain Tarti=E8re <romain@FreeBSD.org>  http://people.FreeBSD.org/~romain/
 pgp: 8234 9A78 E7C0 B807 0B59  80FF BA4D 1D95 5112 336F (ID: 0x5112336F)
 (plain text =3Dnon-HTML=3D PGP/GPG encrypted/signed e-mail much appreciated)
 
 --AqsLC8rIMeq19msA
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.17 (FreeBSD)
 
 iQGcBAEBAgAGBQJOFWBZAAoJELpNHZVREjNvjuIMAJ8MMkkrKLtjfrQ0rSSRS4xK
 h7hrfAP/e5L7ymkrk2DYme80y+ZMwEmRke+w+BkdjjOkqT6AMcq94KmjbXeQiHNP
 BOVwceBJqvChPJzhIB7W6dOSVZWW6pP76166Do5hpy67ac/gRpJhN3m3gtav0hpe
 0oNPHiQNyZ4fYsXdbYf3zOq1G0nO3CbNYaPPx4wm53w1wJIUEIRPyrsJ1trcAbs/
 /eTKuXiC+jyzuExg8tPw7TqPUv+bSIu0UV1p2UPJCQNW4OSCDPOtkIbSp7GyY4NV
 k4FZhtTk+X9TKW6BaC12Bo0ZUYSrUYmmrLG3F+1pZbmwu4GiYA2locSh0XkRqkAx
 9BC1+bylbH9qywTKXsv+nvjgW9iUtv/BTZOOWFwfSBCs5BVdQ/JO9/o/Dd+eTez3
 u8/Ux1BpMGM5JaOLigee1CuIeYsZYf/MXHHkFPas0H3ShjnlUxUVio1k7LbmcU8P
 RgZUK4rwCni0y0w6ae1Lntzx/F+dfPsewotSMCB5bQ==
 =Nxw/
 -----END PGP SIGNATURE-----
 
 --AqsLC8rIMeq19msA--
State-Changed-From-To: feedback->closed 
State-Changed-By: romain 
State-Changed-When: Thu Jul 7 17:26:38 UTC 2011 
State-Changed-Why:  
Invalid 

http://www.freebsd.org/cgi/query-pr.cgi?pr=158681 

From: Romain =?iso-8859-1?Q?Tarti=E8re?= <romain@FreeBSD.org>
To: Russell Jackson <raj@csub.edu>
Cc: bug-followup@FreeBSD.org
Subject: Re: ports/158681: sysutils/puppet: Fix for optpatched 'freebsd'
 package provider
Date: Thu, 7 Jul 2011 19:26:02 +0200

 --PEIAKu/WMn1b1Hv9
 Content-Type: text/plain; charset=iso-8859-1
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 
 On Thu, Jul 07, 2011 at 09:29:32AM +0200, Romain Tarti=E8re wrote:
 > The machine where it fails is currently down so I'll check again later
 > and tell you.
 
 I changed the "portmaster" provider to "freebsd" and it worked.
 
 I removed all packages, installed puppet by hand and run the agent,
 everything went fine.
 
 I don't know what was wrong but I might had some error somewhere that
 triggered the error in the freebsd package provider.
 
 I'll close the PR, sorry for the noise...
 
 --=20
 Romain Tarti=E8re <romain@FreeBSD.org>  http://people.FreeBSD.org/~romain/
 pgp: 8234 9A78 E7C0 B807 0B59  80FF BA4D 1D95 5112 336F (ID: 0x5112336F)
 (plain text =3Dnon-HTML=3D PGP/GPG encrypted/signed e-mail much appreciated)
 
 --PEIAKu/WMn1b1Hv9
 Content-Type: application/pgp-signature
 
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v2.0.17 (FreeBSD)
 
 iQGcBAEBAgAGBQJOFewoAAoJELpNHZVREjNv+lEL/AqUN4rAWRKsPBgaVdwVV29p
 aOd8x8oSsZ+NsE7xhqsMtjJlOG3AFJscnEpBhOggjTGDtNE3mdcqOigmbahdOiaU
 AXWCAi9OK/Y/jX9fMlYH0I6gg8JDBt6zBiRvIH2mtowDwP7iJL6Gz93viXsC5sin
 iNwfKY7aRhM09r+oiS+35nbXI2RHXeagtCgqVTTWZNJYBBY4OgpglAYDABgdfrqw
 zrxcdVaPY0DwVPYgFiKlVvOadEWEfWm8dsIo8cwCK2JWvmCM48k6Gqy2tv7FrHZb
 G8zVaTA3QJadp2YrgGgTImBUb/yhN+mk6gpNRp5nam/bc3rhqxZfMiXpJmu46ZK0
 CAvOy8ILC0mb9YHqLudV5bwyJkO1D0x1KlOCqsrhVTHgmedpah6+6WhX06usCVMI
 2x38gRWNkI6/dyymqcKum+BM2RaUx/cSWOR7undBe2ryNWDUtP82ExBU94RSafqL
 I2QO6EgMjE+g+q8hcjDCOqzAQVr3O9O34A4QEb0/ww==
 =VNTm
 -----END PGP SIGNATURE-----
 
 --PEIAKu/WMn1b1Hv9--
>Unformatted:
