Permalink
Browse files

Merge branch 'upstream/master' into merge

  • Loading branch information...
davidjrice committed Aug 1, 2012
2 parents 1723963 + c4f2cc0 commit 53b958d6127aaf7af07aa702b7bb8605c27a3929
Showing with 303 additions and 59 deletions.
  1. +62 −0 CHANGELOG.md
  2. +53 −32 Rakefile
  3. +3 −0 bin/compile
  4. +22 −0 lib/language_pack/base.rb
  5. +8 −0 lib/language_pack/rack.rb
  6. +8 −1 lib/language_pack/rails2.rb
  7. +3 −3 lib/language_pack/rails3.rb
  8. +144 −23 lib/language_pack/ruby.rb
View
@@ -1,3 +1,65 @@
+## v29 (7/19/2012)
+
+Features:
+
+* support .profile.d/ruby.sh
+* sync stdout so that the buildpack streams even in non-interactive shells
+* Upgrade to Bundler 1.2.0.rc
+
+## v28 (7/16/2012)
+
+Features:
+
+* Vendor OpenJDK6 into slug when using JRuby
+* ruby version support for ruby 1.8.7 via bundler's ruby DSL
+
+Bugfixes:
+
+* sqlite3 error gets displayed again
+
+## v27 (6/14/2012)
+
+Bugfixes:
+
+* Remove `vendor/bundle` message only appears when dir actually exists
+
+## v26 (6/14/2012)
+
+Features:
+
+* print message when assets:precompile finishes successfully
+* Remove `vendor/bundle` if user commits it to their git repo.
+
+## v25 (6/12/2012)
+
+Features:
+
+* support "ruby-xxx-jruby-yyy" for jruby detection packages
+
+## v24 (6/7/2012)
+
+Features:
+
+* removes bundler cache in the slug, to minimize slug size (@stevenh512, #16)
+* optimize push time with caching
+
+## v23 (5/8/2012)
+
+Bugfixes:
+
+* fix ruby version bug with "fatal:-Not-a-git-repository"
+
+## v22 (5/7/2012)
+
+Features:
+
+* bundler 1.2.0.pre
+* ruby version support for ruby 1.9.2/1.9.3 via bundler's ruby DSL
+
+Deprecation:
+
+* ENV['RUBY_VERSION'] in favor of bundler's ruby DSL
+
## v21 (3/21/2012)
Features:
View
@@ -14,13 +14,14 @@ def s3_upload(tmpdir, name)
sh("#{s3_tools_dir}/s3 put #{S3_BUCKET_NAME} #{name}.tgz #{tmpdir}/#{name}.tgz")
end
-def vendor_plugin(git_url)
+def vendor_plugin(git_url, branch = nil)
name = File.basename(git_url, File.extname(git_url))
Dir.mktmpdir("#{name}-") do |tmpdir|
FileUtils.rm_rf("#{tmpdir}/*")
Dir.chdir(tmpdir) do
sh "git clone #{git_url} ."
+ sh "git checkout origin/#{branch}" if branch
FileUtils.rm_rf("#{name}/.git")
sh("tar czvf #{tmpdir}/#{name}.tgz *")
s3_upload(tmpdir, name)
@@ -54,14 +55,15 @@ def install_gem(gem, version)
end
end
-def build_ruby_command(name, output, prefix, usr_dir, tmpdir)
+def build_ruby_command(name, output, prefix, usr_dir, tmpdir, rubygems = nil)
build_command = [
# need to move libyaml/libffi to dirs we can see
- "mv usr /tmp",
+ "mv #{usr_dir} /tmp",
"./configure --disable-install-doc --prefix #{prefix}",
"env CPATH=/tmp/#{usr_dir}/include:\\$CPATH CPPATH=/tmp/#{usr_dir}/include:\\$CPPATH LIBRARY_PATH=/tmp/#{usr_dir}/lib:\\$LIBRARY_PATH make",
"make install"
]
+ build_command << "#{prefix}/bin/ruby /tmp/#{usr_dir}/rubygems-#{rubygems}/setup.rb"
build_command << "mv #{prefix} /app/vendor/#{name}" if name != output
build_command = build_command.join(" && ")
@@ -86,7 +88,7 @@ end
desc "update plugins"
task "plugins:update" do
- vendor_plugin "http://github.com/ddollar/rails_log_stdout.git"
+ vendor_plugin "http://github.com/heroku/rails_log_stdout.git", "legacy"
vendor_plugin "http://github.com/pedro/rails3_serve_static_assets.git"
vendor_plugin "http://github.com/hone/rails31_enable_runtime_asset_compilation.git"
end
@@ -150,28 +152,34 @@ end
desc "install ruby"
task "ruby:install", :version do |t, args|
- version = args[:version]
- name = "ruby-#{version}"
- usr_dir = "usr"
+ full_version = args[:version]
+ full_name = "ruby-#{full_version}"
+ version = full_version.split('-').first
+ name = "ruby-#{version}"
+ usr_dir = "usr"
+ rubygems = nil
Dir.mktmpdir("ruby-") do |tmpdir|
Dir.chdir(tmpdir) do |dir|
FileUtils.rm_rf("#{tmpdir}/*")
- sh "curl http://ftp.ruby-lang.org/pub/ruby/1.9/#{name}.tar.gz -s -o - | tar vzxf -"
- FileUtils.mkdir_p("#{name}/#{usr_dir}")
- Dir.chdir("#{name}/#{usr_dir}") do
- sh "curl #{VENDOR_URL}/libyaml-0.1.4.tgz -s -o - | tar vzxf -"
- sh "curl #{VENDOR_URL}/libffi-3.0.10.tgz -s -o - | tar vzxf -"
+ major_ruby = version.match(/\d\.\d/)[0]
+ rubygems = "1.8.24" if major_ruby == "1.8"
+ sh "curl http://ftp.ruby-lang.org/pub/ruby/#{major_ruby}/#{full_name}.tar.gz -s -o - | tar zxf -"
+ FileUtils.mkdir_p("#{full_name}/#{usr_dir}")
+ Dir.chdir("#{full_name}/#{usr_dir}") do
+ sh "curl #{VENDOR_URL}/libyaml-0.1.4.tgz -s -o - | tar zxf -"
+ sh "curl #{VENDOR_URL}/libffi-3.0.10.tgz -s -o - | tar zxf -"
+ sh "curl http://production.cf.rubygems.org/rubygems/rubygems-#{rubygems}.tgz -s -o - | tar xzf -" if major_ruby == "1.8"
end
# runtime ruby
prefix = "/app/vendor/#{name}"
- build_ruby_command(name, name, prefix, usr_dir, tmpdir)
+ build_ruby_command(full_name, name, prefix, usr_dir, tmpdir, rubygems)
# build ruby
output = "ruby-build-#{version}"
prefix = "/tmp/#{name}"
- build_ruby_command(name, output, prefix, usr_dir, tmpdir)
+ build_ruby_command(full_name, output, prefix, usr_dir, tmpdir, rubygems)
end
end
end
@@ -231,30 +239,43 @@ task "rbx2dev:install", :version, :ruby_version do |t, args|
end
desc "install jruby"
-task "jruby:install", :version do |t, args|
- version = args[:version]
- name = "jruby-bin-#{version}"
- output = "jruby-#{version}"
- launcher = "launcher"
+task "jruby:install", :version, :ruby_version do |t, args|
+ version = args[:version]
+ ruby_version = args[:ruby_version]
+ name = "jruby-src-#{version}"
+ src_folder = "jruby-#{version}"
+ output = "ruby-#{ruby_version}-jruby-#{version}"
+ launcher = "launcher"
Dir.mktmpdir("jruby-") do |tmpdir|
+ tmpdir = Dir.mktmpdir("jruby-")
Dir.chdir(tmpdir) do
sh "curl http://jruby.org.s3.amazonaws.com/downloads/#{version}/#{name}.tar.gz -s -o - | tar vzxf -"
- Dir.chdir("#{output}/bin") do
- sh "curl #{VENDOR_URL}/jruby-launcher-1.0.12-java.tgz -s -o - | tar vzxf -"
+ sh "rm -rf test"
+ Dir.chdir(src_folder) do
+ 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 -"
+ sh "rm -rf manual"
end
- sh "rm #{output}/bin/*.bat"
- sh "rm #{output}/bin/*.dll"
- sh "rm #{output}/bin/*.exe"
- sh "rm -rf #{output}/docs"
- sh "rm -rf #{output}/samples"
- sh "rm -rf #{output}/share"
- sh "rm -rf #{output}/tool"
- sh "ln -s jruby #{output}/bin/ruby"
- Dir.chdir(output) do
- sh("tar czvf #{tmpdir}/#{output}.tgz *")
- s3_upload(tmpdir, output)
+ Dir.chdir("#{src_folder}/bin") do
+ sh "curl #{VENDOR_URL}/jruby-launcher-1.0.12-java.tgz -s -o - | tar vzxf -"
end
+
+ major, minor, patch = ruby_version.split('.')
+
+ build_command = [
+ "apache-ant-1.8.4/bin/ant -Djruby.default.ruby.version=#{major}.#{minor}",
+ "rm bin/*.bat",
+ "rm bin/*.dll",
+ "rm bin/*.exe",
+ "ln -s jruby bin/ruby",
+ "mkdir -p /app/vendor/#{output}",
+ "mv bin /app/vendor/#{output}",
+ "mv lib /app/vendor/#{output}"
+ ]
+ build_command = build_command.join(" && ")
+ sh "vulcan build -v -o #{output}.tgz --prefix /app/vendor/#{output} --source #{src_folder} --command=\"#{build_command}\""
+
+ s3_upload(tmpdir, output)
end
end
end
View
@@ -1,5 +1,8 @@
#!/usr/bin/env ruby
+# sync output
+$stdout.sync = true
+
$:.unshift File.expand_path("../../lib", __FILE__)
require "language_pack"
View
@@ -96,6 +96,21 @@ def log(*args)
def setup_language_pack_environment
end
+ def add_to_profiled(string)
+ FileUtils.mkdir_p "#{build_path}/.profile.d"
+ File.open("#{build_path}/.profile.d/ruby.sh", "a") do |file|
+ file.puts string
+ end
+ end
+
+ def set_env_default(key, val)
+ add_to_profiled "export #{key}=${#{key}:-#{val}}"
+ end
+
+ def set_env_override(key, val)
+ add_to_profiled %{export #{key}="#{val.gsub('"','\"')}"}
+ end
+
def log_internal(*args)
message = build_log_message(args)
%x{ logger -p user.notice -t "slugc[$$]" "buildpack-ruby #{message}" }
@@ -131,6 +146,13 @@ def run(command)
%x{ #{command} 2>&1 }
end
+ # run a shell command and pipe stderr to /dev/null
+ # @param [String] command to be run
+ # @return [String] output of stdout
+ def run_stdout(command)
+ %x{ #{command} 2>/dev/null }
+ end
+
# run a shell command and stream the ouput
# @param [String] command to be run
def pipe(command)
@@ -31,5 +31,13 @@ def default_process_types
})
end
+private
+
+ # sets up the profile.d script for this buildpack
+ def setup_profiled
+ super
+ set_env_default "RACK_ENV", "production"
+ end
+
end
@@ -71,11 +71,18 @@ def install_plugin(name)
end
end
-
# most rails apps need a database
# @return [Array] shared database addon
def add_shared_database_addon
['shared-database:5mb']
end
+
+ # sets up the profile.d script for this buildpack
+ def setup_profiled
+ super
+ set_env_default "RACK_ENV", "production"
+ set_env_default "RAILS_ENV", "production"
+ end
+
end
@@ -47,12 +47,12 @@ def run_assets_precompile_rake_task
ENV["RAILS_ENV"] ||= "production"
puts "Running: rake assets:precompile"
- rake_output = ""
- rake_output << run("env PATH=$PATH:bin bundle exec rake assets:precompile 2>&1")
- puts rake_output
+ require 'benchmark'
+ time = Benchmark.realtime { pipe("env PATH=$PATH:bin bundle exec rake assets:precompile 2>&1") }
if $?.success?
log "assets_precompile", :status => "success"
+ puts "Asset precompilation completed (#{"%.2f" % time}s)"
else
log "assets_precompile", :status => "failure"
puts "Precompiling assets failed, enabling runtime asset compilation"
Oops, something went wrong.

0 comments on commit 53b958d

Please sign in to comment.