Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ead613f

Browse files
author
Joshua Timberman
committed
Merge pull request poise#22 from opscode-cookbooks/COOK-1727
Cook 1727
2 parents 0e10ccb + b0f7906 commit ead613f

File tree

4 files changed

+31
-54
lines changed

4 files changed

+31
-54
lines changed

attributes/default.rb

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,9 @@
2626
default['python']['prefix_dir'] = '/usr/local'
2727
end
2828

29-
case platform
30-
when "redhat","centos","scientific","fedora","suse","amazon"
31-
set['python']['pip']['prefix_dir'] = '/usr'
32-
when "debian","ubuntu"
33-
set['python']['pip']['prefix_dir'] = '/usr/local'
34-
else
35-
set['python']['pip']['prefix_dir'] = '/usr/local'
36-
end
29+
default['python']['binary'] = "#{python['prefix_dir']}/bin/python"
3730

3831
default['python']['url'] = 'http://www.python.org/ftp/python'
3932
default['python']['version'] = '2.7.1'
4033
default['python']['checksum'] = '80e387bcf57eae8ce26726753584fd63e060ec11682d1145af921e85fd612292'
4134
default['python']['configure_options'] = %W{--prefix=#{python['prefix_dir']}}
42-

recipes/package.rb

Lines changed: 15 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -18,38 +18,22 @@
1818
# limitations under the License.
1919
#
2020

21-
# COOK-1016 Handle RHEL/CentOS namings of python packages, by installing EPEL repo & package
22-
# This implementation was determined a stopgap measure until CHEF-2410 is implemented and widespread.
23-
if node['platform'] == 'centos' || node['platform'] == 'redhat'
24-
major_version = node['platform_version'].split('.').first.to_i
25-
if major_version == 5
26-
include_recipe 'yum::epel'
27-
else
28-
# Do nothing.
29-
end
30-
end
21+
major_version = node['platform_version'].split('.').first.to_i
3122

32-
python_pkgs = if node['platform'] == 'centos' || node['platform'] == 'redhat'
33-
major_version = node['platform_version'].split('.').first.to_i
34-
if major_version == 6
35-
["python", "python-devel"]
36-
else
37-
["python26", "python26-devel"]
38-
end
39-
else
40-
value_for_platform(
41-
["debian","ubuntu"] => {
42-
"default" => ["python","python-dev"]
43-
},
44-
["fedora","amazon"] => {
45-
"default" => ["python","python-devel"]
46-
},
47-
["freebsd"] => {
48-
"default" => ["python"]
49-
},
50-
"default" => ["python","python-dev"]
51-
)
52-
end
23+
# COOK-1016 Handle RHEL/CentOS namings of python packages, by installing EPEL
24+
# repo & package
25+
if platform_family?('rhel') && major_version < 6
26+
include_recipe 'yum::epel'
27+
python_pkgs = ["python26", "python26-devel"]
28+
node['python']['binary'] = "/usr/bin/python26"
29+
else
30+
python_pkgs = value_for_platform_family(
31+
"debian" => ["python","python-dev"],
32+
"rhel" => ["python","python-devel"],
33+
"freebsd" => ["python"],
34+
"default" => ["python","python-dev"]
35+
)
36+
end
5337

5438
python_pkgs.each do |pkg|
5539
package pkg do

recipes/pip.rb

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,11 @@
1818
# limitations under the License.
1919
#
2020

21-
python_bindir = "#{node['python']['prefix_dir']}/bin"
22-
pip_bindir = "#{node['python']['pip']['prefix_dir']}/bin"
21+
if platform_family?("rhel")
22+
pip_binary = "/usr/bin/pip"
23+
else
24+
pip_binary = "/usr/local/bin/pip"
25+
end
2326

2427
# Ubuntu's python-setuptools, python-pip and python-virtualenv packages
2528
# are broken...this feels like Rubygems!
@@ -28,14 +31,14 @@
2831
remote_file "#{Chef::Config[:file_cache_path]}/distribute_setup.py" do
2932
source "http://python-distribute.org/distribute_setup.py"
3033
mode "0644"
31-
not_if { ::File.exists?("#{pip_bindir}/pip") }
34+
not_if { ::File.exists?(pip_binary) }
3235
end
3336

34-
bash "install-pip" do
37+
execute "install-pip" do
3538
cwd Chef::Config[:file_cache_path]
36-
code <<-EOF
37-
#{python_bindir}/python distribute_setup.py
38-
#{pip_bindir}/easy_install pip
39+
command <<-EOF
40+
#{node['python']['binary']} distribute_setup.py
41+
#{::File.dirname(pip_binary)}/easy_install pip
3942
EOF
40-
not_if { ::File.exists?("#{pip_bindir}/pip") }
43+
not_if { ::File.exists?(pip_binary) }
4144
end

recipes/source.rb

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,10 @@
2020

2121
configure_options = node['python']['configure_options'].join(" ")
2222

23-
packages = value_for_platform(
24-
["centos","redhat","fedora"] =>
25-
{"default" => ["openssl-devel","bzip2-devel","zlib-devel","expat-devel","db4-devel","sqlite-devel","ncurses-devel","readline-devel"]},
26-
"default" =>
27-
["libssl-dev","libbz2-dev","zlib1g-dev","libexpat1-dev","libdb4.8-dev","libsqlite3-dev","libncursesw5-dev","libncurses5-dev","libreadline-dev"]
28-
)
23+
packages = value_for_platform_family(
24+
"rhel" => ["openssl-devel","bzip2-devel","zlib-devel","expat-devel","db4-devel","sqlite-devel","ncurses-devel","readline-devel"],
25+
"default" => ["libssl-dev","libbz2-dev","zlib1g-dev","libexpat1-dev","libdb4.8-dev","libsqlite3-dev","libncursesw5-dev","libncurses5-dev","libreadline-dev"]
26+
)
2927

3028
packages.each do |dev_pkg|
3129
package dev_pkg

0 commit comments

Comments
 (0)