heroku_hatchet 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +14 -0
  3. data/CHANGELOG.md +4 -0
  4. data/README.md +2 -2
  5. data/Rakefile +6 -0
  6. data/hatchet.gemspec +3 -1
  7. data/hatchet.json +3 -2
  8. data/lib/hatchet.rb +2 -0
  9. data/lib/hatchet/anvil_app.rb +28 -18
  10. data/lib/hatchet/app.rb +19 -5
  11. data/lib/hatchet/git_app.rb +5 -2
  12. data/lib/hatchet/tasks.rb +17 -7
  13. data/lib/hatchet/version.rb +1 -1
  14. data/test/fixtures/buildpacks/heroku-buildpack-ruby/.gitignore +4 -0
  15. data/test/fixtures/buildpacks/heroku-buildpack-ruby/CHANGELOG.md +378 -0
  16. data/test/fixtures/buildpacks/heroku-buildpack-ruby/Gemfile +10 -0
  17. data/test/fixtures/buildpacks/heroku-buildpack-ruby/LICENSE +9 -0
  18. data/test/fixtures/buildpacks/heroku-buildpack-ruby/README.md +192 -0
  19. data/test/fixtures/buildpacks/heroku-buildpack-ruby/Rakefile +358 -0
  20. data/test/fixtures/buildpacks/heroku-buildpack-ruby/bin/compile +13 -0
  21. data/test/fixtures/buildpacks/heroku-buildpack-ruby/bin/detect +12 -0
  22. data/test/fixtures/buildpacks/heroku-buildpack-ruby/bin/release +9 -0
  23. data/test/fixtures/buildpacks/heroku-buildpack-ruby/hatchet.json +25 -0
  24. data/test/fixtures/buildpacks/heroku-buildpack-ruby/lib/language_pack.rb +27 -0
  25. data/test/fixtures/buildpacks/heroku-buildpack-ruby/lib/language_pack/base.rb +175 -0
  26. data/test/fixtures/buildpacks/heroku-buildpack-ruby/lib/language_pack/bundler_lockfile.rb +19 -0
  27. data/test/fixtures/buildpacks/heroku-buildpack-ruby/lib/language_pack/disable_deploys.rb +17 -0
  28. data/test/fixtures/buildpacks/heroku-buildpack-ruby/lib/language_pack/no_lockfile.rb +16 -0
  29. data/test/fixtures/buildpacks/heroku-buildpack-ruby/lib/language_pack/rack.rb +43 -0
  30. data/test/fixtures/buildpacks/heroku-buildpack-ruby/lib/language_pack/rails2.rb +91 -0
  31. data/test/fixtures/buildpacks/heroku-buildpack-ruby/lib/language_pack/rails3.rb +86 -0
  32. data/test/fixtures/buildpacks/heroku-buildpack-ruby/lib/language_pack/rails4.rb +66 -0
  33. data/test/fixtures/buildpacks/heroku-buildpack-ruby/lib/language_pack/ruby.rb +681 -0
  34. data/test/fixtures/buildpacks/heroku-buildpack-ruby/lib/language_pack/shell_helpers.rb +62 -0
  35. data/test/fixtures/buildpacks/heroku-buildpack-ruby/spec/bugs_spec.rb +11 -0
  36. data/test/fixtures/buildpacks/heroku-buildpack-ruby/spec/no_lockfile_spec.rb +10 -0
  37. data/test/fixtures/buildpacks/heroku-buildpack-ruby/spec/rails23_spec.rb +11 -0
  38. data/test/fixtures/buildpacks/heroku-buildpack-ruby/spec/rails3_spec.rb +22 -0
  39. data/test/fixtures/buildpacks/heroku-buildpack-ruby/spec/rails4_spec.rb +12 -0
  40. data/test/fixtures/buildpacks/heroku-buildpack-ruby/spec/rubies_spec.rb +38 -0
  41. data/test/fixtures/buildpacks/heroku-buildpack-ruby/spec/spec_helper.rb +35 -0
  42. data/test/fixtures/buildpacks/heroku-buildpack-ruby/support/s3/hmac +79 -0
  43. data/test/fixtures/buildpacks/heroku-buildpack-ruby/support/s3/s3 +223 -0
  44. data/test/fixtures/buildpacks/heroku-buildpack-ruby/vendor/syck_hack.rb +64 -0
  45. data/test/hatchet/allow_failure_anvil_test.rb +21 -0
  46. data/test/hatchet/allow_failure_git_test.rb +17 -0
  47. data/test/hatchet/anvil_test.rb +7 -7
  48. data/test/hatchet/config_test.rb +4 -2
  49. data/test/hatchet/git_test.rb +2 -2
  50. metadata +89 -8
