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