summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG2
-rw-r--r--lib/puppet/provider/package/hpux.rb41
-rw-r--r--spec/unit/provider/package/hpux.rb52
3 files changed, 95 insertions, 0 deletions
diff --git a/CHANGELOG b/CHANGELOG
index b6f822362..bf0fea229 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 000000000..aa756ead0
--- /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 000000000..32eae5189
--- /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