-
Notifications
You must be signed in to change notification settings - Fork 28
/
rbenv.rb
125 lines (106 loc) · 3.06 KB
/
rbenv.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
# Usage:
# [install rbenv like normal] https://github.com/sstephenson/rbenv
# babushka 1.9.3.rbenv
# rbenv global 1.9.3-rc1
# rbenv rehash
# TODO: delegate all this to ruby-build.
dep 'rbenv' do
met? {
in_path? 'rbenv'
}
meet {
git 'https://github.com/sstephenson/rbenv.git', :to => '~/.rbenv'
}
end
meta :rbenv do
accepts_value_for :version, :basename
accepts_value_for :patchlevel
accepts_block_for :customise
template {
def version_spec
"#{version}-#{patchlevel}"
end
def prefix
"~/.rbenv/versions" / version_spec
end
def version_group
version.scan(/^\d\.\d/).first
end
requires 'rbenv', 'yaml headers.managed', 'openssl.lib'
met? {
(prefix / 'bin/ruby').executable? and
shell(prefix / 'bin/ruby -v')[/^ruby #{version}#{patchlevel}\b/]
}
meet {
Babushka::Resource.extract "http://ftp.ruby-lang.org/pub/ruby/#{version_group}/ruby-#{version_spec}.tar.gz" do |path|
invoke(:customise)
log_shell 'Configure', "./configure --prefix='#{prefix}' --with-openssl-dir=$(brew --prefix openssl)"
log_shell 'Build', "CFLAGS='-march=native -O3 -pipe -fomit-frame-pointer' make -j#{Babushka.host.cpus}"
log_shell 'Install', "make install"
# ruby-1.9.2 doesn't install bin/* when the build path contains a dot-dir.
shell "cp bin/* #{prefix / 'bin'}"
end
}
after {
log_shell 'rbenv rehash', 'rbenv rehash'
}
}
end
dep 'ruby', :version, :patchlevel, :prefix do
def version_spec
"#{version}-#{patchlevel}"
end
def version_group
version.to_s.scan(/^\d\.\d/).first
end
def rbenv_prefix
"~/.rbenv/versions" / version_spec
end
version.default!('1.9.3')
patchlevel.default!('p374')
prefix.default!(rbenv_prefix)
def source_uri
"http://ftp.ruby-lang.org/pub/ruby/#{version_group}/ruby-#{version_spec}.tar.gz"
end
def build_ruby
log_shell 'Configure', "./configure --prefix='#{prefix}' --with-openssl-dir=$(brew --prefix openssl)"
log_shell 'Build', "CFLAGS='-march=native -O3 -pipe -fomit-frame-pointer' make -j#{Babushka.host.cpus}"
log_shell 'Install', "make install"
# ruby-1.9.2 doesn't install bin/* when the build path contains a dot-dir.
shell "cp bin/* #{prefix / 'bin'}"
end
requires 'rbenv', 'yaml headers.managed', 'openssl.lib'
met? {
(prefix / 'bin/ruby').executable? and
shell(prefix / 'bin/ruby -v')[/^ruby #{version}#{patchlevel}\b/]
}
meet {
Babushka::Resource.extract source_uri do |path|
build_ruby
end
log_shell 'rbenv rehash', 'rbenv rehash'
}
end
dep '2.0.0.rbenv' do
patchlevel 'rc2'
end
dep '1.9.3.rbenv' do
patchlevel 'p374'
end
dep '1.9.3-falcon.rbenv' do
version '1.9.3'
patchlevel 'p0'
customise {
falcon_patch = 'https://raw.github.com/gist/1658360/afd06eec533ad0140011bdaf652e6cd82eedf7ec/cumulative_performance.patch'
shell "curl '#{falcon_patch}' | git apply"
}
end
dep '1.9.2.rbenv' do
patchlevel 'p290'
end
dep '1.8.7.rbenv' do
patchlevel 'p352'
end
dep '1.8.6.rbenv' do
patchlevel 'p420'
end