diff options
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/provider/package/apt.rb | 22 | ||||
-rw-r--r-- | lib/chef/provider/package/zypper.rb | 22 |
2 files changed, 32 insertions, 12 deletions
diff --git a/lib/chef/provider/package/apt.rb b/lib/chef/provider/package/apt.rb index 2692ec9f15..798abf4680 100644 --- a/lib/chef/provider/package/apt.rb +++ b/lib/chef/provider/package/apt.rb @@ -70,12 +70,22 @@ class Chef @candidate_version ||= get_candidate_versions end - def package_locked(name, version) - locked = shell_out_compact_timeout!("apt-mark", "showhold") - locked_packages = locked.stdout.each_line.map do |line| - line.strip - end - name.all? { |n| locked_packages.include? n } + def packages_all_locked?(names, versions) + names.all? { |n| locked_packages.include? n } + end + + def packages_all_unlocked?(names, versions) + names.all? { |n| !locked_packages.include? n } + end + + def locked_packages + @locked_packages ||= + begin + locked = shell_out_compact_timeout!("apt-mark", "showhold") + locked.stdout.each_line.map do |line| + line.strip + end + end end def install_package(name, version) diff --git a/lib/chef/provider/package/zypper.rb b/lib/chef/provider/package/zypper.rb index 7d97bf310d..c2638fbfc1 100644 --- a/lib/chef/provider/package/zypper.rb +++ b/lib/chef/provider/package/zypper.rb @@ -75,12 +75,22 @@ class Chef end end - def package_locked(name, version) - locked = shell_out_compact_timeout!("zypper", "locks") - locked_packages = locked.stdout.each_line.map do |line| - line.split("|").shift(2).last.strip - end - name.all? { |n| locked_packages.include? n } + def packages_all_locked?(names, versions) + names.all? { |n| locked_packages.include? n } + end + + def packages_all_unlocked?(names, versions) + names.all? { |n| !locked_packages.include? n } + end + + def locked_packages + @locked_packages ||= + begin + locked = shell_out_compact_timeout!("zypper", "locks") + locked.stdout.each_line.map do |line| + line.split("|").shift(2).last.strip + end + end end def load_current_resource |