Issue #2382 has been updated by a zen.

File ports.rb.patch added

Attached patch is a suggestion to solve this problem within the ports provider.
Tested sucessfully on my FreeBSD 9.x machines using puppet 3.2.3 and 3.2.4.

----------------------------------------
Feature #2382: package provider ports: portupgrade does not work
https://projects.puppetlabs.com/issues/2382#change-97007

* Author: Ryan Hutchison
* Status: Code Insufficient
* Priority: Normal
* Assignee: Ryan Hutchison
* Category: package
* Target version: 
* Affected Puppet version: 0.24.8
* Keywords: 
* Branch: 
----------------------------------------
In puppet/provider/package/ports.rb the command passes argument -N which 
prevents installed ports from being upgraded.

* Modified type 'packages.rb'.
> * latest now calls install when port is absent and update when port exists, 
> but is not the latest version.
* Modified package provider 'ports.rb'.
> * update now runs portupgrade with -M BATCH=yes instead of calling install.
> * install runs as normal.


Patch:
<pre>
--- puppet/provider/package/ports.rb    2009-07-01 14:22:00.000000000 -0400
+++ puppet-patched/provider/package/ports.rb    2009-07-01 14:25:45.000000000 
-0400
@@ -91,7 +91,13 @@ Puppet::Type.type(:package).provide :por
     end

     def update
-        install()
+        # -M: yes, we're a batch, so don't ask any questions
+        cmd = %w{-M BATCH=yes} << @resource[:name]
+
+        output = portupgrade(*cmd)
+        if output =~ /\*\* No such /
+            raise Puppet::ExecutionFailure, "Could not find package %s" % 
@resource[:name]
+        end
     end
 end

--- puppet/type/package.rb      2009-07-01 14:22:01.000000000 -0400
+++ puppet-patched/type/package.rb      2009-07-01 14:25:22.000000000 -0400
@@ -68,15 +68,20 @@ module Puppet
                 # in the "install" method.  So, check the current state now,
                 # to compare against later.
                 current = self.retrieve
-                begin
-                    provider.update
-                rescue => detail
-                    self.fail "Could not update: %s" % detail
-                end

                 if current == :absent
+                    begin
+                        provider.install
+                    rescue => detail
+                        self.fail "Could not install: %s" % detail
+                    end
                     :package_installed
                 else
+                    begin
+                        provider.update
+                    rescue => detail
+                        self.fail "Could not update: %s" % detail
+                    end
                     :package_changed
                 end
             end
</pre>> 


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to