Permalink
Browse files

Merge branch 'master' of github.com:heroku/heroku-buildpack-ruby

  • Loading branch information...
2 parents ee63730 + 6b5e8dd commit 6025285985412d14a1c6ba63073b04b0585dc5e4 @mattmanning committed Jul 17, 2012
Showing with 97 additions and 34 deletions.
  1. +11 −0 CHANGELOG.md
  2. +50 −30 Rakefile
  3. +36 −4 lib/language_pack/ruby.rb
View
@@ -1,3 +1,14 @@
+## 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:
View
@@ -53,14 +53,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(" && ")
@@ -149,28 +150,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
@@ -230,30 +237,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
@@ -11,6 +11,8 @@ class LanguagePack::Ruby < LanguagePack::Base
BUNDLER_GEM_PATH = "bundler-#{BUNDLER_VERSION}"
NODE_VERSION = "0.4.7"
NODE_JS_BINARY_PATH = "node-#{NODE_VERSION}"
+ JVM_BASE_URL = "http://heroku-jvm-langpack-java.s3.amazonaws.com"
+ JVM_VERSION = "openjdk6-latest"
# detects if this is a valid Ruby app
# @return [Boolean] true if it's a Ruby app
@@ -47,6 +49,7 @@ def compile
Dir.chdir(build_path)
remove_vendor_bundle
install_ruby
+ install_jvm
setup_language_pack_environment
allow_git do
install_language_pack_gems
@@ -69,7 +72,13 @@ def default_path
# the relative path to the bundler directory of gems
# @return [String] resulting path
def slug_vendor_base
- @slug_vendor_base ||= run(%q(ruby -e "require 'rbconfig';puts \"vendor/bundle/#{RUBY_ENGINE}/#{RbConfig::CONFIG['ruby_version']}\"")).chomp
+ if @slug_vendor_base
+ @slug_vendor_base
+ elsif @ruby_version == "ruby-1.8.7"
+ @slug_vendor_base = "vendor/bundle/1.8"
+ else
+ @slug_vendor_base = run(%q(ruby -e "require 'rbconfig';puts \"vendor/bundle/#{RUBY_ENGINE}/#{RbConfig::CONFIG['ruby_version']}\"")).chomp
+ end
end
# the relative path to the vendored ruby directory
@@ -78,6 +87,12 @@ def slug_vendor_ruby
"vendor/#{ruby_version}"
end
+ # the relative path to the vendored jvm
+ # @return [String] resulting path
+ def slug_vendor_jvm
+ "vendor/jvm"
+ end
+
# the absolute path of the build ruby to use during the buildpack
# @return [String] resulting path
def build_ruby_path
@@ -174,7 +189,6 @@ def build_ruby?
end
# install the vendored ruby
- # @note this only installs if we detect RUBY_VERSION in the environment
# @return [Boolean] true if it installs the vendored ruby and false otherwise
def install_ruby
return false unless ruby_version
@@ -216,6 +230,24 @@ def install_ruby
true
end
+ # vendors JVM into the slug for JRuby
+ def install_jvm
+ if ruby_version_jruby?
+ topic "Installing JVM: #{JVM_VERSION}"
+
+ FileUtils.mkdir_p(slug_vendor_jvm)
+ Dir.chdir(slug_vendor_jvm) do
+ run("curl #{JVM_BASE_URL}/#{JVM_VERSION}.tar.gz -s -o - | tar xzf -")
+ end
+
+ bin_dir = "bin"
+ FileUtils.mkdir_p bin_dir
+ Dir["#{slug_vendor_jvm}/bin/*"].each do |bin|
+ run("ln -s ../#{bin} #{bin_dir}")
+ end
+ end
+ end
+
# find the ruby install path for its binstubs during build
# @return [String] resulting path or empty string if ruby is not vendored
def ruby_install_binstub_path
@@ -360,7 +392,7 @@ def build_bundler
else
log "bundle", :status => "failure"
error_message = "Failed to install gems via Bundler."
- if bundler_output.match(/Installing sqlite3 \([\w.]+\) with native extensions Unfortunately/)
+ if bundler_output.match(/Installing sqlite3 \([\w.]+\) with native extensions\s+Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension./)
error_message += <<ERROR
@@ -381,7 +413,7 @@ def syck_hack
ruby_version = run('ruby -e "puts RUBY_VERSION"').chomp
# < 1.9.3 includes syck, so we need to use the syck hack
if Gem::Version.new(ruby_version) < Gem::Version.new("1.9.3")
- "-r #{syck_hack_file}"
+ "-r#{syck_hack_file}"
else
""
end

0 comments on commit 6025285

Please sign in to comment.