[Pkg-puppet-devel] [SCM] Puppet packaging for Debian branch, master, updated. debian/0.24.6-1-356-g5718585

James Turnbull james at lovedthanlost.net
Fri Jan 23 14:20:49 UTC 2009


The following commit has been merged in the master branch:
commit b6609ee5f4e6bffc467da4f3f9623f22e9e07095
Author: Mark Plaksin <happy at usg.edu>
Date:   Thu Aug 14 16:06:54 2008 -0400

    Fixed #1508 - Add HP-UX package provider.

diff --git a/CHANGELOG b/CHANGELOG
index b6f8223..bf0fea2 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,4 +1,6 @@
 0.24.x
+    Fixed #1508 - Added HP-UX package provider
+
     Fixed #1502 - Fixed poor stored configuration performance
 
     Fixed #1510 - Storeconfiguration fixed for Rails 2.1
diff --git a/lib/puppet/provider/package/hpux.rb b/lib/puppet/provider/package/hpux.rb
new file mode 100644
index 0000000..aa756ea
--- /dev/null
+++ b/lib/puppet/provider/package/hpux.rb
@@ -0,0 +1,41 @@
+# HP-UX packaging.
+
+require 'puppet/provider/package'
+
+Puppet::Type.type(:package).provide :hpux, :parent => Puppet::Provider::Package do
+    desc "HP-UX's packaging system."
+    commands :swinstall => "/usr/sbin/swinstall",
+             :swlist => "/usr/sbin/swlist",
+             :swremove => "/usr/sbin/swremove"
+    defaultfor :operatingsystem => 'hp-ux'
+    
+    def self.instances
+        # TODO:  This is very hard on HP-UX!
+        []
+    end
+    
+    # source and name are required
+    def install
+        raise ArgumentError, "source must be provided to install HP-UX packages" unless resource[:source]
+        args = standard_args + ["-s", resource[:source], resource[:name]]
+        swinstall(*args)
+    end
+    
+    def query
+        begin
+            swlist resource[:name]
+            {:ensure => :present}
+        rescue
+            {:ensure => :absent}
+        end
+    end
+    
+    def uninstall
+        args = standard_args + [resource[:name]]
+        swremove(*args)
+    end
+    
+    def standard_args
+        return ["-x", "mount_all_filesystems=false"]
+    end
+end
diff --git a/spec/unit/provider/package/hpux.rb b/spec/unit/provider/package/hpux.rb
new file mode 100644
index 0000000..32eae51
--- /dev/null
+++ b/spec/unit/provider/package/hpux.rb
@@ -0,0 +1,52 @@
+#!/usr/bin/env ruby
+
+require File.dirname(__FILE__) + '/../../../spec_helper'
+
+provider_class = Puppet::Type.type(:package).provider(:hpux)
+
+describe provider_class do
+    before(:each) do
+        # Create a mock resource
+        @resource = stub 'resource'
+
+        # A catch all; no parameters set
+        @resource.stubs(:[]).returns(nil)
+
+        # But set name and source
+        @resource.stubs(:[]).with(:name).returns "mypackage"
+        @resource.stubs(:[]).with(:source).returns "mysource"
+        @resource.stubs(:[]).with(:ensure).returns :installed
+
+        @provider = provider_class.new
+        @provider.stubs(:resource).returns @resource
+    end
+
+    it "should have an install method" do
+        @provider = provider_class.new
+        @provider.should respond_to(:install)
+    end
+
+    it "should have an uninstall method" do
+        @provider = provider_class.new
+        @provider.should respond_to(:uninstall)
+    end
+
+    it "should have a swlist method" do
+        @provider = provider_class.new
+        @provider.should respond_to(:swlist)
+    end
+
+    describe "when installing" do
+        it "should use a command-line like 'swinstall -x mount_all_filesystems=false -s SOURCE PACKAGE-NAME'" do
+            @provider.expects(:swinstall).with('-x', 'mount_all_filesystems=false', '-s', 'mysource', 'mypackage')
+            @provider.install
+        end
+    end
+
+    describe "when uninstalling" do
+        it "should use a command-line like 'swremove -x mount_all_filesystems=false PACKAGE-NAME'" do
+            @provider.expects(:swremove).with('-x', 'mount_all_filesystems=false', 'mypackage')
+            @provider.uninstall
+        end
+    end
+ end

-- 
Puppet packaging for Debian



More information about the Pkg-puppet-devel mailing list