@@ -0,0 +1,10 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development, :test do
4
+ gem "heroku_hatchet"
5
+ gem "rspec-core"
6
+ gem "rspec-expectations"
7
+ gem "excon"
8
+ gem "rake"
9
+ gem "parallel_tests"
10
+ end
@@ -0,0 +1,9 @@
1
+ MIT License:
2
+
3
+ Copyright (C) 2012 Heroku, Inc.
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,192 @@
1
+ Heroku buildpack: Ruby
2
+ ======================
3
+
4
+ This is a [Heroku buildpack](http://devcenter.heroku.com/articles/buildpacks) for Ruby, Rack, and Rails apps. It uses [Bundler](http://gembundler.com) for dependency management.
5
+
6
+ Usage
7
+ -----
8
+
9
+ ### Ruby
10
+
11
+ Example Usage:
12
+
13
+ $ ls
14
+ Gemfile Gemfile.lock
15
+
16
+ $ heroku create --stack cedar --buildpack https://github.com/heroku/heroku-buildpack-ruby.git
17
+
18
+ $ git push heroku master
19
+ ...
20
+ -----> Heroku receiving push
21
+ -----> Fetching custom buildpack
22
+ -----> Ruby app detected
23
+ -----> Installing dependencies using Bundler version 1.1.rc
24
+ Running: bundle install --without development:test --path vendor/bundle --deployment
25
+ Fetching gem metadata from http://rubygems.org/..
26
+ Installing rack (1.3.5)
27
+ Using bundler (1.1.rc)
28
+ Your bundle is complete! It was installed into ./vendor/bundle
29
+ Cleaning up the bundler cache.
30
+ -----> Discovering process types
31
+ Procfile declares types -> (none)
32
+ Default types for Ruby -> console, rake
33
+
34
+ The buildpack will detect your app as Ruby if it has a `Gemfile` and `Gemfile.lock` files in the root directory. It will then proceed to run `bundle install` after setting up the appropriate environment for [ruby](http://ruby-lang.org) and [Bundler](http://gembundler.com).
35
+
36
+ #### Run the Tests
37
+
38
+ The tests on this buildpack are written in Rspec to allow the use of
39
+ `focused: true`. Parallelization of testing is provided by
40
+ https://github.com/grosser/parallel_tests this lib spins up an arbitrary
41
+ number of processes and running a different test file in each process,
42
+ it does not parallelize tests within a test file. To run the tests: clone the repo, then `bundle install` then clone the test fixtures by running:
43
+
44
+ ```sh
45
+ $ hatchet install
46
+ ```
47
+
48
+ Now run the tests:
49
+
50
+ ```sh
51
+ $ bundle exec parallel_rspec -n 6 spec/
52
+ ```
53
+
54
+ If you don't want to run them in parallel you can still:
55
+
56
+ ```sh
57
+ $ bundle exec rake spec
58
+ ```
59
+
60
+ Now go take a nap or something for a really long time.
61
+
62
+ #### Bundler
63
+
64
+ For non-windows `Gemfile.lock` files, the `--deployment` flag will be used. In the case of windows, the Gemfile.lock will be deleted and Bundler will do a full resolve so native gems are handled properly. The `vendor/bundle` directory is cached between builds to allow for faster `bundle install` times. `bundle clean` is used to ensure no stale gems are stored between builds.
65
+
66
+ ### Rails 2
67
+
68
+ Example Usage:
69
+
70
+ $ ls
71
+ app config db doc Gemfile Gemfile.lock lib log public Rakefile README script test tmp vendor
72
+
73
+ $ ls config/environment.rb
74
+ config/environment.rb
75
+
76
+ $ heroku create --stack cedar --buildpack https://github.com/heroku/heroku-buildpack-ruby.git
77
+
78
+ $ git push heroku master
79
+ ...
80
+ -----> Heroku receiving push
81
+ -----> Ruby/Rails app detected
82
+ -----> Installing dependencies using Bundler version 1.1.rc
83
+ ...
84
+ -----> Writing config/database.yml to read from DATABASE_URL
85
+ -----> Rails plugin injection
86
+ Injecting rails_log_stdout
87
+ -----> Discovering process types
88
+ Procfile declares types -> (none)
89
+ Default types for Ruby/Rails -> console, rake, web, worker
90
+
91
+ The buildpack will detect your app as a Rails 2 app if it has a `environment.rb` file in the `config` directory.
92
+
93
+ #### Rails Log STDOUT
94
+ A [rails_log_stdout](http://github.com/ddollar/rails_log_stdout) is installed by default so Rails' logger will log to STDOUT and picked up by Heroku's [logplex](http://github.com/heroku/logplex).
95
+
96
+ #### Auto Injecting Plugins
97
+
98
+ Any vendored plugin can be stopped from being installed by creating the directory it's installed to in the slug. For instance, to prevent rails_log_stdout plugin from being injected, add `vendor/plugins/rails_log_stdout/.gitkeep` to your git repo.
99
+
100
+ ### Rails 3
101
+
102
+ Example Usage:
103
+
104
+ $ ls
105
+ app config config.ru db doc Gemfile Gemfile.lock lib log Procfile public Rakefile README script tmp vendor
106
+
107
+ $ ls config/application.rb
108
+ config/application.rb
109
+
110
+ $ heroku create --stack cedar --buildpack https://github.com/heroku/heroku-buildpack-ruby.git
111
+
112
+ $ git push heroku master
113
+ -----> Heroku receiving push
114
+ -----> Ruby/Rails app detected
115
+ -----> Installing dependencies using Bundler version 1.1.rc
116
+ Running: bundle install --without development:test --path vendor/bundle --deployment
117
+ ...
118
+ -----> Writing config/database.yml to read from DATABASE_URL
119
+ -----> Preparing app for Rails asset pipeline
120
+ Running: rake assets:precompile
121
+ -----> Rails plugin injection
122
+ Injecting rails_log_stdout
123
+ Injecting rails3_serve_static_assets
124
+ -----> Discovering process types
125
+ Procfile declares types -> web
126
+ Default types for Ruby/Rails -> console, rake, worker
127
+
128
+ The buildpack will detect your apps as a Rails 3 app if it has an `application.rb` file in the `config` directory.
129
+
130
+ #### Assets
131
+
132
+ To enable static assets being served on the dyno, [rails3_serve_static_assets](http://github.com/pedro/rails3_serve_static_assets) is installed by default. If the [execjs gem](http://github.com/sstephenson/execjs) is detected then [node.js](http://github.com/joyent/node) will be vendored. The `assets:precompile` rake task will get run if no `public/manifest.yml` is detected. See [this article](http://devcenter.heroku.com/articles/rails31_heroku_cedar) on how rails 3.1 works on cedar.
133
+
134
+ Hacking
135
+ -------
136
+
137
+ To use this buildpack, fork it on Github. Push up changes to your fork, then create a test app with `--buildpack <your-github-url>` and push to it.
138
+
139
+ To change the vendored binaries for Bundler, [Node.js](http://github.com/joyent/node), and rails plugins, use the rake tasks provided by the `Rakefile`. You'll need an S3-enabled AWS account and a bucket to store your binaries in as well as the [vulcan](http://github.com/heroku/vulcan) gem to build the binaries on heroku.
140
+
141
+ For example, you can change the vendored version of Bundler to 1.1.rc.
142
+
143
+ First you'll need to build a Heroku-compatible version of Node.js:
144
+
145
+ $ export AWS_ID=xxx AWS_SECRET=yyy S3_BUCKET=zzz
146
+ $ s3 create $S3_BUCKET
147
+ $ rake gem:install[bundler,1.1.rc]
148
+
149
+ Open `lib/language_pack/ruby.rb` in your editor, and change the following line:
150
+
151
+ BUNDLER_VERSION = "1.1.rc"
152
+
153
+ Open `lib/language_pack/base.rb` in your editor, and change the following line:
154
+
155
+ VENDOR_URL = "https://s3.amazonaws.com/zzz"
156
+
157
+ Commit and push the changes to your buildpack to your Github fork, then push your sample app to Heroku to test. You should see:
158
+
159
+ -----> Installing dependencies using Bundler version 1.1.rc
160
+
161
+ NOTE: You'll need to vendor the plugins, node, Bundler, and libyaml by running the rake tasks for the buildpack to work properly.
162
+
163
+ Flow
164
+ ----
165
+
166
+ Here's the basic flow of how the buildpack works:
167
+
168
+ Ruby (Gemfile and Gemfile.lock is detected)
169
+
170
+ * runs Bundler
171
+ * installs binaries
172
+ * installs node if the gem execjs is detected
173
+ * runs `rake assets:precompile` if the rake task is detected
174
+
175
+ Rack (config.ru is detected)
176
+
177
+ * everything from Ruby
178
+ * sets RACK_ENV=production
179
+
180
+ Rails 2 (config/environment.rb is detected)
181
+
182
+ * everything from Rack
183
+ * sets RAILS_ENV=production
184
+ * install rails 2 plugins
185
+ * [rails_log_stdout](http://github.com/ddollar/rails_log_stdout)
186
+
187
+ Rails 3 (config/application.rb is detected)
188
+
189
+ * everything from Rails 2
190
+ * install rails 3 plugins
191
+ * [rails3_server_static_assets](https://github.com/pedro/rails3_serve_static_assets)
192
+
@@ -0,0 +1,358 @@
1
+ require "fileutils"
2
+ require "tmpdir"
3
+
4
+ S3_BUCKET_NAME = "heroku-buildpack-ruby"
5
+ VENDOR_URL = "https://s3.amazonaws.com/#{S3_BUCKET_NAME}"
6
+
7
+ def s3_tools_dir
8
+ File.expand_path("../support/s3", __FILE__)
9
+ end
10
+
11
+ def s3_upload(tmpdir, name)
12
+ sh("#{s3_tools_dir}/s3 put #{S3_BUCKET_NAME} #{name}.tgz #{tmpdir}/#{name}.tgz")
13
+ end
14
+
15
+ def vendor_plugin(git_url, branch = nil)
16
+ name = File.basename(git_url, File.extname(git_url))
17
+ Dir.mktmpdir("#{name}-") do |tmpdir|
18
+ FileUtils.rm_rf("#{tmpdir}/*")
19
+
20
+ Dir.chdir(tmpdir) do
21
+ sh "git clone #{git_url} ."
22
+ sh "git checkout origin/#{branch}" if branch
23
+ FileUtils.rm_rf("#{name}/.git")
24
+ sh("tar czvf #{tmpdir}/#{name}.tgz *")
25
+ s3_upload(tmpdir, name)
26
+ end
27
+ end
28
+ end
29
+
30
+ def in_gem_env(gem_home, &block)
31
+ old_gem_home = ENV['GEM_HOME']
32
+ old_gem_path = ENV['GEM_PATH']
33
+ ENV['GEM_HOME'] = ENV['GEM_PATH'] = gem_home.to_s
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)
42
+ name = "#{gem}-#{version}"
43
+ Dir.mktmpdir("#{gem}-#{version}") do |tmpdir|
44
+ Dir.chdir(tmpdir) do |dir|
45
+ FileUtils.rm_rf("#{tmpdir}/*")
46
+
47
+ in_gem_env(tmpdir) do
48
+ sh("gem install #{gem} --version #{version} --no-ri --no-rdoc --env-shebang")
49
+ sh("tar czvf #{tmpdir}/#{name}.tgz *")
50
+ s3_upload(tmpdir, name)
51
+ end
52
+ end
53
+ end
54
+ end
55
+
56
+ def build_ruby_command(name, output, prefix, usr_dir, tmpdir, rubygems = nil)
57
+ vulcan_prefix = "/app/vendor/#{output}"
58
+ build_command = [
59
+ # need to move libyaml/libffi to dirs we can see
60
+ "mv #{usr_dir} /tmp",
61
+ "./configure --enable-load-relative --disable-install-doc --prefix #{prefix}",
62
+ "env CPATH=/tmp/#{usr_dir}/include:\\$CPATH CPPATH=/tmp/#{usr_dir}/include:\\$CPPATH LIBRARY_PATH=/tmp/#{usr_dir}/lib:\\$LIBRARY_PATH make",
63
+ "make install"
64
+ ]
65
+ build_command << "#{prefix}/bin/ruby /tmp/#{usr_dir}/rubygems-#{rubygems}/setup.rb" if rubygems
66
+ build_command << "mv #{prefix} /app/vendor/#{output}" if prefix != "/app/vendor/#{output}"
67
+ build_command = build_command.join(" && ")
68
+
69
+ sh "vulcan build -v -o #{output}.tgz --prefix #{vulcan_prefix} --source #{name} --command=\"#{build_command}\""
70
+ s3_upload(tmpdir, output)
71
+ end
72
+
73
+ def build_rbx_command(name, output, prefix, usr_dir, tmpdir, ruby_version)
74
+ build_command = [
75
+ # need to move libyaml/libffi to dirs we can see
76
+ "mv usr /tmp",
77
+ "ls /tmp/#{usr_dir}",
78
+ "./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",
79
+ "rake install"
80
+ ]
81
+ # build_command << "mv #{prefix} /app/vendor/#{name}" if name != output
82
+ build_command = build_command.join(" && ")
83
+
84
+ sh "vulcan build -v -o #{output}.tgz --source #{name} --prefix #{prefix} --command=\"#{build_command}\""
85
+ s3_upload(tmpdir, output)
86
+ end
87
+
88
+ desc "update plugins"
89
+ task "plugins:update" do
90
+ vendor_plugin "http://github.com/heroku/rails_log_stdout.git", "legacy"
91
+ vendor_plugin "http://github.com/pedro/rails3_serve_static_assets.git"
92
+ vendor_plugin "http://github.com/hone/rails31_enable_runtime_asset_compilation.git"
93
+ end
94
+
95
+ desc "install vendored gem"
96
+ task "gem:install", :gem, :version do |t, args|
97
+ gem = args[:gem]
98
+ version = args[:version]
99
+
100
+ install_gem(gem, version)
101
+ end
102
+
103
+ desc "install libyaml"
104
+ task "libyaml:install", :version do |t, args|
105
+ version = args[:version]
106
+ name = "libyaml-#{version}"
107
+ Dir.mktmpdir("libyaml-") do |tmpdir|
108
+ Dir.chdir(tmpdir) do |dir|
109
+ FileUtils.rm_rf("#{tmpdir}/*")
110
+ prefix = "/app/vendor/yaml-#{version}"
111
+
112
+ sh "curl http://pyyaml.org/download/libyaml/yaml-#{version}.tar.gz -s -o - | tar vzxf -"
113
+
114
+ build_command = [
115
+ "env CFLAGS=-fPIC ./configure --enable-static --disable-shared --prefix=#{prefix}",
116
+ "make",
117
+ "make install"
118
+ ].join(" && ")
119
+
120
+ sh "vulcan build -v -o #{name}.tgz --source yaml-#{version} --prefix=#{prefix} --command=\"#{build_command}\""
121
+ s3_upload(tmpdir, name)
122
+ end
123
+ end
124
+ end
125
+
126
+ desc "install node"
127
+ task "node:install", :version do |t, args|
128
+ version = args[:version]
129
+ name = "node-#{version}"
130
+ prefix = "/app/vendor/node-v#{version}"
131
+ Dir.mktmpdir("node-") do |tmpdir|
132
+ Dir.chdir(tmpdir) do |dir|
133
+ FileUtils.rm_rf("#{tmpdir}/*")
134
+
135
+ sh "curl http://nodejs.org/dist/node-v#{version}.tar.gz -s -o - | tar vzxf -"
136
+
137
+ build_command = [
138
+ "./configure --prefix #{prefix}",
139
+ "make install",
140
+ "mv #{prefix}/bin/node #{prefix}/.",
141
+ "rm -rf #{prefix}/include",
142
+ "rm -rf #{prefix}/lib",
143
+ "rm -rf #{prefix}/share",
144
+ "rm -rf #{prefix}/bin"
145
+ ].join(" && ")
146
+
147
+ sh "vulcan build -v -o #{name}.tgz --source node-v#{version} --command=\"#{build_command}\""
148
+ s3_upload(tmpdir, name)
149
+ end
150
+ end
151
+ end
152
+
153
+ desc "install ruby"
154
+ task "ruby:install", :version do |t, args|
155
+ full_version = args[:version]
156
+ full_name = "ruby-#{full_version}"
157
+ version = full_version.split('-').first
158
+ name = "ruby-#{version}"
159
+ usr_dir = "usr"
160
+ rubygems = nil
161
+ Dir.mktmpdir("ruby-") do |tmpdir|
162
+ Dir.chdir(tmpdir) do |dir|
163
+ FileUtils.rm_rf("#{tmpdir}/*")
164
+
165
+ major_ruby = version.match(/\d\.\d/)[0]
166
+ rubygems = "1.8.24" if major_ruby == "1.8"
167
+ sh "curl http://ftp.ruby-lang.org/pub/ruby/#{major_ruby}/#{full_name}.tar.gz -s -o - | tar zxf -"
168
+ FileUtils.mkdir_p("#{full_name}/#{usr_dir}")
169
+ Dir.chdir("#{full_name}/#{usr_dir}") do
170
+ sh "curl #{VENDOR_URL}/libyaml-0.1.4.tgz -s -o - | tar zxf -"
171
+ sh "curl #{VENDOR_URL}/libffi-3.0.10.tgz -s -o - | tar zxf -"
172
+ sh "curl http://production.cf.rubygems.org/rubygems/rubygems-#{rubygems}.tgz -s -o - | tar xzf -" if major_ruby == "1.8"
173
+ end
174
+
175
+ # runtime ruby
176
+ prefix = "/app/vendor/#{name}"
177
+ build_ruby_command(full_name, name, prefix, usr_dir, tmpdir, rubygems)
178
+
179
+ # build ruby
180
+ if major_ruby == "1.8"
181
+ output = "ruby-build-#{version}"
182
+ prefix = "/tmp/ruby-#{version}"
183
+ build_ruby_command(full_name, output, prefix, usr_dir, tmpdir, rubygems)
184
+ end
185
+ end
186
+ end
187
+ end
188
+
189
+ desc "install rbx"
190
+ task "rbx:install", :version do |t, args|
191
+ version = args[:version]
192
+ name = "rubinius-#{version}"
193
+ output = "rbx-#{version}"
194
+ prefix = "/app/vendor/#{output}"
195
+
196
+ Dir.mktmpdir("rbx-") do |tmpdir|
197
+ Dir.chdir(tmpdir) do |dir|
198
+ FileUtils.rm_rf("#{tmpdir}/*")
199
+
200
+ sh "curl http://asset.rubini.us/#{name}.tar.gz -s -o - | tar vzxf -"
201
+ build_command = [
202
+ "./configure --prefix #{prefix}",
203
+ "rake install"
204
+ ].join(" && ")
205
+
206
+ sh "vulcan build -v -o #{output}.tgz --source #{name} --prefix #{prefix} --command=\"#{build_command}\""
207
+ s3_upload(tmpdir, output)
208
+ end
209
+ end
210
+ end
211
+
212
+ desc "install rbx 2.0.0dev"
213
+ task "rbx2dev:install", :version, :ruby_version do |t, args|
214
+ version = args[:version]
215
+ ruby_version = args[:ruby_version]
216
+ source = "rubinius-#{version}"
217
+ name = "rubinius-2.0.0dev"
218
+ output = "rbx-#{version}-#{ruby_version}"
219
+ usr_dir = "usr"
220
+
221
+ Dir.mktmpdir("rbx-") do |tmpdir|
222
+ Dir.chdir(tmpdir) do |dir|
223
+ FileUtils.rm_rf("#{tmpdir}/*")
224
+
225
+ sh "curl http://asset.rubini.us/#{source}.tar.gz -s -o - | tar vzxf -"
226
+ FileUtils.mkdir_p("#{name}/#{usr_dir}")
227
+ Dir.chdir("#{name}/#{usr_dir}") do
228
+ sh "curl #{VENDOR_URL}/libyaml-0.1.4.tgz -s -o - | tar vzxf -"
229
+ sh "curl #{VENDOR_URL}/libffi-3.0.10.tgz -s -o - | tar vzxf -"
230
+ end
231
+
232
+ prefix = "/app/vendor/#{output}"
233
+ build_rbx_command(name, output, prefix, usr_dir, tmpdir, ruby_version)
234
+
235
+ # rbx build
236
+ prefix = "/tmp/#{output}"
237
+ output = "rbx-build-#{version}-#{ruby_version}"
238
+ build_rbx_command(name, output, prefix, usr_dir, tmpdir, ruby_version)
239
+ end
240
+ end
241
+ end
242
+
243
+ desc "install jruby"
244
+ task "jruby:install", :version, :ruby_version do |t, args|
245
+ version = args[:version]
246
+ ruby_version = args[:ruby_version]
247
+ name = "jruby-src-#{version}"
248
+ src_folder = "jruby-#{version}"
249
+ output = "ruby-#{ruby_version}-jruby-#{version}"
250
+ launcher = "launcher"
251
+
252
+ Dir.mktmpdir("jruby-") do |tmpdir|
253
+ Dir.chdir(tmpdir) do
254
+ sh "curl http://jruby.org.s3.amazonaws.com/downloads/#{version}/#{name}.tar.gz -s -o - | tar vzxf -"
255
+ sh "rm -rf test"
256
+ Dir.chdir(src_folder) do
257
+ 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 -"
258
+ sh "rm -rf manual"
259
+ end
260
+ Dir.chdir("#{src_folder}/bin") do
261
+ sh "curl #{VENDOR_URL}/jruby-launcher-1.0.12-java.tgz -s -o - | tar vzxf -"
262
+ end
263
+
264
+ major, minor, patch = ruby_version.split('.')
265
+
266
+ build_command = [
267
+ "apache-ant-1.8.4/bin/ant -Djruby.default.ruby.version=#{major}.#{minor}",
268
+ "rm bin/*.bat",
269
+ "rm bin/*.dll",
270
+ "rm bin/*.exe",
271
+ "ln -s jruby bin/ruby",
272
+ "mkdir -p /app/vendor/#{output}",
273
+ "mv bin /app/vendor/#{output}",
274
+ "mv lib /app/vendor/#{output}"
275
+ ]
276
+ build_command = build_command.join(" && ")
277
+ sh "vulcan build -v -o #{output}.tgz --prefix /app/vendor/#{output} --source #{src_folder} --command=\"#{build_command}\""
278
+
279
+ s3_upload(tmpdir, output)
280
+ end
281
+ end
282
+ end
283
+
284
+ desc "build the jruby-launcher"
285
+ task "jruby:launcher", :version do |t, args|
286
+ version = args[:version]
287
+ name = "jruby-launcher-#{version}-java"
288
+ prefix = "/tmp/jruby-launcher"
289
+
290
+ Dir.mktmpdir("jruby-launcher-") do |tmpdir|
291
+ Dir.chdir(tmpdir) do
292
+ sh "gem fetch jruby-launcher --platform java --version #{version}"
293
+ sh "gem unpack jruby-launcher-#{version}-java.gem"
294
+
295
+ build_command = [
296
+ "make",
297
+ "mkdir -p #{prefix}",
298
+ "cp jruby #{prefix}"
299
+ ].join(" && ")
300
+
301
+ sh "vulcan build -v -o #{name}.tgz --source #{name} --prefix #{prefix} --command=\"#{build_command}\""
302
+ s3_upload(tmpdir, name)
303
+ end
304
+ end
305
+
306
+ end
307
+
308
+ desc "generate ruby versions manifest"
309
+ task "ruby:manifest" do
310
+ require 'rexml/document'
311
+ require 'yaml'
312
+
313
+ document = REXML::Document.new(`curl https://#{S3_BUCKET_NAME}.s3.amazonaws.com`)
314
+ rubies = document.elements.to_a("//Contents/Key").map {|node| node.text }.select {|text| text.match(/^(ruby|rbx|jruby)-\\\\d+\\\\.\\\\d+\\\\.\\\\d+(-p\\\\d+)?/) }
315
+
316
+ Dir.mktmpdir("ruby_versions-") do |tmpdir|
317
+ name = 'ruby_versions.yml'
318
+ File.open(name, 'w') {|file| file.puts(rubies.to_yaml) }
319
+ sh("#{s3_tools_dir}/s3 put #{S3_BUCKET_NAME} #{name} #{name}")
320
+ end
321
+ end
322
+
323
+ desc "install libffi"
324
+ task "libffi:install", :version do |t, args|
325
+ version = args[:version]
326
+ name = "libffi-#{version}"
327
+ prefix = "/app/vendor/#{name}"
328
+ Dir.mktmpdir("libffi-") do |tmpdir|
329
+ Dir.chdir(tmpdir) do |dir|
330
+ FileUtils.rm_rf("#{tmpdir}/*")
331
+
332
+ sh "curl ftp://sourceware.org/pub/libffi/libffi-#{version}.tar.gz -s -o - | tar vzxf -"
333
+
334
+ build_command = [
335
+ "env CFLAGS=-fPIC ./configure --enable-static --disable-shared --prefix=#{prefix}",
336
+ "make",
337
+ "make install",
338
+ "mv #{prefix}/lib/#{name}/include #{prefix}",
339
+ "rm -rf #{prefix}/lib/#{name}"
340
+ ].join(" && ")
341
+
342
+ sh "vulcan build -v -o #{name}.tgz --source #{name} --prefix=#{prefix} --command=\"#{build_command}\""
343
+ s3_upload(tmpdir, name)
344
+ end
345
+ end
346
+ end
347
+
348
+ begin
349
+ require 'rspec/core/rake_task'
350
+
351
+ desc "Run specs"
352
+ RSpec::Core::RakeTask.new(:spec) do |t|
353
+ t.rspec_opts = %w(-fs --color)
354
+ #t.ruby_opts = %w(-w)
355
+ end
356
+ task :default => :spec
357
+ rescue LoadError => e
358
+ end