summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Waldt <waldt@b1-systems.de>2016-09-29 14:13:44 +0200
committerEike Waldt <waldt@b1-systems.de>2016-09-29 14:13:44 +0200
commitee54399ab4ec5b26f4fd3fd0b03a16af36e16f4a (patch)
tree0e4176427b72240d658f5f5a6c760925fa20cd43
parentefbdada70840bb6c005e96ba998143fd9ba95ece (diff)
downloadchef-ee54399ab4ec5b26f4fd3fd0b03a16af36e16f4a.tar.gz
added corrections mentioned by @lamont-granquist in https://github.com/chef/chef/pull/5395
-rw-r--r--lib/chef/provider/package.rb48
-rw-r--r--lib/chef/provider/package/zypper.rb3
2 files changed, 29 insertions, 22 deletions
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index 0f1adfb3d0..7e635cc3ad 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -218,27 +218,33 @@ class Chef
end
end
- def action_lock
- multipackage_api_adapter(@current_resource.package_name, @new_resource.version) do |name, version|
- if package_locked(name, version) == true
- Chef::Log.debug("#{new_resource} is already locked")
- else
- lock_package(name, version)
- Chef::Log.info("#{@new_resource} locked")
- end
- end
- end
-
- def action_unlock
- multipackage_api_adapter(@current_resource.package_name, @new_resource.version) do |name, version|
- if package_locked(name, version) == false
- Chef::Log.debug("#{new_resource} is already unlocked")
- else
- unlock_package(name, version)
- Chef::Log.info("#{@new_resource} unlocked")
- end
- end
- end
+ def action_lock
+ if package_locked(@new_resource.name, @new_resource.version) == false
+ description = @new_resource.version ? "version #{@new_resource.version} of " : ""
+ converge_by("lock #{description}package #{@current_resource.package_name}") do
+ multipackage_api_adapter(@current_resource.package_name, @new_resource.version) do |name, version|
+ lock_package(name, version)
+ Chef::Log.info("#{@new_resource} locked")
+ end
+ end
+ else
+ Chef::Log.debug("#{new_resource} is already locked")
+ end
+ end
+
+ def action_unlock
+ if package_locked(@new_resource.name, @new_resource.version) == true
+ description = @new_resource.version ? "version #{@new_resource.version} of " : ""
+ converge_by("unlock #{description}package #{@current_resource.package_name}") do
+ multipackage_api_adapter(@current_resource.package_name, @new_resource.version) do |name, version|
+ unlock_package(name, version)
+ Chef::Log.info("#{@new_resource} unlocked")
+ end
+ end
+ else
+ Chef::Log.debug("#{new_resource} is already unlocked")
+ end
+ end
# @todo use composition rather than inheritance
diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb
index 0fd5f00f49..edad45c3e4 100644
--- a/lib/chef/provider/package/zypper.rb
+++ b/lib/chef/provider/package/zypper.rb
@@ -79,7 +79,8 @@ class Chef
islocked = false
locked = shell_out_with_timeout!("zypper locks")
locked.stdout.each_line do |line|
- if line.split("|").shift(2).last.strip == name.first
+ line_package = line.split("|").shift(2).last.strip
+ if line_package == name
islocked = true
end
end