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

Skip to content

Commit 29e883d

Browse files
committed
[COOK-1016] Adds better package name handling for python2.6 between distros and versions
1 parent bb17707 commit 29e883d

File tree

4 files changed

+47
-16
lines changed

4 files changed

+47
-16
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ Cookbooks
1616
---------
1717

1818
* build-essential
19+
* yum
20+
21+
NOTE: The `yum` cookbook is a dependency of the cookbook, and will be used to install [EPEL](http://fedoraproject.org/wiki/EPEL) on RedHet/CentOS 5.x systems to provide the Python 2.6 packages.
1922

2023
Attributes
2124
==========

attributes/default.rb

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,22 @@
2121
default['python']['install_method'] = 'package'
2222

2323
if python['install_method'] == 'package'
24-
default['python']['prefix_dir'] = '/usr'
24+
default['python']['prefix_dir'] = '/usr'
2525
else
26-
default['python']['prefix_dir'] = '/usr/local'
26+
default['python']['prefix_dir'] = '/usr/local'
27+
end
28+
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'
2736
end
2837

2938
default['python']['url'] = 'http://www.python.org/ftp/python'
3039
default['python']['version'] = '2.7.1'
3140
default['python']['checksum'] = '80e387bcf57eae8ce26726753584fd63e060ec11682d1145af921e85fd612292'
3241
default['python']['configure_options'] = %W{--prefix=#{python['prefix_dir']}}
3342

34-
default['python']['pip']['prefix_dir'] = '/usr/local'

metadata.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
version "1.0.6"
66

77
depends "build-essential"
8+
depends "yum"
89

910
recipe "python", "Installs python, pip, and virtualenv"
1011
recipe "python::package", "Installs python using packages."

recipes/package.rb

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

21-
python_pkgs = value_for_platform(
22-
["debian","ubuntu"] => {
23-
"default" => ["python","python-dev"]
24-
},
25-
["centos","redhat","fedora"] => {
26-
"default" => ["python26","python26-devel"]
27-
},
28-
["freebsd"] => {
29-
"default" => ["python"]
30-
},
31-
"default" => ["python","python-dev"]
32-
)
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
31+
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
3353

3454
python_pkgs.each do |pkg|
3555
package pkg do
3656
action :install
3757
end
3858
end
39-

0 commit comments

Comments
 (0)