diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-08-13 10:35:04 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-08-20 00:18:58 -0700 |
commit | 874870d25c545452a50d2de35ffb9d8657236b44 (patch) | |
tree | 9f9e7a925447588fae1e1ee8df2dab458cf015b3 | |
parent | 739189eb2a62f5d2d027dbf4bd48575fc42351ca (diff) | |
download | chef-874870d25c545452a50d2de35ffb9d8657236b44.tar.gz |
add yum_binary
set this to 'yum-deprecated' if /usr/bin/yum-deprecated exists so
that we pick this up rather than getting /usr/bin/yum on systems that
have DNF installed (assuming yum-deprecated is installed).
-rw-r--r-- | lib/chef/provider/package/yum.rb | 15 | ||||
-rw-r--r-- | lib/chef/resource/yum_package.rb | 11 |
2 files changed, 20 insertions, 6 deletions
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb index e8c0483741..6bd12bc45e 100644 --- a/lib/chef/provider/package/yum.rb +++ b/lib/chef/provider/package/yum.rb @@ -1,6 +1,6 @@ # Author:: Adam Jacob (<adam@opscode.com>) -# Copyright:: Copyright (c) 2008 Opscode, Inc. +# Copyright:: Copyright (c) 2008-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -781,7 +781,7 @@ class Chef end def python_bin - yum_executable = which("yum") + yum_executable = which(yum_binary) if yum_executable && shabang?(yum_executable) extract_interpreter(yum_executable) else @@ -982,6 +982,10 @@ class Chef @yum = YumCache.instance end + def yum_binary + new_resource.yum_binary + end + # Extra attributes # @@ -1026,6 +1030,7 @@ class Chef end def yum_command(command) + command = "#{yum_binary} #{command}" Chef::Log.debug("#{@new_resource}: yum command: \"#{command}\"") status = shell_out_with_timeout(command, {:timeout => Chef::Config[:yum_timeout]}) @@ -1233,7 +1238,7 @@ class Chef end pkg_string = pkg_string_bits.join(' ') Chef::Log.info("#{@new_resource} #{log_method} #{repos.join(' ')}") - yum_command("yum -d0 -e0 -y#{expand_options(@new_resource.options)} #{method} #{pkg_string}") + yum_command("-d0 -e0 -y#{expand_options(@new_resource.options)} #{method} #{pkg_string}") else raise Chef::Exceptions::Package, "Version #{version} of #{name} not found. Did you specify both version " + "and release? (version-release, e.g. 1.84-10.fc6)" @@ -1242,7 +1247,7 @@ class Chef def install_package(name, version) if @new_resource.source - yum_command("yum -d0 -e0 -y#{expand_options(@new_resource.options)} localinstall #{@new_resource.source}") + yum_command("-d0 -e0 -y#{expand_options(@new_resource.options)} localinstall #{@new_resource.source}") else install_remote_package(name, version) end @@ -1290,7 +1295,7 @@ class Chef "#{n}#{yum_arch(a)}" end.join(' ') end - yum_command("yum -d0 -e0 -y#{expand_options(@new_resource.options)} remove #{remove_str}") + yum_command("-d0 -e0 -y#{expand_options(@new_resource.options)} remove #{remove_str}") if flush_cache[:after] @yum.reload diff --git a/lib/chef/resource/yum_package.rb b/lib/chef/resource/yum_package.rb index 4d54f6051f..de1075d1ad 100644 --- a/lib/chef/resource/yum_package.rb +++ b/lib/chef/resource/yum_package.rb @@ -1,6 +1,6 @@ # # Author:: AJ Christensen (<aj@opscode.com>) -# Copyright:: Copyright (c) 2008 Opscode, Inc. +# Copyright:: Copyright (c) 2008-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -28,6 +28,7 @@ class Chef super @flush_cache = { :before => false, :after => false } @allow_downgrade = false + @yum_binary = File.exist?("/usr/bin/yum-deprecated") ? "yum-deprecated" : "yum" end # Install a specific arch @@ -57,6 +58,14 @@ class Chef ) end + def yum_binary(arg=nil) + set_or_return( + :yum_binary, + arg, + :kind_of => [ String ] + ) + end + end end end |