Skip to content
Newer
Older
100644 323 lines (270 sloc) 9.72 KB
29971b5 @ddollar add rake task to update plugins
ddollar authored May 24, 2011
1 require "fileutils"
42f3325 @hone vendor plugins onto s3
hone authored Sep 23, 2011
2 require "tmpdir"
29971b5 @ddollar add rake task to update plugins
ddollar authored May 24, 2011
3
43ee356 @hone update to new s3 bucket name
hone authored Oct 21, 2011
4 S3_BUCKET_NAME = "heroku-buildpack-ruby"
c9e6434 @hone rake task for build ruby
hone authored Nov 4, 2011
5 VENDOR_URL = "https://s3.amazonaws.com/#{S3_BUCKET_NAME}"
9abebb1 @hone vendor libyaml onto s3
hone authored Sep 24, 2011
6
42f3325 @hone vendor plugins onto s3
hone authored Sep 24, 2011
7 def s3_tools_dir
8 File.expand_path("../support/s3", __FILE__)
29971b5 @ddollar add rake task to update plugins
ddollar authored May 24, 2011
9 end
10
1d7bfe8 @hone refactor out s3_upload logic
hone authored Sep 24, 2011
11 def s3_upload(tmpdir, name)
12 sh("#{s3_tools_dir}/s3 put #{S3_BUCKET_NAME} #{name}.tgz #{tmpdir}/#{name}.tgz")
13 end
14
29971b5 @ddollar add rake task to update plugins
ddollar authored May 24, 2011
15 def vendor_plugin(git_url)
16 name = File.basename(git_url, File.extname(git_url))
42f3325 @hone vendor plugins onto s3
hone authored Sep 24, 2011
17 Dir.mktmpdir("#{name}-") do |tmpdir|
18 FileUtils.rm_rf("#{tmpdir}/*")
19
20 Dir.chdir(tmpdir) do
21 sh "git clone #{git_url} ."
22 FileUtils.rm_rf("#{name}/.git")
23 sh("tar czvf #{tmpdir}/#{name}.tgz *")
1d7bfe8 @hone refactor out s3_upload logic
hone authored Sep 24, 2011
24 s3_upload(tmpdir, name)
42f3325 @hone vendor plugins onto s3
hone authored Sep 24, 2011
25 end
29971b5 @ddollar add rake task to update plugins
ddollar authored May 24, 2011
26 end
27 end
28
728c896 @hone vendor gems onto s3
hone authored Sep 26, 2011
29 def in_gem_env(gem_home, &block)
a16dfa4 @hone rake task to install gems to be vendored
hone authored Jun 15, 2011
30 old_gem_home = ENV['GEM_HOME']
31 old_gem_path = ENV['GEM_PATH']
728c896 @hone vendor gems onto s3
hone authored Sep 26, 2011
32 ENV['GEM_HOME'] = ENV['GEM_PATH'] = gem_home.to_s
a16dfa4 @hone rake task to install gems to be vendored
hone authored Jun 15, 2011
33
34 yield
35
36 ENV['GEM_HOME'] = old_gem_home
37 ENV['GEM_PATH'] = old_gem_path
38 end
39
40 def install_gem(gem, version)
728c896 @hone vendor gems onto s3
hone authored Sep 26, 2011
41 name = "#{gem}-#{version}"
42 Dir.mktmpdir("#{gem}-#{version}") do |tmpdir|
43 Dir.chdir(tmpdir) do |dir|
44 FileUtils.rm_rf("#{tmpdir}/*")
a16dfa4 @hone rake task to install gems to be vendored
hone authored Jun 15, 2011
45
728c896 @hone vendor gems onto s3
hone authored Sep 26, 2011
46 in_gem_env(tmpdir) do
434e8c9 @hone always write gem wrappers with #!/usr/bin/env ruby
hone authored Sep 27, 2011
47 sh("gem install #{gem} --version #{version} --no-ri --no-rdoc --env-shebang")
728c896 @hone vendor gems onto s3
hone authored Sep 26, 2011
48 sh("tar czvf #{tmpdir}/#{name}.tgz *")
49 s3_upload(tmpdir, name)
50 end
51 end
a16dfa4 @hone rake task to install gems to be vendored
hone authored Jun 15, 2011
52 end
53 end
54
35d4533 @hone refactor building ruby code
hone authored Nov 5, 2011
55 def build_ruby_command(name, output, prefix, usr_dir, tmpdir)
56 build_command = [
57 # need to move libyaml/libffi to dirs we can see
58 "mv usr /tmp",
59 "./configure --disable-install-doc --prefix #{prefix}",
60 "env CPATH=/tmp/#{usr_dir}/include:\\$CPATH CPPATH=/tmp/#{usr_dir}/include:\\$CPPATH LIBRARY_PATH=/tmp/#{usr_dir}/lib:\\$LIBRARY_PATH make",
61 "make install"
62 ]
63 build_command << "mv #{prefix} /app/vendor/#{name}" if name != output
64 build_command = build_command.join(" && ")
65
66 sh "vulcan build -v -o #{output}.tgz --source #{name} --command=\"#{build_command}\""
67 s3_upload(tmpdir, output)
68 end
69
44f552c @hone build the build rbx for rbx2.0.0dev
hone authored Jan 24, 2012
70 def build_rbx_command(name, output, prefix, usr_dir, tmpdir, ruby_version)
71 build_command = [
72 # need to move libyaml/libffi to dirs we can see
73 "mv usr /tmp",
74 "ls /tmp/#{usr_dir}",
75 "./configure --prefix #{prefix} --enable-version=#{ruby_version} --default-version=#{ruby_version} --with-include-dir=/tmp/#{usr_dir}/include --with-lib-dir=/tmp/#{usr_dir}/lib",
76 "rake install"
77 ]
78 # build_command << "mv #{prefix} /app/vendor/#{name}" if name != output
79 build_command = build_command.join(" && ")
80
81 sh "vulcan build -v -o #{output}.tgz --source #{name} --prefix #{prefix} --command=\"#{build_command}\""
82 s3_upload(tmpdir, output)
83 end
84
29971b5 @ddollar add rake task to update plugins
ddollar authored May 24, 2011
85 desc "update plugins"
86 task "plugins:update" do
87 vendor_plugin "http://github.com/ddollar/rails_log_stdout.git"
88 vendor_plugin "http://github.com/pedro/rails3_serve_static_assets.git"
a8c78ea @hone add rails31_enable_runtime_asset_compilation to Rakefile
hone authored Sep 4, 2011
89 vendor_plugin "http://github.com/hone/rails31_enable_runtime_asset_compilation.git"
29971b5 @ddollar add rake task to update plugins
ddollar authored May 24, 2011
90 end
a16dfa4 @hone rake task to install gems to be vendored
hone authored Jun 15, 2011
91
92 desc "install vendored gem"
93 task "gem:install", :gem, :version do |t, args|
94 gem = args[:gem]
95 version = args[:version]
96
97 install_gem(gem, version)
98 end
da21ad1 @hone rake task for vendoring new libyaml
hone authored Aug 23, 2011
99
f8745d3 @hone don't hardcode the libyaml version in the Rakefile
hone authored Sep 26, 2011
100 desc "install libyaml"
101 task "libyaml:install", :version do |t, args|
102 version = args[:version]
103 name = "libyaml-#{version}"
9abebb1 @hone vendor libyaml onto s3
hone authored Sep 24, 2011
104 Dir.mktmpdir("libyaml-") do |tmpdir|
105 Dir.chdir(tmpdir) do |dir|
106 FileUtils.rm_rf("#{tmpdir}/*")
107
f8745d3 @hone don't hardcode the libyaml version in the Rakefile
hone authored Sep 26, 2011
108 sh "curl http://pyyaml.org/download/libyaml/yaml-#{version}.tar.gz -s -o - | tar vzxf -"
2f310ae @hone make build command easier to read for libyaml
hone authored Nov 5, 2011
109
110 build_command = [
111 "env CFLAGS=-fPIC ./configure --enable-static --disable-shared --prefix=/app/vendor/yaml-#{version}",
112 "make",
113 "make install"
114 ].join(" && ")
115
116 sh "vulcan build -v -o #{name}.tgz --source yaml-#{version} --command=\"#{build_command}\""
1d7bfe8 @hone refactor out s3_upload logic
hone authored Sep 24, 2011
117 s3_upload(tmpdir, name)
9abebb1 @hone vendor libyaml onto s3
hone authored Sep 24, 2011
118 end
119 end
da21ad1 @hone rake task for vendoring new libyaml
hone authored Aug 24, 2011
120 end
0d3400c @hone vendor node in s3
hone authored Sep 24, 2011
121
643da19 @hone remove hard coding node version in Rakefile
hone authored Sep 26, 2011
122 desc "install node"
123 task "node:install", :version do |t, args|
124 version = args[:version]
125 name = "node-#{version}"
126 prefix = "/app/vendor/node-v#{version}"
0d3400c @hone vendor node in s3
hone authored Sep 24, 2011
127 Dir.mktmpdir("node-") do |tmpdir|
128 Dir.chdir(tmpdir) do |dir|
129 FileUtils.rm_rf("#{tmpdir}/*")
130
643da19 @hone remove hard coding node version in Rakefile
hone authored Sep 26, 2011
131 sh "curl http://nodejs.org/dist/node-v#{version}.tar.gz -s -o - | tar vzxf -"
00a2544 @hone make build command easier to read for node
hone authored Nov 5, 2011
132
133 build_command = [
134 "./configure --prefix #{prefix}",
135 "make install",
136 "mv #{prefix}/bin/node #{prefix}/.",
25cb790 @hone Revert "rm -rf all the nodedirs at once"
hone authored Jan 10, 2012
137 "rm -rf #{prefix}/include",
138 "rm -rf #{prefix}/lib",
139 "rm -rf #{prefix}/share",
140 "rm -rf #{prefix}/bin"
00a2544 @hone make build command easier to read for node
hone authored Nov 5, 2011
141 ].join(" && ")
142
143 sh "vulcan build -v -o #{name}.tgz --source node-v#{version} --command=\"#{build_command}\""
0d3400c @hone vendor node in s3
hone authored Sep 24, 2011
144 s3_upload(tmpdir, name)
145 end
146 end
147 end
28a874c @hone rake task to build ruby 1.9.3
hone authored Nov 2, 2011
148
149 desc "install ruby"
150 task "ruby:install", :version do |t, args|
151 version = args[:version]
152 name = "ruby-#{version}"
7939f2b @hone update ruby install task to use libyaml + libffi
hone authored Nov 4, 2011
153 usr_dir = "usr"
28a874c @hone rake task to build ruby 1.9.3
hone authored Nov 2, 2011
154 Dir.mktmpdir("ruby-") do |tmpdir|
155 Dir.chdir(tmpdir) do |dir|
156 FileUtils.rm_rf("#{tmpdir}/*")
157
158 sh "curl http://ftp.ruby-lang.org/pub/ruby/1.9/#{name}.tar.gz -s -o - | tar vzxf -"
7939f2b @hone update ruby install task to use libyaml + libffi
hone authored Nov 4, 2011
159 FileUtils.mkdir_p("#{name}/#{usr_dir}")
160 Dir.chdir("#{name}/#{usr_dir}") do
161 sh "curl #{VENDOR_URL}/libyaml-0.1.4.tgz -s -o - | tar vzxf -"
162 sh "curl #{VENDOR_URL}/libffi-3.0.10.tgz -s -o - | tar vzxf -"
163 end
d1d840f @hone make ruby build task more readable
hone authored Nov 4, 2011
164
3782f19 @hone combine build/runtime ruby rake tasks
hone authored Nov 7, 2011
165 # runtime ruby
166 prefix = "/app/vendor/#{name}"
35d4533 @hone refactor building ruby code
hone authored Nov 5, 2011
167 build_ruby_command(name, name, prefix, usr_dir, tmpdir)
168
3782f19 @hone combine build/runtime ruby rake tasks
hone authored Nov 7, 2011
169 # build ruby
170 output = "ruby-build-#{version}"
171 prefix = "/tmp/#{name}"
35d4533 @hone refactor building ruby code
hone authored Nov 5, 2011
172 build_ruby_command(name, output, prefix, usr_dir, tmpdir)
c9e6434 @hone rake task for build ruby
hone authored Nov 4, 2011
173 end
174 end
175 end
176
b4a16bc @hone rake task to build rbx
hone authored Nov 9, 2011
177 desc "install rbx"
178 task "rbx:install", :version do |t, args|
179 version = args[:version]
180 name = "rubinius-#{version}"
181 output = "rbx-#{version}"
182 prefix = "/app/vendor/#{output}"
183
184 Dir.mktmpdir("rbx-") do |tmpdir|
185 Dir.chdir(tmpdir) do |dir|
186 FileUtils.rm_rf("#{tmpdir}/*")
187
188 sh "curl http://asset.rubini.us/#{name}.tar.gz -s -o - | tar vzxf -"
189 build_command = [
190 "./configure --prefix #{prefix}",
191 "rake install"
192 ].join(" && ")
193
194 sh "vulcan build -v -o #{output}.tgz --source #{name} --prefix #{prefix} --command=\"#{build_command}\""
195 s3_upload(tmpdir, output)
196 end
197 end
198 end
199
d41a3f3 @hone rake task to install rbx-2.0.0dev
hone authored Jan 15, 2012
200 desc "install rbx 2.0.0dev"
201 task "rbx2dev:install", :version, :ruby_version do |t, args|
202 version = args[:version]
203 ruby_version = args[:ruby_version]
204 source = "rubinius-#{version}"
205 name = "rubinius-2.0.0dev"
206 output = "rbx-#{version}-#{ruby_version}"
207 usr_dir = "usr"
208
209 Dir.mktmpdir("rbx-") do |tmpdir|
210 Dir.chdir(tmpdir) do |dir|
211 FileUtils.rm_rf("#{tmpdir}/*")
212
213 sh "curl http://asset.rubini.us/#{source}.tar.gz -s -o - | tar vzxf -"
214 FileUtils.mkdir_p("#{name}/#{usr_dir}")
215 Dir.chdir("#{name}/#{usr_dir}") do
216 sh "curl #{VENDOR_URL}/libyaml-0.1.4.tgz -s -o - | tar vzxf -"
217 sh "curl #{VENDOR_URL}/libffi-3.0.10.tgz -s -o - | tar vzxf -"
218 end
219
44f552c @hone build the build rbx for rbx2.0.0dev
hone authored Jan 24, 2012
220 prefix = "/app/vendor/#{output}"
221 build_rbx_command(name, output, prefix, usr_dir, tmpdir, ruby_version)
222
223 # rbx build
224 prefix = "/tmp/#{output}"
225 output = "rbx-build-#{version}-#{ruby_version}"
226 build_rbx_command(name, output, prefix, usr_dir, tmpdir, ruby_version)
d41a3f3 @hone rake task to install rbx-2.0.0dev
hone authored Jan 16, 2012
227 end
228 end
229 end
230
1b2b445 @hone jruby install task
hone authored Jan 9, 2012
231 desc "install jruby"
232 task "jruby:install", :version do |t, args|
d82aa23 @hone build the jruby-launcher
hone authored Jan 17, 2012
233 version = args[:version]
234 name = "jruby-bin-#{version}"
235 output = "jruby-#{version}"
236 launcher = "launcher"
1b2b445 @hone jruby install task
hone authored Jan 10, 2012
237
238 Dir.mktmpdir("jruby-") do |tmpdir|
a139aa1 @hone don't keep jruby-x.x.x dir
hone authored Jan 9, 2012
239 Dir.chdir(tmpdir) do
1b2b445 @hone jruby install task
hone authored Jan 10, 2012
240 sh "curl http://jruby.org.s3.amazonaws.com/downloads/#{version}/#{name}.tar.gz -s -o - | tar vzxf -"
d82aa23 @hone build the jruby-launcher
hone authored Jan 17, 2012
241 Dir.chdir("#{output}/bin") do
242 sh "curl #{VENDOR_URL}/jruby-launcher-1.0.12-java.tgz -s -o - | tar vzxf -"
243 end
1b2b445 @hone jruby install task
hone authored Jan 10, 2012
244 sh "rm #{output}/bin/*.bat"
245 sh "rm #{output}/bin/*.dll"
246 sh "rm #{output}/bin/*.exe"
247 sh "rm -rf #{output}/docs"
248 sh "rm -rf #{output}/samples"
249 sh "rm -rf #{output}/share"
250 sh "rm -rf #{output}/tool"
251 sh "ln -s jruby #{output}/bin/ruby"
a139aa1 @hone don't keep jruby-x.x.x dir
hone authored Jan 10, 2012
252 Dir.chdir(output) do
253 sh("tar czvf #{tmpdir}/#{output}.tgz *")
254 s3_upload(tmpdir, output)
255 end
1b2b445 @hone jruby install task
hone authored Jan 10, 2012
256 end
257 end
258 end
259
d82aa23 @hone build the jruby-launcher
hone authored Jan 17, 2012
260 desc "build the jruby-launcher"
261 task "jruby:launcher", :version do |t, args|
262 version = args[:version]
263 name = "jruby-launcher-#{version}-java"
264 prefix = "/tmp/jruby-launcher"
265
266 Dir.mktmpdir("jruby-launcher-") do |tmpdir|
267 Dir.chdir(tmpdir) do
268 sh "gem fetch jruby-launcher --platform java --version #{version}"
269 sh "gem unpack jruby-launcher-#{version}-java.gem"
270
271 build_command = [
272 "make",
273 "mkdir -p #{prefix}",
274 "cp jruby #{prefix}"
275 ].join(" && ")
276
277 sh "vulcan build -v -o #{name}.tgz --source #{name} --prefix #{prefix} --command=\"#{build_command}\""
278 s3_upload(tmpdir, name)
279 end
280 end
281
282 end
283
0fe5f39 @hone task to generate ruby versions manifest file
hone authored Nov 8, 2011
284 desc "generate ruby versions manifest"
285 task "ruby:manifest" do
286 require 'rexml/document'
287 require 'yaml'
288
289 document = REXML::Document.new(`curl https://#{S3_BUCKET_NAME}.s3.amazonaws.com`)
c05cea1 @hone support jruby in ruby versions yml file
hone authored Jan 9, 2012
290 rubies = document.elements.to_a("//Contents/Key").map {|node| node.text }.select {|text| text.match(/^(ruby|rbx|jruby)-\\\\d+\\\\.\\\\d+\\\\.\\\\d+(-p\\\\d+)?/) }
0fe5f39 @hone task to generate ruby versions manifest file
hone authored Nov 8, 2011
291
292 Dir.mktmpdir("ruby_versions-") do |tmpdir|
293 name = 'ruby_versions.yml'
294 File.open(name, 'w') {|file| file.puts(rubies.to_yaml) }
295 sh("#{s3_tools_dir}/s3 put #{S3_BUCKET_NAME} #{name} #{name}")
296 end
297 end
298
cf2aa29 @hone rake task for installing libffi
hone authored Nov 4, 2011
299 desc "install libffi"
300 task "libffi:install", :version do |t, args|
301 version = args[:version]
302 name = "libffi-#{version}"
303 prefix = "/app/vendor/#{name}"
304 Dir.mktmpdir("libffi-") do |tmpdir|
305 Dir.chdir(tmpdir) do |dir|
306 FileUtils.rm_rf("#{tmpdir}/*")
307
308 sh "curl ftp://sourceware.org/pub/libffi/libffi-#{version}.tar.gz -s -o - | tar vzxf -"
4a977dd @hone make build command easier to read for libffi
hone authored Nov 5, 2011
309
310 build_command = [
311 "env CFLAGS=-fPIC ./configure --enable-static --disable-shared --prefix=#{prefix}",
312 "make",
313 "make install",
314 "mv #{prefix}/lib/#{name}/include #{prefix}",
315 "rm -rf #{prefix}/lib/#{name}"
316 ].join(" && ")
317
318 sh "vulcan build -v -o #{name}.tgz --source #{name} --command=\"#{build_command}\""
cf2aa29 @hone rake task for installing libffi
hone authored Nov 4, 2011
319 s3_upload(tmpdir, name)
320 end
321 end
322 end
Something went wrong with that request. Please try again.