summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLamont Granquist <lamont@scriptkiddie.org>2015-06-03 11:30:50 -0700
committerLamont Granquist <lamont@scriptkiddie.org>2015-06-03 11:30:50 -0700
commit42181ed56318851d5c04306e48e54066f6805703 (patch)
treef71c7b9358737d7b1eaec87e01993d1a7661270a
parent770b1b5475d871ed7affa1fef605d64be1922457 (diff)
parent37020da19dab7086a8efcb98b13de5d56a88e9c5 (diff)
downloadchef-42181ed56318851d5c04306e48e54066f6805703.tar.gz
Merge pull request #3477 from chef/lcg/zypper-package
Lcg/zypper package
-rw-r--r--CHANGELOG.md5
-rw-r--r--lib/chef/provider/package/zypper.rb27
-rw-r--r--lib/chef/resource/zypper_package.rb31
-rw-r--r--lib/chef/resources.rb1
-rw-r--r--spec/unit/provider/package/zypper_spec.rb4
5 files changed, 51 insertions, 17 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d0d68ede7a..06407d6112 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,8 +6,8 @@
* [**Steve Lowe**](https://github.com/SteveLowe):
Fix copying ntfs dacl and sacl when they are nil. [pr#3066](https://github.com/chef/chef/pull/3066)
-* [Issue #2247](https://github.com/chef/chef/issues/2247): powershell_script returns 0 for scripts with syntax errors
-* [pr#3080](https://github.com/chef/chef/pull/3080): Issue 2247: powershell_script exit status should be nonzero for syntax errors
+* [Issue #2247](https://github.com/chef/chef/issues/2247): `powershell_script` returns 0 for scripts with syntax errors
+* [pr#3080](https://github.com/chef/chef/pull/3080): Issue 2247: `powershell_script` exit status should be nonzero for syntax errors
* [pr#3441](https://github.com/chef/chef/pull/3441): Add `powershell_out` mixin to core chef
* [pr#3448](https://github.com/chef/chef/pull/3448): Fix `dsc_resource` to work with wmf5 april preview
* [pr#3392](https://github.com/chef/chef/pull/3392): Comment up `Chef::Client` and privatize/deprecate unused things
@@ -20,6 +20,7 @@
* [pr#3442](https://github.com/chef/chef/pull/3442): Add `resource_name` to top-level Resource class to make defining resources easier. `use_automatic_resource_name` also added, to support convention-based resource naming.
* [pr#3447](https://github.com/chef/chef/pull/3447): Add `allowed_actions` and `default_action` to top-level Resource class.
* [pr#3475](https://github.com/chef/chef/pull/3475): Fix `shell_out` timeouts in all package providers to respect timeout property on the resource.
+* [pr#3477](https://github.com/chef/chef/pull/3477): Update `zypper_package` to look like the rest of our package classes.
## 12.4.0
diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb
index f77fb27013..c2a3ac4ba8 100644
--- a/lib/chef/provider/package/zypper.rb
+++ b/lib/chef/provider/package/zypper.rb
@@ -29,47 +29,48 @@ class Chef
class Package
class Zypper < Chef::Provider::Package
+ provides :zypper_package, os: "linux"
+
def load_current_resource
- # FIXME: zypper needs a Chef::Resource::ZypperPackage wired up to :zypper_package
- @current_resource = Chef::Resource::Package.new(@new_resource.name)
- @current_resource.package_name(@new_resource.package_name)
+ @current_resource = Chef::Resource::ZypperPackage.new(new_resource.name)
+ current_resource.package_name(new_resource.package_name)
is_installed=false
is_out_of_date=false
version=''
oud_version=''
- Chef::Log.debug("#{@new_resource} checking zypper")
- status = shell_out_with_timeout("zypper --non-interactive info #{@new_resource.package_name}")
+ Chef::Log.debug("#{new_resource} checking zypper")
+ status = shell_out_with_timeout("zypper --non-interactive info #{new_resource.package_name}")
status.stdout.each_line do |line|
case line
when /^Version: (.+)$/
version = $1
- Chef::Log.debug("#{@new_resource} version #{$1}")
+ Chef::Log.debug("#{new_resource} version #{$1}")
when /^Installed: Yes$/
is_installed=true
- Chef::Log.debug("#{@new_resource} is installed")
+ Chef::Log.debug("#{new_resource} is installed")
when /^Installed: No$/
is_installed=false
- Chef::Log.debug("#{@new_resource} is not installed")
+ Chef::Log.debug("#{new_resource} is not installed")
when /^Status: out-of-date \(version (.+) installed\)$/
is_out_of_date=true
oud_version=$1
- Chef::Log.debug("#{@new_resource} out of date version #{$1}")
+ Chef::Log.debug("#{new_resource} out of date version #{$1}")
end
end
if is_installed==false
@candidate_version=version
- @current_resource.version(nil)
+ current_resource.version(nil)
end
if is_installed==true
if is_out_of_date==true
- @current_resource.version(oud_version)
+ current_resource.version(oud_version)
@candidate_version=version
else
- @current_resource.version(version)
+ current_resource.version(version)
@candidate_version=version
end
end
@@ -78,7 +79,7 @@ class Chef
raise Chef::Exceptions::Package, "zypper failed - #{status.inspect}!"
end
- @current_resource
+ current_resource
end
def zypper_version()
diff --git a/lib/chef/resource/zypper_package.rb b/lib/chef/resource/zypper_package.rb
new file mode 100644
index 0000000000..74cdf72e15
--- /dev/null
+++ b/lib/chef/resource/zypper_package.rb
@@ -0,0 +1,31 @@
+#
+# Author:: Joe Williams (<joe@joetify.com>)
+# Copyright:: Copyright (c) 2009 Joe Williams
+# License:: Apache License, Version 2.0
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+require 'chef/resource/package'
+
+class Chef
+ class Resource
+ class ZypperPackage < Chef::Resource::Package
+
+ provides :package, platform_family: "suse"
+
+ use_automatic_resource_name
+
+ end
+ end
+end
diff --git a/lib/chef/resources.rb b/lib/chef/resources.rb
index 40b12a7c5f..af4dd8a642 100644
--- a/lib/chef/resources.rb
+++ b/lib/chef/resources.rb
@@ -80,6 +80,7 @@ require 'chef/resource/windows_package'
require 'chef/resource/yum_package'
require 'chef/resource/lwrp_base'
require 'chef/resource/bff_package'
+require 'chef/resource/zypper_package'
begin
# Optional resources chef_node, chef_client, machine, machine_image, etc.
diff --git a/spec/unit/provider/package/zypper_spec.rb b/spec/unit/provider/package/zypper_spec.rb
index ecff9477fd..18ff739bc6 100644
--- a/spec/unit/provider/package/zypper_spec.rb
+++ b/spec/unit/provider/package/zypper_spec.rb
@@ -19,9 +19,9 @@
require 'spec_helper'
describe Chef::Provider::Package::Zypper do
- let!(:new_resource) { Chef::Resource::Package.new("cups") }
+ let!(:new_resource) { Chef::Resource::ZypperPackage.new("cups") }
- let!(:current_resource) { Chef::Resource::Package.new("cups") }
+ let!(:current_resource) { Chef::Resource::ZypperPackage.new("cups") }
let(:provider) do
node = Chef::Node.new