diff --git a/gecode/README.md b/gecode/README.md index 2e9cb3bd2..44887ba30 100644 --- a/gecode/README.md +++ b/gecode/README.md @@ -6,34 +6,45 @@ Installs Gecode 3.5.0+ development package. Requirements ============ -Tested on Ubuntu and Debian with Opscode APT repository and build from source. +Platform +-------- -Tested on CentOS for build from source. See USAGE for information on installing RPMs. +* Debian, Ubuntu +* Red Hat, CentOS, Fedora +* Mac OS X 10.6+ -Requires the following cookbooks: +Cookbooks +--------- * apt - for installing packages from apt.opscode.com * build-essential - for compiling from source +Attributes +========== + +* `node['gecode']['install_method']` - Specifies the recipe to use for installing gecode. +* `node['gecode']['url']` - base url to download from. Default is the Gecode distribution server. +* `node['gecode']['version']` - version of gecode to install. +* `node['gecode']['checksum']` - checksum of the source tarball. +* `node['gecode']['configure_options']` - array of options to pass to ./configure for compiling gecode. + Usage ===== -The recipe is primarily used to install gecode's development package or from source in order to install the `dep_selector` gem, which needs to compile native extensions. +default +------- -Note that compiling gecode takes a long time, up to ~30 minutes on a 4 core Macbook Pro. +Include default recipe in a run list, to get some Gecode installed. Installs Gecode by package or source depending on the platform. The recipe is primarily used to install gecode's development package or from source in order to install the `dep_selector` gem, which needs to compile native extensions. -On Debian and Ubuntu systems, the recipe will attempt to install packages from apt.opscode.com. It uses the apt repository LWRP in Opscode's apt cookbook to enable the repository. For releases after Debian 7.0 (Wheezy) and Ubuntu 11.04 (Natty), Gecode 3.5.0+ exists in the main repositories. +package +------- -On Red Hat family distros, the recipe will attempt to install gecode from source. To install using a package the recipe needs to be updated to account for a package repository. Implementation varies depending on the package repository. For example, to retrieve the /etc/yum.repos.d/somewhere.repo that has the package available, add a condition to the main 'if' block: +Installs Gecode from packages. On Debian and Ubuntu systems, the recipe will attempt to install packages from apt.opscode.com. It uses the apt repository LWRP in Opscode's apt cookbook to enable the repository. For releases after Debian 7.0 (Wheezy) and Ubuntu 11.04 (Natty), Gecode 3.5.0+ exists in the main repositories. - remote_file "/etc/yum.repos.d/somewhere.repo" do - source "http://somewhere.example.com/yum/el5/somewhere.repo" - owner "root" - group "root" - mode 0644 - end +source +------ - package "gecode-devel" +Installs Gecode from source. Note that compiling gecode takes a long time, up to ~30 minutes on a 4 core Macbook Pro. Changes/Roadmap =============== diff --git a/gecode/attributes/default.rb b/gecode/attributes/default.rb new file mode 100644 index 000000000..2237c3f3e --- /dev/null +++ b/gecode/attributes/default.rb @@ -0,0 +1,38 @@ +# +# Author:: Seth Chisamore () +# Cookbook Name:: gecode +# Attribute:: default +# +# Copyright 2011, Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +case node['platform'] +when 'debian', 'ubuntu' + default['gecode']['install_method'] = 'package' +else + default['gecode']['install_method'] = 'source' +end + +default['gecode']['url'] = 'http://www.gecode.org/download' +default['gecode']['version'] = '3.5.0' +default['gecode']['checksum'] = '0b2602ce647dd23814d2a7f5f0e757e09f98581b14b95aafbcd9e4c7e0ab4d2a' + +default['gecode']['configure_options'] = %w{ + --disable-debug + --disable-dependency-tracking + --disable-qt + --prefix=/usr/local + --with-architectures=i386,x86_64 + } diff --git a/gecode/metadata.rb b/gecode/metadata.rb index a2b8667b0..12183165c 100644 --- a/gecode/metadata.rb +++ b/gecode/metadata.rb @@ -4,5 +4,11 @@ description "Installs gecode" long_description IO.read(File.join(File.dirname(__FILE__), 'README.md')) version "1.0.0" -depends "apt" -depends "build-essential" + +%w{ debian ubuntu redhat centos fedora mac_os_x }.each do |os| + supports os +end + +%w{ build-essential apt }.each do |cb| + depends cb +end diff --git a/gecode/recipes/default.rb b/gecode/recipes/default.rb index dbec89850..490ec66bc 100644 --- a/gecode/recipes/default.rb +++ b/gecode/recipes/default.rb @@ -1,7 +1,4 @@ # -# Author:: Christopher Walters () -# Author:: Nuo Yan () -# Author:: Joshua Timberman () # Author:: Seth Chisamore () # Cookbook Name:: gecode # Recipe:: default @@ -20,46 +17,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -case node['platform'] -when 'ubuntu','debian' - - include_recipe 'apt' - - # use opscode apt repo for older releases - if (platform?("debian") && (node.platform_version.to_f < 7.0)) || - (platform?("ubuntu") && (node.platform_version.to_f < 11.0)) - - # add Opscode's apt repo to sources - apt_repository "opscode" do - uri "http://apt.opscode.com" - components ["main"] - distribution node['lsb']['codename'] - key "2940ABA983EF826A" - keyserver "pgpkeys.mit.edu" - action :add - end - - end - - apt_package 'libgecode-dev' do - action :install - end - -when 'redhat','centos' - - include_recipe 'build-essential' - - bash "build gecode from source" do - cwd "/tmp" - code <<-EOH - curl -C - -O http://www.gecode.org/download/gecode-3.5.0.tar.gz - tar zxvf gecode-3.5.0.tar.gz - cd gecode-3.5.0 && ./configure - make && make install - EOH - not_if {::File.exists? "/usr/local/lib/libgecodekernel.so" } - end - -else - raise "This recipe does not yet support installing Gecode 3.5.0+ for your platform" -end +include_recipe "gecode::#{node['gecode']['install_method']}" \ No newline at end of file diff --git a/gecode/recipes/package.rb b/gecode/recipes/package.rb new file mode 100644 index 000000000..29ad7a143 --- /dev/null +++ b/gecode/recipes/package.rb @@ -0,0 +1,50 @@ +# +# Author:: Christopher Walters () +# Author:: Nuo Yan () +# Author:: Joshua Timberman () +# Author:: Seth Chisamore () +# Cookbook Name:: gecode +# Recipe:: package +# +# Copyright:: Copyright (c) 2011 Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +case node['platform'] +when 'ubuntu','debian' + + include_recipe 'apt' + + # use opscode apt repo for older releases + if (platform?("debian") && (node.platform_version.to_f < 7.0)) || + (platform?("ubuntu") && (node.platform_version.to_f < 11.0)) + + # add Opscode's apt repo to sources + apt_repository "opscode" do + uri "http://apt.opscode.com" + components ["main"] + distribution node['lsb']['codename'] + key "2940ABA983EF826A" + keyserver "pgpkeys.mit.edu" + action :add + end + + end + + apt_package 'libgecode-dev' do + action :install + end + +else + raise "This recipe does not yet support installing Gecode 3.5.0+ from packages on your platform" +end diff --git a/gecode/recipes/source.rb b/gecode/recipes/source.rb new file mode 100644 index 000000000..3ad8f3256 --- /dev/null +++ b/gecode/recipes/source.rb @@ -0,0 +1,40 @@ +# +# Author:: Seth Chisamore () +# Cookbook Name:: gecode +# Recipe:: source +# +# Copyright:: Copyright (c) 2011 Opscode, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +include_recipe 'build-essential' + +version = node['gecode']['version'] + +remote_file "#{Chef::Config[:file_cache_path]}/gecode-#{version}.tar.gz" do + source "#{node['gecode']['url']}/gecode-#{version}.tar.gz" + checksum node['gecode']['checksum'] + mode 0644 +end + +lib_name = value_for_platform("mac_os_x" => { "default" => "libgecodekernel.dylib" }, "default" => "libgecodekernel.so") + +bash "build gecode from source" do + cwd Chef::Config[:file_cache_path] + code <<-EOH + tar zxvf gecode-#{version}.tar.gz + (cd gecode-#{version} && ./configure #{node['gecode']['configure_options'].join(" ")}) + (cd gecode-#{version} && make && make install) + EOH + not_if { ::File.exists?("/usr/local/lib/#{lib_name}") } +end