-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcabal-source.rb
69 lines (62 loc) · 2.11 KB
/
cabal-source.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#
# Author:: Masahiro Yamauchi (<[email protected]>)
# Cookbook Name:: haskell
# Recipe:: cabal-source
#
# Copyright 2013, Masahiro Yamauchi
#
# 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.
#
if node['haskell']['cabal']['packages'].length == 0
packages = value_for_platform(
"ubuntu" => {
"default" => ['zlib1g-dev'],
}
)
else
packages = node['haskell']['cabal']['packages']
end
packages.each do |pkg|
package pkg do
action :install
end
end
extract_command = node['haskell']['cabal']['extract_command']
extract_options = node['haskell']['cabal']['extract_options']
configure_options = node['haskell']['cabal']['configure_options']
archive_file = node['haskell']['cabal']['archive_file']
cabal_dir = node['haskell']['cabal']['cabal_dir']
cache_dir = node['haskell']['cabal']['cache_dir']
scope = node['haskell']['cabal']['scope']
directory cache_dir do
owner node['haskell']['cabal']['owner']
group node['haskell']['cabal']['group']
action :create
not_if { ::File.exists?(cache_dir) }
end
remote_file "#{File.join(cache_dir, archive_file)}" do
source node['haskell']['cabal']['download']
owner node['haskell']['cabal']['owner']
group node['haskell']['cabal']['group']
mode "0644"
not_if { ::File.exists?("#{File.join(cache_dir, archive_file)}") }
end
bash "build-and-install-cabal-install" do
cwd cache_dir
user node['haskell']['cabal']['owner']
group node['haskell']['cabal']['group']
code <<-EOF
(#{extract_command} #{extract_options} #{archive_file} && cd #{cabal_dir} && #{configure_options} bash bootstrap.sh #{scope})
EOF
not_if { ::File.exists?(node['haskell']['cabal']['binary']) }
end