source.rb 2.05 KB
Newer Older
Tim Smith's avatar
Tim Smith committed
1
# Cookbook:: erlang
Tim Smith's avatar
Tim Smith committed
2
# Recipe:: source
3
# Author:: Joe Williams <joe@joetify.com>
Sean OMeara's avatar
Sean OMeara committed
4
# Author:: Matt Ray <matt@chef.io>
5
6
# Author:: Hector Castro <hector@basho.com>
#
Tim Smith's avatar
Tim Smith committed
7
8
# Copyright:: 2008-2016, Joe Williams
# Copyright:: 2011-2016, Chef Software Inc.
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#
# 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.
#

23
include_recipe 'build-essential'
24

25
26
case node['platform_family']
when 'debian'
27
  package %w(tar libncurses5-dev openssl libssl-dev)
28
when 'rhel', 'fedora'
29
  package %w(tar ncurses-devel openssl-devel)
30
31
end

Lamont Granquist's avatar
Lamont Granquist committed
32
erlang_version     = node['erlang']['source']['version']
33
erlang_url         = node['erlang']['source']['url'] || "http://erlang.org/download/otp_src_#{erlang_version}.tar.gz"
Lamont Granquist's avatar
Lamont Granquist committed
34
35
36
37
erlang_checksum    = node['erlang']['source']['checksum']
erlang_build_flags = node['erlang']['source']['build_flags']
erlang_cflags      = node['erlang']['source']['cflags']

38
bash 'install-erlang' do
39
40
  cwd Chef::Config[:file_cache_path]
  code <<-EOH
Lamont Granquist's avatar
Lamont Granquist committed
41
42
    tar -xzf otp_src_#{erlang_version}.tar.gz
    (cd otp_src_#{erlang_version} && ./configure #{erlang_build_flags} && make && make install)
43
  EOH
Lamont Granquist's avatar
Lamont Granquist committed
44
  environment('CFLAGS' => erlang_cflags)
45
  action :nothing
46
  not_if "erl -eval '{ok, Version} = file:read_file(filename:join([code:root_dir(), \"releases\", erlang:system_info(otp_release), \"OTP_VERSION\"])), erlang:display(erlang:binary_to_list(Version)), halt().' -noshell | grep #{erlang_version}"
47
48
end

Lamont Granquist's avatar
Lamont Granquist committed
49
50
remote_file File.join(Chef::Config[:file_cache_path], "otp_src_#{erlang_version}.tar.gz") do
  source erlang_url
51
  owner 'root'
52
  mode '0644'
Lamont Granquist's avatar
Lamont Granquist committed
53
  checksum erlang_checksum
54
  notifies :run, 'bash[install-erlang]', :immediately
55
end