diff options
author | Tim Smith <tsmith84@gmail.com> | 2015-11-05 10:00:05 -0800 |
---|---|---|
committer | Tim Smith <tsmith84@gmail.com> | 2015-11-05 10:00:05 -0800 |
commit | a65408a6d005ec5ca9270b0efd42fec74c7b7087 (patch) | |
tree | 1a869612a94fff06c897ec60955f7527fd6165bc /lib/chef/provider/package | |
parent | 5020cc6df7cffe45eddddbedcc2a1e18c55cf1e5 (diff) | |
download | chef-a65408a6d005ec5ca9270b0efd42fec74c7b7087.tar.gz |
Use the proper python interpretor for yum-dump.py on Fedora 21+
Fedora 21+ use dnf as the primary package manager. Lamont added code in
12.5 to allow for a yum compat mode. This doesn't entirely work though
as we need yum-dump.py to correctly run. We were parsing the shabang in
the yum binary to find the path to python. On a dnf system the yum
binary is a bash script though so we were trying to run yum-dump.py
using bash which obviously fails. I added a fallback method to use
python if the shebang parsing returns bash. With this in place AND the
yum package installed you can use the package resource on Fedora.
Diffstat (limited to 'lib/chef/provider/package')
-rw-r--r-- | lib/chef/provider/package/yum.rb | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/lib/chef/provider/package/yum.rb b/lib/chef/provider/package/yum.rb index aff8dc9326..6258472a65 100644 --- a/lib/chef/provider/package/yum.rb +++ b/lib/chef/provider/package/yum.rb @@ -785,7 +785,7 @@ class Chef def python_bin yum_executable = which(yum_binary) if yum_executable && shabang?(yum_executable) - extract_interpreter(yum_executable) + shabang_or_fallback(extract_interpreter(yum_executable)) else Chef::Log.warn("Yum executable not found or doesn't start with #!. Using default python.") "/usr/bin/python" @@ -797,7 +797,17 @@ class Chef end def extract_interpreter(file) - ::File.open(file, 'r', &:readline)[2..-1].chomp + ::File.open(file, 'r', &:readline)[2..-1].strip + end + + # dnf based systems have a yum shim that has /bin/bash as the interpreter. Don't use this. + def shabang_or_fallback(interpreter) + if interpreter == '/bin/bash' + Chef::Log.warn("Yum executable interpreter is /bin/bash. Falling back to default python.") + "/usr/bin/python" + else + interpreter + end end def shabang?(file) |