|
| 1 | +# |
| 2 | +# Author:: Seth Chisamore <[email protected]> |
| 3 | +# Cookbook Name:: python |
| 4 | +# Recipe:: source |
| 5 | +# |
| 6 | +# Copyright 2011, Opscode, Inc. |
| 7 | +# |
| 8 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 9 | +# you may not use this file except in compliance with the License. |
| 10 | +# You may obtain a copy of the License at |
| 11 | +# |
| 12 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | +# |
| 14 | +# Unless required by applicable law or agreed to in writing, software |
| 15 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 16 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 17 | +# See the License for the specific language governing permissions and |
| 18 | +# limitations under the License. |
| 19 | +# |
| 20 | + |
| 21 | +configure_options = node['python']['configure_options'].join(" ") |
| 22 | + |
| 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 | + ) |
| 29 | + |
| 30 | +packages.each do |dev_pkg| |
| 31 | + package dev_pkg |
| 32 | +end |
| 33 | + |
| 34 | +version = node['python']['version'] |
| 35 | +install_path = "#{node['python']['prefix_dir']}/lib/python#{version.split(/(^\d+\.\d+)/)}" |
| 36 | + |
| 37 | +remote_file "#{Chef::Config[:file_cache_path]}/Python-#{version}.tar.bz2" do |
| 38 | + source "#{node['python']['url']}/#{version}/Python-#{version}.tar.bz2" |
| 39 | + checksum node['python']['checksum'] |
| 40 | + mode "0644" |
| 41 | + not_if { ::File.exists?(install_path) } |
| 42 | +end |
| 43 | + |
| 44 | +bash "build-and-install-python" do |
| 45 | + cwd Chef::Config[:file_cache_path] |
| 46 | + code <<-EOF |
| 47 | + tar -jxvf Python-#{version}.tar.bz2 |
| 48 | + (cd Python-#{version} && ./configure #{configure_options}) |
| 49 | + (cd Python-#{version} && make && make install) |
| 50 | + EOF |
| 51 | + not_if { ::File.exists?(install_path) } |
| 52 | +end |
0 commit comments