From d0539bba285fded066511a3040ad17988300188b Mon Sep 17 00:00:00 2001 From: Maxim Kremenev Date: Tue, 7 Jan 2014 14:27:21 +0700 Subject: [PATCH 1/3] feat(source): check install_path and full version --- recipes/source.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/source.rb b/recipes/source.rb index ac8ed86..7f52aeb 100644 --- a/recipes/source.rb +++ b/recipes/source.rb @@ -39,7 +39,7 @@ source "#{node['python']['url']}/#{version}/Python-#{version}.tgz" checksum node['python']['checksum'] mode "0644" - not_if { ::File.exists?(install_path) } + not_if { ::File.exists?(install_path) && `#{install_path} --version 2>&1`.strip =~ /#{version}/ } end bash "build-and-install-python" do @@ -55,7 +55,7 @@ "CXXFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/lib", "CFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/lib" }) if platform?("ubuntu") && node['platform_version'].to_f >= 12.04 - not_if { ::File.exists?(install_path) } + not_if { ::File.exists?(install_path) && `#{install_path} --version 2>&1`.strip =~ /#{version}/ } end # Link install as the default python, to support Python 3.x From 96bbec3269216912bec1836d123cedc2e7bc6ace Mon Sep 17 00:00:00 2001 From: Maxim Kremenev Date: Fri, 10 Jan 2014 14:22:22 +0700 Subject: [PATCH 2/3] add recompile option --- attributes/default.rb | 1 + recipes/source.rb | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/attributes/default.rb b/attributes/default.rb index 85c96eb..6a457de 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -38,6 +38,7 @@ default['python']['checksum'] = '3b477554864e616a041ee4d7cef9849751770bc7c39adaf78a94ea145c488059' default['python']['configure_options'] = %W{--prefix=#{python['prefix_dir']}} default['python']['make_options'] = %W{install} +default['python']['recompile'] = false default['python']['pip_location'] = "#{node['python']['prefix_dir']}/bin/pip" default['python']['virtualenv_location'] = "#{node['python']['prefix_dir']}/bin/virtualenv" diff --git a/recipes/source.rb b/recipes/source.rb index 7f52aeb..bb59010 100644 --- a/recipes/source.rb +++ b/recipes/source.rb @@ -34,17 +34,19 @@ version = node['python']['version'] install_path = "#{node['python']['prefix_dir']}/bin/python#{version.split(/(^\d+\.\d+)/)[1]}" +recompile = node['python']['recompile'] remote_file "#{Chef::Config[:file_cache_path]}/Python-#{version}.tgz" do source "#{node['python']['url']}/#{version}/Python-#{version}.tgz" checksum node['python']['checksum'] mode "0644" - not_if { ::File.exists?(install_path) && `#{install_path} --version 2>&1`.strip =~ /#{version}/ } + not_if { !recompile && ::File.exists?(install_path) && `#{install_path} --version 2>&1`.strip =~ /#{version}/ } end bash "build-and-install-python" do cwd Chef::Config[:file_cache_path] code <<-EOF + rm -rf Python-#{version} tar -zxvf Python-#{version}.tgz (cd Python-#{version} && ./configure #{configure_options}) (cd Python-#{version} && make && make #{make_options}) @@ -55,7 +57,7 @@ "CXXFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/lib", "CFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/lib" }) if platform?("ubuntu") && node['platform_version'].to_f >= 12.04 - not_if { ::File.exists?(install_path) && `#{install_path} --version 2>&1`.strip =~ /#{version}/ } + not_if { !recompile && ::File.exists?(install_path) && `#{install_path} --version 2>&1`.strip =~ /#{version}/ } end # Link install as the default python, to support Python 3.x From 42bfaa5efdd9784e4f12eab3bc7e9d39c3ec1c13 Mon Sep 17 00:00:00 2001 From: Maxim Kremenev Date: Mon, 17 Nov 2014 17:10:13 +0700 Subject: [PATCH 3/3] try fix --- recipes/source.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/recipes/source.rb b/recipes/source.rb index bb59010..fbcaac2 100644 --- a/recipes/source.rb +++ b/recipes/source.rb @@ -52,10 +52,10 @@ (cd Python-#{version} && make && make #{make_options}) EOF environment({ - "LDFLAGS" => "-L#{node['python']['prefix_dir']} -L/usr/lib", - "CPPFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/lib", - "CXXFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/lib", - "CFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/lib" + "LDFLAGS" => "-L#{node['python']['prefix_dir']} -L/usr/local/ssl/lib -L/usr/lib", + "CPPFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/local/ssl/lib -I/usr/lib", + "CXXFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/local/ssl/lib -I/usr/lib", + "CFLAGS" => "-I#{node['python']['prefix_dir']} -I/usr/local/ssl/lib -I/usr/lib" }) if platform?("ubuntu") && node['platform_version'].to_f >= 12.04 not_if { !recompile && ::File.exists?(install_path) && `#{install_path} --version 2>&1`.strip =~ /#{version}/ } end