summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Dibowitz <phil@ipom.com>2015-01-30 15:18:32 -0800
committerPhil Dibowitz <phil@ipom.com>2015-02-03 19:32:36 -0800
commitc4c05b868a0d8face976d8d5c89324c173dbeaa8 (patch)
tree0626fd06e5f597fcc6cf350983831664ca4c73db
parenta50c72f4ffbeb9118f8916de5a3b93a1a40f17bb (diff)
downloadchef-c4c05b868a0d8face976d8d5c89324c173dbeaa8.tar.gz
Mior output cleanups
-rw-r--r--lib/chef/provider/package.rb30
-rw-r--r--lib/chef/provider/package/yum.rb4
2 files changed, 27 insertions, 7 deletions
diff --git a/lib/chef/provider/package.rb b/lib/chef/provider/package.rb
index 58de80c868..454936f1e8 100644
--- a/lib/chef/provider/package.rb
+++ b/lib/chef/provider/package.rb
@@ -40,6 +40,10 @@ class Chef
def load_current_resource
end
+ def as_array(thing)
+ [ thing ].flatten
+ end
+
def package_name_array
[ new_resource.package_name ].flatten
end
@@ -77,7 +81,7 @@ class Chef
if new_version_array.any? && !(target_version_already_installed?)
install_version = @new_resource.version
# If it's not installed at all, install it
- elsif current_version_array.any? { |x| x.nil? }
+ elsif current_version_array.include?(nil)
install_version = candidate_version
else
Chef::Log.debug("#{@new_resource} is already installed - nothing to do")
@@ -99,6 +103,20 @@ class Chef
end
end
+ def upgrade_text(name, oldversion, newversion)
+ if as_array(name).size == 1
+ return "upgraded #{name} from #{oldversion} to #{newversion}"
+ end
+
+ outs = []
+ name.zip(oldversion, newversion).each do |pkg, old, new|
+ next if old == new
+ outs << "#{pkg} from #{old} to #{new}"
+ end
+
+ "upgraded #{outs.join(', ')}"
+ end
+
def action_upgrade
if !candidate_version_array.any?
Chef::Log.debug("#{@new_resource} no candidate version - nothing to do")
@@ -108,8 +126,14 @@ class Chef
return
end
@new_resource.version(candidate_version)
- orig_version = @current_resource.version || "uninstalled"
- converge_by("upgrade package #{@new_resource.package_name} from #{orig_version} to #{candidate_version}") do
+
+ orig_version = []
+ current_version_array.each do |v|
+ orig_version << (v || "uninstalled")
+ end
+ orig_version = orig_version.size == 1 ? orig_version[0] : orig_version
+
+ converge_by(upgrade_text(@new_resource.package_name, orig_version, candidate_version)) do
upgrade_package(@new_resource.package_name, candidate_version)
Chef::Log.info("#{@new_resource} upgraded from #{orig_version} to #{candidate_version}")
end
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb
index 0debba8267..415f204581 100644
--- a/lib/chef/provider/package/yum.rb
+++ b/lib/chef/provider/package/yum.rb
@@ -987,10 +987,6 @@ class Chef
# Helpers
#
- def as_array(thing)
- [ thing ].flatten
- end
-
def yum_arch
arch ? ".#{arch}" : nil
end